16#ifdef DEBUG_ROOT_COCOA
28#include <Availability.h>
36#include "RConfigure.h"
53#pragma mark - Create a window or a view.
67 const NSUInteger
styleMask = kTitledWindowMask | kClosableWindowMask |
68 kMiniaturizableWindowMask | kResizableWindowMask;
76 throw std::runtime_error(
"CreateTopLevelWindow failed");
96 throw std::runtime_error(
"CreateChildView failed");
101#pragma mark - root window (does not really exist, it's our desktop built of all screens).
107 assert(
attr != 0 &&
"GetRootWindowAttributes, parameter 'attr' is null");
118 "GetRootWindowAttributes, gVirtualX is either null or has a wrong type");
128 attr->fBorderWidth = 0;
129 attr->fYourEventMask = 0;
130 attr->fAllEventMasks = 0;
138#pragma mark - Coordinate conversions.
143 assert(window !=
nil &&
"ConvertPointFromBaseToScreen, parameter 'window' is nil");
159 assert(window !=
nil &&
"ConvertPointFromScreenToBase, parameter 'window' is nil");
180 "GlobalYCocoaToROOT, gVirtualX is either nul or has a wrong type");
191 "GlobalXCocoaToROOT, gVirtualX is either nul or has a wrong type");
201 "GlobalYROOTToCocoa, gVirtualX is either nul or has a wrong type");
211 "GlobalXROOTToCocoa, gVirtualX is either nul or has a wrong type");
239 assert(drawable !=
nil &&
"LocalYROOTToCocoa, drawable is nil");
241 return int(drawable.fHeight -
yROOT);
247 assert(from !=
nil &&
"TranslateToScreen, parameter 'from' is nil");
261 assert(to !=
nil &&
"TranslateFromScreen, parameter 'to' is nil");
274 assert(from !=
nil &&
"TranslateCoordinates, parameter 'from' is nil");
275 assert(to !=
nil &&
"TranslateCoordinates, parameter 'to' is nil");
277 if ([from window] == [to window]) {
298 assert(view !=
nil &&
"ScreenPointIsInView, parameter 'view' is nil");
301 point.x =
x, point.y =
y;
305 if (point.x < 0 || point.x >
viewFrame.size.width)
307 if (point.y < 0 || point.y >
viewFrame.size.height)
313#pragma mark - Different FindView/Window functions iterating on the ROOT's windows/views.
340 assert(children !=
nil &&
"FindDNDAwareViewInPoint, parameter 'children' is nil");
456 "FindWindowForPointerEvent, parameter 'pointerEvent' is nil");
503 "FindViewForPointerEvent, parameter 'pointerEvent' is nil");
522#pragma mark - Downscale image ("reading color bits" on retina macs).
527 assert(
w != 0 &&
h != 0 &&
"DownscaledImageData, invalid geometry");
528 assert(
image !=
nullptr &&
"DonwscaledImageData, invalid parameter 'image'");
530 std::vector<unsigned char>
result;
533 }
catch (
const std::bad_alloc &) {
534 NSLog(
@"DownscaledImageData, memory allocation failed");
540 NSLog(
@"DownscaledImageData, CGColorSpaceCreateDeviceRGB failed");
548 NSLog(
@"DownscaledImageData, CGBitmapContextCreateWithData failed");
557#pragma mark - "Focus management" - just make another window key window.
563 if (![
NSApp isActive])
578 if (
qWindow.fContentView.fOverrideRedirect)
586#pragma mark - 'shape mask' - to create a window with arbitrary (probably non-rectangle) shape.
591 assert(view !=
nil &&
"ClipToShapeMask, parameter 'view' is nil");
592 assert(ctx != 0 &&
"ClipToShapeMask, parameter 'ctx' is null");
596 "ClipToShapeMask, fShapeCombineMask is nil on a top-level window");
598 "ClipToShapeMask, shape mask is null");
604 if (!view.fParentView) {
613 toView : [view window].contentView];
631#pragma mark - Window's geometry and attributes.
636 assert(
attr != 0 &&
"SetWindowAttributes, parameter 'attr' is null");
637 assert(window !=
nil &&
"SetWindowAttributes, parameter 'window' is nil");
642 window.fBackgroundPixel =
attr->fBackgroundPixel;
645 window.fEventMask =
attr->fEventMask;
648 window.fBitGravity =
attr->fBitGravity;
651 window.fWinGravity =
attr->fWinGravity;
660 window.fOverrideRedirect =
YES;
667 assert(
win !=
nil &&
"GetWindowGeometry, parameter 'win' is nil");
668 assert(
dst != 0 &&
"GetWindowGeometry, parameter 'dst' is null");
674 dst->fHeight =
win.fHeight;
680 assert(window !=
nil &&
"GetWindowAttributes, parameter 'window' is nil");
681 assert(
dst != 0 &&
"GetWindowAttributes, parameter 'attr' is null");
689 dst->fBorderWidth = 0;
690 dst->fDepth = window.fDepth;
695 dst->fClass = window.fClass;
696 dst->fBitGravity = window.fBitGravity;
697 dst->fWinGravity = window.fWinGravity;
700 dst->fBackingPlanes = 0;
703 dst->fBackingPixel = 0;
712 dst->fMapState = window.fMapState;
714 dst->fAllEventMasks = window.fEventMask;
715 dst->fYourEventMask = window.fEventMask;
720 dst->fOverrideRedirect = window.fOverrideRedirect;
729#pragma mark - Comparators (I need them when changing a window's z-order).
733#ifdef MAC_OS_X_VERSION_10_11
750#ifdef MAC_OS_X_VERSION_10_11
765#pragma mark - Cursor's area.
770 assert(
image !=
nil &&
"CursroHotSpot, parameter 'image' is nil");
817 if (!path || path[0] == 0) {
894#pragma mark - Workarounds for a text view and its descendants.
905 return dynamic_cast<const TGTextView*
>(window);
911 assert(view !=
nil &&
"ViewIsTextView, parameter 'view' is nil");
919 assert(view !=
nil &&
"ViewIsTextViewFrame, parameter 'view' is nil");
934 if (!view.fParentView)
955 assert(view !=
nil &&
"ViewIsHtmlView, parameter 'view' is nil");
964 assert(view !=
nil &&
"ViewIsHtmlViewFrame, parameter 'view' is nil");
979 if (!view.fParentView)
1011#pragma mark - Workarounds for 'paint out of paint events'.
1016 assert(view !=
nil &&
"LockFocus, parameter 'view' is nil");
1018 "LockFocus, QuartzView is expected");
1037 assert(view !=
nil &&
"UnlockFocus, parameter 'view' is nil");
1039 "UnlockFocus, QuartzView is expected");
1054#ifdef DEBUG_ROOT_COCOA
1056#pragma mark - 'loggers'.
1066 static std::ofstream logfile(
"win_attr.txt");
1070 logfile<<
"win "<<
winID<<
": BackPixmap\n";
1072 logfile<<
"win "<<
winID<<
": BackPixel\n";
1074 logfile<<
"win "<<
winID<<
": BorderPixmap\n";
1076 logfile<<
"win "<<
winID<<
": BorderPixel\n";
1078 logfile<<
"win "<<
winID<<
": BorderWidth\n";
1080 logfile<<
"win "<<
winID<<
": BitGravity\n";
1082 logfile<<
"win "<<
winID<<
": WinGravity\n";
1084 logfile<<
"win "<<
winID<<
": BackingStore\n";
1086 logfile<<
"win "<<
winID<<
": BackingPlanes\n";
1088 logfile<<
"win "<<
winID<<
": BackingPixel\n";
1090 logfile<<
"win "<<
winID<<
": OverrideRedirect\n";
1092 logfile<<
"win "<<
winID<<
": SaveUnder\n";
1094 logfile<<
"win "<<
winID<<
": EventMask\n";
1096 logfile<<
"win "<<
winID<<
": DontPropagate\n";
1098 logfile<<
"win "<<
winID<<
": Colormap\n";
1100 logfile<<
"win "<<
winID<<
": Cursor\n";
1107 NSLog(
@"button press mask");
1109 NSLog(
@"button release mask");
1111 NSLog(
@"exposure mask");
1113 NSLog(
@"pointer motion mask");
1115 NSLog(
@"button motion mask");
1117 NSLog(
@"enter notify mask");
1119 NSLog(
@"leave notify mask");
1127 std::vector<ROOT::MacOSX::X11::Command *>
xorOps;
1137 [
super drawRect:dirtyRect];
1171 self.ignoresMouseEvents =
YES;
1177#pragma mark - suppress the normal window behavior.
1195#pragma mark - QuartzWindow's life cycle.
1202 self = [
super initWithContentRect : contentRect styleMask : windowStyle
1203 backing : bufferingType defer : deferCreation];
1207 [
self setAllowsConcurrentViewDrawing : NO];
1217 [
self setContentView : fContentView];
1219 [fContentView release];
1238 assert(
glView !=
nil &&
"-initWithGLView, parameter 'glView' is nil");
1246 self = [
super initWithContentRect : contentRect styleMask : styleMask
1247 backing : NSBackingStoreBuffered defer : NO];
1251 [
self setAllowsConcurrentViewDrawing : NO];
1254 [
self setContentView : fContentView];
1267 [fShapeCombineMask release];
1280 [
super setContentView:cv];
1293#pragma mark - Forwaring: I want to forward a lot of property setters/getters to the content view.
1304 [
super forwardInvocation : anInvocation];
1315 signature = [fContentView methodSignatureForSelector : selector];
1330 assert(window !=
nil &&
"-addTransientWindow:, parameter 'window' is nil");
1339 [
self addChildWindow : window ordered : NSWindowAbove];
1347#pragma unused(sender)
1352#ifdef MAC_OS_X_VERSION_10_9
1353 [
self setCollectionBehavior : NSWindowCollectionBehaviorMoveToActiveSpace];
1355 [
self setCollectionBehavior : NSWindowCollectionBehaviorCanJoinAllSpaces];
1358 [
super makeKeyAndOrderFront : self];
1360 [
self setCollectionBehavior : NSWindowCollectionBehaviorDefault];
1379 [fShapeCombineMask release];
1387#pragma mark - X11Drawable's protocol.
1408 return self.screen.backingScaleFactor;
1426 return self.frame.size.width;
1444 assert(!(
newSize.width < 0) &&
"-setDrawableSize:, width is negative");
1445 assert(!(
newSize.height < 0) &&
"-setDrawableSize:, height is negative");
1449 if (frame.origin.x < -100000. || frame.origin.x > 100000.) {
1451 NSLog(
@"Attempting to set a frame with X: %g", frame.origin.x);
1452 frame.origin.x = 0.;
1459 frame.size.height +=
dY;
1460 [
self setFrame : frame display : YES];
1464- (void)
setX : (
int) x Y : (
int) y width : (
unsigned) w height : (
unsigned) h
1469 [
self setContentSize : newSize];
1476 [
self setFrameTopLeftPoint : topLeft];
1480- (void)
setX : (
int) x Y : (
int) y
1486 [
self setFrameTopLeftPoint : topLeft];
1491 clipOrigin : (
X11::Point) clipXY toPoint : (
X11::Point) dstPoint
1496 [fContentView copy : src area : area withMask : mask clipOrigin : clipXY toPoint : dstPoint];
1505 return [fContentView readColorBits : area];
1508#pragma mark - XorDrawinWindow/View
1513 auto res = [
self findXorWindow];
1519 [
self adjustXorWindowGeometry : special];
1520 [
self addChildWindow : special ordered : NSWindowAbove];
1528 assert(
win &&
"invalid (nil) parameter 'win'");
1529 auto frame =
self.contentView.frame;
1530 frame = [
self convertRectToScreen:frame];
1531 [win setFrame:frame display:NO];
1541 [
self removeChildWindow : win];
1548 auto children = [
self childWindows];
1566 [
cv addXorCommand : cmd.get()];
1568 [
cv setNeedsDisplay : YES];
1570 }
catch (
const std::exception &) {
1585 [
cv addXorCommand : cmd.get()];
1587 [
cv setNeedsDisplay : YES];
1588 }
catch (
const std::exception &) {
1598 [
self removeXorWindow];
1610#pragma mark - X11Window protocol's implementation.
1621#pragma unused(parent)
1645 CGFloat
rgba[] = {0., 0., 0., 1.};
1648 [
self setBackgroundColor : [
NSColor colorWithColorSpace : [
NSColorSpace deviceRGBColorSpace] components : rgba count : 4]];
1684 "-addChild: gl view in a top-level window as content view is not supported");
1687 [
self setContentView : child];
1690 [fContentView addChild : child];
1699 assert(
attr &&
"-getAttributes:, parameter 'attr' is nil");
1707 assert(
attr != 0 &&
"-setAttributes:, parameter 'attr' is null");
1709#ifdef DEBUG_ROOT_COCOA
1724 [fContentView setHidden : NO];
1725 [
self makeKeyAndOrderFront : self];
1726 [fContentView configureNotifyTree];
1730 [fMainWindow addChildWindow : self ordered : NSWindowAbove];
1742 [fContentView setHidden : NO];
1743 [
self makeKeyAndOrderFront : self];
1744 [fContentView configureNotifyTree];
1748 [fMainWindow addChildWindow : self ordered : NSWindowAbove];
1760 [fContentView mapSubwindows];
1761 [fContentView configureNotifyTree];
1770 [fContentView setHidden : YES];
1771 [
self orderOut : self];
1774 [fMainWindow removeChildWindow : self];
1779#pragma mark - Events.
1802 const NSPoint
viewPoint = [fContentView convertPoint : windowPoint fromView : nil];
1808 "-sendEvent:, gVirtualX is either null or not of TGCocoa type");
1822 [
super sendEvent : theEvent];
1825#pragma mark - NSWindowDelegate's methods.
1830#pragma unused(sender)
1846 "-windowShouldClose:, gVirtualX is either null or has a type different from TGCocoa");
1857#pragma unused(aNotification)
1866 "-windowDidBecomeKey:, gVirtualX is null or not of TGCocoa type");
1868 vx->GetEventTranslator()->GenerateFocusChangeEvent(
self.fContentView);
1876#pragma unused(aNotification)
1882#pragma mark - Passive key grab info.
1887- (id)
initWithKey : (unichar) keyCode modifiers : (NSUInteger) modifiers
1898- (BOOL)
matchKey : (unichar) keyCode modifiers : (NSUInteger) modifiers
1904- (BOOL)
matchKey : (unichar) keyCode
1923#pragma mark - X11 property emulation.
1940- (id)
initWithData : (
unsigned char *) data size : (
unsigned) dataSize type : (
Atom_t) type format : (
unsigned) format
1948 [
self resetPropertyData : data size : dataSize type : type format : format];
1957 [fPropertyData release];
1964 type : (
Atom_t) type format : (
unsigned) format
1966 [fPropertyData release];
1993#pragma mark - QuartzView.
2026#pragma mark - Lifetime.
2045 [
self setCanDrawConcurrently : NO];
2047 [
self setHidden : YES];
2067 [fBackBuffer release];
2068 [fPassiveKeyGrabs release];
2069 [fX11Properties release];
2070 [fBackgroundPixmap release];
2074#pragma mark - Tracking area.
2081 [
super updateTrackingAreas];
2090 for (NSUInteger i = 0; i <
size; ++i) {
2092 [
self removeTrackingArea : t];
2101 frame.size.width =
self.fWidth;
2102 frame.size.height =
self.fHeight;
2105 options : trackerOptions owner : self userInfo : nil];
2106 [
self addTrackingArea : tracker];
2113 [
self updateTrackingAreas];
2119#pragma mark - X11Drawable protocol.
2136 return self.fQuartzWindow.fScaleFactor;
2142 return self.frame.origin.x;
2148 return self.frame.origin.y;
2154 return self.frame.size.width;
2160 return self.frame.size.height;
2166 assert(!(
newSize.width < 0) &&
"-setDrawableSize, width is negative");
2167 assert(!(
newSize.height < 0) &&
"-setDrawableSize, height is negative");
2206 [
self.fQuartzWindow setDrawMode:newMode];
2212 return [
self.fQuartzWindow getDrawMode];
2222 [fBackBuffer setDirectDraw : mode];
2232- (void)
setX : (
int) x Y : (
int) y width : (
unsigned) w height : (
unsigned) h
2244- (void)
setX : (
int) x Y : (
int) y
2256 toPoint : (
X11::Point) dstPoint
2260 "-copyImage:area:withMask:clipOrigin:toPoint:, parameter 'srcImage' is nil");
2262 "-copyImage:area:withMask:clipOrigin:toPoint:, srcImage.fImage is nil");
2266 "-copyImage:area:withMask:clipOrigin:toPoint:, self.fContext is null");
2269 NSLog(
@"QuartzView: -copyImage:area:withMask:clipOrigin:toPoint:,"
2270 " srcRect and copyRect do not intersect");
2282 NSLog(
@"QuartzView: -copyImage:area:withMask:clipOrigin:toPoint:,"
2283 " subimage creation failed");
2299 "-copyImage:area:withMask:clipOrigin:toPoint:, mask.fImage is nil");
2301 "-copyImage:area:withMask:clipOrigin:toPoint:, mask.fImage is not a mask");
2326 assert(
srcView !=
nil &&
"-copyView:area:toPoint:, parameter 'srcView' is nil");
2332 NSLog(
@"QuartzView: -copyView:area:toPoint failed");
2336 assert(
srcView !=
nil &&
"-copyView:area:toPoint:, parameter 'srcView' is nil");
2337 assert(
self.fContext != 0 &&
"-copyView:area:toPoint, self.fContext is null");
2344 [
srcView cacheDisplayInRect : frame toBitmapImageRep : imageRep];
2352 NSLog(
@"QuartzView: -copyView:area:toPoint, CGImageCreateWithImageInRect failed");
2369 withMask : (
QuartzImage *) mask clipOrigin : (
X11::Point) clipXY toPoint : (
X11::Point) dstPoint
2372 assert(
srcPixmap !=
nil &&
"-copyPixmap:area:withMask:clipOrigin:toPoint:, parameter 'srcPixmap' is nil");
2375 NSLog(
@"QuartzView: -copyPixmap:area:withMask:clipOrigin:toPoint,"
2376 " no intersection between pixmap rectangle and cropArea");
2382 "-copyPixmap:area:withMask:clipOrigin:toPoint:, self.fContext is null");
2392 "-copyPixmap:area:withMask:clipOrigin:toPoint:, createImageFromPixmap failed");
2401 NSLog(
@"QuartzView: -copyImage:area:withMask:clipOrigin:toPoint:,"
2402 " subimage creation failed");
2410 "-copyPixmap:area:withMask:clipOrigin:toPoint:, mask.fImage is nil");
2412 "-copyPixmap:area:withMask:clipOrigin:toPoint:, mask.fImage is not a mask");
2433 toPoint : (
X11::Point) dstPoint
2435 assert(
srcImage !=
nil &&
"-copyImage:area:toPoint:, parameter 'srcImage' is nil");
2436 assert(
srcImage.fImage !=
nil &&
"-copyImage:area:toPoint:, srcImage.fImage is nil");
2437 assert(
self.fContext != 0 &&
"-copyImage:area:toPoint:, fContext is null");
2440 NSLog(
@"QuartzView: -copyImage:area:toPoint, image and copy area do not intersect");
2450 NSLog(
@"QuartzView: -copyImage:area:toPoint:, subimage creation failed");
2473 withMask : (
QuartzImage *)mask clipOrigin : (
X11::Point) clipXY toPoint : (
X11::Point) dstPoint
2475 assert(
src !=
nil &&
"-copy:area:withMask:clipOrigin:toPoint:, parameter 'src' is nil");
2476 assert(
area.fWidth &&
area.fHeight &&
"-copy:area:withMask:clipOrigin:toPoint:, area to copy is empty");
2482 [
self copyView : (QuartzView *)qw.fContentView area : area toPoint : dstPoint];
2485 [
self copyView : (QuartzView *)src area : area toPoint : dstPoint];
2487 [
self copyPixmap : (QuartzPixmap *)src area : area withMask : mask clipOrigin : clipXY toPoint : dstPoint];
2489 [
self copyImage : (QuartzImage *)src area : area withMask : mask clipOrigin : clipXY toPoint : dstPoint];
2491 assert(0 &&
"-copy:area:withMask:clipOrigin:toPoint:, src is of unknown type");
2502 assert(
area.fWidth &&
area.fHeight &&
"-readColorBits:, area to copy is empty");
2523 NSLog(
@"QuartzView: -readColorBits:, visible rect of view and copy area do not intersect");
2530 NSLog(
@"QuartzView: -readColorBits:, bitmapImageRepForCachingDisplayInRect failed");
2535 [
self cacheDisplayInRect : visRect toBitmapImageRep : imageRep];
2536 self.fContext = ctx;
2544 unsigned char *
srcData =
nullptr;
2555 NSLog(
@"QuartzView: -readColorBits:, failed to obtain backing store contents");
2560 unsigned char *
data =
nullptr;
2563 data =
new unsigned char[
area.fWidth * area.fHeight * 4];
2564 }
catch (
const std::bad_alloc &) {
2565 NSLog(
@"QuartzView: -readColorBits:, memory allocation failed");
2573 for (
unsigned i = 0; i <
area.fHeight; ++i) {
2592 [fBackgroundPixmap release];
2611 if ([
self isHidden])
2615 if ([parent isHidden])
2635#pragma unused(focus)
2652 [fBackBuffer release];
2686- (void)
activateGrab : (
unsigned) eventMask ownerEvents : (BOOL) ownerEvents
2723 [
super didAddSubview:subview];
2725 self.layer.masksToBounds =
YES;
2731 [
super willRemoveSubview:subview];
2733 self.layer.masksToBounds =
self.subviews.count > 1;
2741 [
self addSubview : child];
2748 assert(
attr != 0 &&
"-getAttributes:, parameter 'attr' is null");
2756 assert(
attr != 0 &&
"-setAttributes:, parameter 'attr' is null");
2758#ifdef DEBUG_ROOT_COCOA
2770 [
self removeFromSuperview];
2771 [parent addSubview : self];
2772 [
self setHidden : NO];
2778 [
self setHidden : NO];
2791 [
self setHidden : YES];
2805 [child setOverlapped : overlap];
2822 using namespace X11;
2831 [
sibling setOverlapped : YES];
2836 [
self setOverlapped : NO];
2838 [
self setHidden : NO];
2840 [fParentView sortSubviewsUsingFunction : CompareViewsToRaise context : (void *)self];
2842 [
self updateTrackingAreasAfterRaise];
2844 [
self setNeedsDisplay : YES];
2852 using namespace X11;
2864 [
sibling setNeedsDisplay : YES];
2865 [
self setOverlapped : YES];
2867 [
self setHidden : YES];
2873 [fParentView sortSubviewsUsingFunction : CompareViewsToLower context : (void*)self];
2890 "-configureNotifyTree, gVirtualX is either null or has type different from TGCocoa");
2892 vx->GetEventTranslator()->GenerateConfigureNotifyEvent(
self,
self.frame);
2896 [v configureNotifyTree];
2900#pragma mark - Key grabs.
2903- (void)
addPassiveKeyGrab : (unichar) keyCode modifiers : (NSUInteger) modifiers
2905 [
self removePassiveKeyGrab : keyCode modifiers : modifiers];
2907 modifiers : modifiers];
2908 [fPassiveKeyGrabs addObject : newGrab];
2915 const NSUInteger count = [fPassiveKeyGrabs count];
2916 for (NSUInteger i = 0; i < count; ++i) {
2919 [fPassiveKeyGrabs removeObjectAtIndex : i];
2950#pragma mark - Painting mechanics.
2955#pragma unused(dirtyRect)
2957 using namespace X11;
2972 assert(
fContext != 0 &&
"-drawRect:, graphicsPort returned null");
2977 if (
self.fQuartzWindow.fShapeCombineMask)
3010 gClient->CancelRedraw(window);
3011 vx->GetCommandBuffer()->RemoveGraphicsOperationsForWindow(
fID);
3018 [
self copy : fBackBuffer area : copyArea withMask : nil
3019 clipOrigin : X11::Point() toPoint : X11::Point()];
3023#ifdef DEBUG_ROOT_COCOA
3030#ifdef DEBUG_ROOT_COCOA
3031 NSLog(
@"QuartzView: -drawRect: method, no window for id %u was found",
fID);
3037#pragma mark - Geometry.
3048 [
super setFrame : newFrame];
3056 [
super setFrameSize : newSize];
3060 "setFrameSize:, gVirtualX is either null or has a type, different from TGCocoa");
3062 vx->GetEventTranslator()->GenerateConfigureNotifyEvent(
self,
self.frame);
3065 [
self setNeedsDisplay : YES];
3068#pragma mark - Event handling.
3073 assert(
fID != 0 &&
"-mouseDown:, fID is 0");
3076 "-mouseDown:, gVirtualX is either null or has a type, different from TGCocoa");
3084 assert(
fID != 0 &&
"-scrollWheel:, fID is 0");
3088 "-scrollWheel:, gVirtualX is either null or has a type, different from TGCocoa");
3101#ifdef DEBUG_ROOT_COCOA
3105 assert(
fID != 0 &&
"-printWindowInformation, fID is 0");
3107 assert(window != 0 &&
"printWindowInformation, window not found");
3109 NSLog(
@"-----------------View %u info:---------------------",
fID);
3111 NSLog(
@"event mask is:");
3113 NSLog(
@"grab mask is:");
3115 NSLog(
@"view's geometry: x == %g, y == %g, w == %g, h == %g",
self.frame.origin.x,
3116 self.frame.origin.y,
self.frame.size.width,
self.frame.size.height);
3117 NSLog(
@"----------------End of view info------------------");
3124 assert(
fID != 0 &&
"-rightMouseDown:, fID is 0");
3126#ifdef DEBUG_ROOT_COCOA
3127 [
self printViewInformation];
3131 "-rightMouseDown:, gVirtualX is either null or has type different from TGCocoa");
3139 assert(
fID != 0 &&
"-otherMouseDown:, fID is 0");
3147 "-otherMouseDown:, gVirtualX is either null or has type different from TGCocoa");
3156 assert(
fID != 0 &&
"-mouseUp:, fID is 0");
3159 "-mouseUp:, gVirtualX is either null or has type different from TGCocoa");
3168 assert(
fID != 0 &&
"-rightMouseUp:, fID is 0");
3171 "-rightMouseUp:, gVirtualX is either null or has type different from TGCocoa");
3180 assert(
fID != 0 &&
"-otherMouseUp:, fID is 0");
3184 "-otherMouseUp:, gVirtualX is either null or has type different from TGCocoa");
3192 assert(
fID != 0 &&
"-mouseEntered:, fID is 0");
3194 "-mouseEntered:, gVirtualX is null or not of TGCocoa type");
3197 vx->GetEventTranslator()->GenerateCrossingEvent(
theEvent);
3203 assert(
fID != 0 &&
"-mouseExited:, fID is 0");
3206 "-mouseExited:, gVirtualX is null or not of TGCocoa type");
3209 vx->GetEventTranslator()->GenerateCrossingEvent(
theEvent);
3215 assert(
fID != 0 &&
"-mouseMoved:, fID is 0");
3221 "-mouseMoved:, gVirtualX is null or not of TGCocoa type");
3224 vx->GetEventTranslator()->GeneratePointerMotionEvent(
theEvent);
3230 assert(
fID != 0 &&
"-mouseDragged:, fID is 0");
3233 assert(
vx != 0 &&
"-mouseDragged:, gVirtualX is null or not of TGCocoa type");
3235 vx->GetEventTranslator()->GeneratePointerMotionEvent(
theEvent);
3241 assert(
fID != 0 &&
"-rightMouseDragged:, fID is 0");
3244 "-rightMouseDragged:, gVirtualX is null or not of TGCocoa type");
3247 vx->GetEventTranslator()->GeneratePointerMotionEvent(
theEvent);
3253 assert(
fID != 0 &&
"-otherMouseDragged:, fID is 0");
3257 "-otherMouseDragged:, gVirtualX is null or not of TGCocoa type");
3259 vx->GetEventTranslator()->GeneratePointerMotionEvent(
theEvent);
3266 assert(
fID != 0 &&
"-keyDown:, fID is 0");
3269 "-keyDown:, gVirtualX is null or not of TGCocoa type");
3282 assert(
fID != 0 &&
"-keyUp:, fID is 0");
3285 "-keyUp:, gVirtualX is null or not of TGCocoa type");
3295#pragma mark - First responder stuff.
3300#pragma unused(theEvent)
3310#pragma mark - Cursors.
3317 [
self.fQuartzWindow invalidateCursorRectsForView : self];
3357 if (!path || path[0] == 0) {
3370 hotSpot : hotSpot] autorelease];
3384 [
self addCursorRect : self.visibleRect cursor : cursor];
3400#pragma unused(event)
3412 [
self performSelector : @selector(cursorUpdate) withObject : nil afterDelay : 0.05f];
3415#pragma mark - Emulated X11 properties.
3418- (void)
setProperty : (
const char *) propName data : (
unsigned char *) propData
3419 size : (
unsigned) dataSize forType : (
Atom_t) dataType format : (
unsigned) format
3421 assert(
propName != 0 &&
"-setProperty:data:size:forType:, parameter 'propName' is null");
3422 assert(
propData != 0 &&
"-setProperty:data:size:forType:, parameter 'propData' is null");
3423 assert(
dataSize != 0 &&
"-setProperty:data:size:forType:, parameter 'dataSize' is 0");
3425 NSString *
const key = [
NSString stringWithCString : propName encoding : NSASCIIStringEncoding];
3430 [property resetPropertyData : propData size : dataSize type : dataType format : format];
3434 type : dataType format : format];
3435 [fX11Properties setObject : property forKey : key];
3443 assert(
propName != 0 &&
"-hasProperty:, propName parameter is null");
3445 NSString *
const key = [
NSString stringWithCString : propName encoding : NSASCIIStringEncoding];
3448 return property !=
nil;
3453 returnFormat : (
unsigned *) format nElements : (
unsigned *) nElements
3456 "-getProperty:returnType:returnFormat:nElements:, parameter 'propName' is null");
3458 "-getProperty:returnType:returnFormat:nElements:, parameter 'type' is null");
3460 "-getProperty:returnType:returnFormat:nElements:, parameter 'format' is null");
3462 "-getProperty:returnType:returnFormat:nElements:, parameter 'nElements' is null");
3464 NSString *
const key = [
NSString stringWithCString : propName encoding : NSASCIIStringEncoding];
3467 "-getProperty:returnType:returnFormat:nElements, property not found");
3472 unsigned char *
buff = 0;
3475 }
catch (
const std::bad_alloc &) {
3477 NSLog(
@"QuartzWindow: -getProperty:returnType:returnFormat:nElements:,"
3478 " memory allocation failed");
3482 [
propData getBytes : buff length : dataSize];
3483 *
format =
property.fFormat;
3492 *
type =
property.fType;
3500 assert(
propName != 0 &&
"-removeProperty:, parameter 'propName' is null");
3503 encoding : NSASCIIStringEncoding];
3504 [fX11Properties removeObjectForKey : key];
3546 const NSUInteger
len = [
item lengthOfBytesUsingEncoding : NSASCIIStringEncoding] + 1;
3549 [
item getCString : (char *)&propertyData[0] maxLength : propertyData.size()
3550 encoding : NSASCIIStringEncoding];
3553 [
targetView setProperty : "_XC_DND_DATA" data : &propertyData[0]
3554 size : propertyData.size() forType : textUriAtom format : 8];
3555 }
catch (
const std::bad_alloc &) {
3557 NSLog(
@"QuartzView: -performDragOperation:, memory allocation failed");
3587 dropPoint = [
self convertPoint : dropPoint fromView : nil];
const Mask_t kWABorderPixel
const Mask_t kWAOverrideRedirect
const Mask_t kWABitGravity
const Mask_t kWADontPropagate
const Mask_t kButtonMotionMask
const Mask_t kWABackingStore
const Mask_t kButtonPressMask
const Mask_t kExposureMask
const Mask_t kWAEventMask
Handle_t Window_t
Window handle.
const Mask_t kWASaveUnder
const Mask_t kWABackPixel
const Mask_t kWAWinGravity
const Mask_t kWABackingPixel
const Mask_t kPointerMotionMask
const Mask_t kLeaveWindowMask
const Mask_t kStructureNotifyMask
const Mask_t kButtonReleaseMask
const Mask_t kWABorderPixmap
const Mask_t kEnterWindowMask
const Mask_t kWABackPixmap
const Mask_t kWABorderWidth
const Mask_t kWABackingPlanes
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
unsigned short UShort_t
Unsigned Short integer 2 bytes (unsigned short)
int Int_t
Signed integer 4 bytes (int)
unsigned long ULong_t
Unsigned long integer 4 bytes (unsigned long). Size depends on architecture.
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int)
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t mask
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t cursor
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t TranslateCoordinates
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t GetWindowAttributes
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t rect
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t result
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize id
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t child
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t UChar_t len
Option_t Option_t TPoint TPoint const char x2
Option_t Option_t TPoint TPoint const char x1
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t win
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t attr
Option_t Option_t TPoint TPoint const char mode
Option_t Option_t TPoint TPoint const char y2
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t format
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name CreateCursor
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t grab
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t src
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t property
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t height
Option_t Option_t TPoint TPoint const char y1
R__EXTERN TSystem * gSystem
Fill Area Attributes class.
This class implements TVirtualX interface for MacOS X, using Cocoa and Quartz 2D.
static Atom_t fgDeleteWindowAtom
A TGTextView is a text viewer widget.
ROOT GUI Window base class.
TClass * IsA() const override
const char * GetName() const override
Returns name of object.
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
static const TString & GetIconPath()
Get the icon path in the installation. Static utility function.
virtual char * Which(const char *search, const char *file, EAccessMode mode=kFileExists)
Find location of file in a search path.
Semi-Abstract base class defining a generic interface to the underlying, low level,...
QuartzPixmap * fBackBuffer
unsigned fPassiveGrabKeyModifiers
void activateImplicitGrab()
NSMutableArray * fPassiveKeyGrabs
TAttFill fAttFill
current fill attributes
BOOL fActiveGrabOwnerEvents
TAttText fAttText
current text attribute
QuartzWindow * fQuartzWindow
void configureNotifyTree()
void activatePassiveGrab()
NSMutableDictionary * fX11Properties
BOOL fPassiveGrabOwnerEvents
TAttMarker fAttMarker
current marker attribute
unsigned fPassiveGrabEventMask
QuartzImage * fBackgroundPixmap
ROOT::MacOSX::X11::PointerGrab fCurrentGrabType
unsigned long fBackgroundPixel
unsigned fActiveGrabEventMask
NSView< X11Window > * fContentView
TAttLine fAttLine
current line attributes
unsigned long fBackgroundPixel
QuartzWindow * fQuartzWindow
XorDrawingWindow * findXorWindow()
XorDrawingWindow * addXorWindow()
QuartzWindow * fMainWindow
TVirtualX::EDrawMode fDrawMode
QuartzView * fContentView
QuartzImage * fShapeCombineMask
const NSUInteger kMiniaturizableWindowMask
const NSEventType kLeftMouseDown
const NSEventType kRightMouseDown
const NSUInteger kTitledWindowMask
const NSUInteger kResizableWindowMask
const NSUInteger kClosableWindowMask
const NSUInteger kBorderlessWindowMask
NSCursor * CreateCustomCursor(ECursor currentCursor)
int GlobalYROOTToCocoa(CGFloat yROOT)
NSPoint ConvertPointFromScreenToBase(NSPoint screenPoint, NSWindow *window)
bool ViewIsHtmlViewFrame(NSView< X11Window > *view, bool checkParent)
int GlobalYCocoaToROOT(CGFloat yCocoa)
void PixelToRGB(Pixel_t pixelColor, CGFloat *rgb)
NSPoint ConvertPointFromBaseToScreen(NSWindow *window, NSPoint windowPoint)
NSPoint TranslateToScreen(NSView< X11Window > *from, NSPoint point)
CGImageRef CreateSubImage(QuartzImage *image, const Rectangle &area)
bool ScreenPointIsInView(NSView< X11Window > *view, Int_t x, Int_t y)
NSPoint GetCursorHotStop(NSImage *image, ECursor cursor)
void GetWindowGeometry(NSObject< X11Window > *win, WindowAttributes_t *dst)
void GetWindowAttributes(NSObject< X11Window > *window, WindowAttributes_t *dst)
NSView< X11Window > * FindDNDAwareViewInPoint(NSView *parentView, Window_t dragWinID, Window_t inputWinID, Int_t x, Int_t y, Int_t maxDepth)
NSView< X11Window > * FrameForHtmlView(NSView< X11Window > *htmlView)
QuartzWindow * FindWindowInPoint(Int_t x, Int_t y)
int GlobalXCocoaToROOT(CGFloat xCocoa)
void WindowLostFocus(Window_t winID)
int LocalYROOTToCocoa(NSView< X11Window > *parentView, CGFloat yROOT)
NSView< X11Window > * FindViewForPointerEvent(NSEvent *pointerEvent)
NSView< X11Window > * FrameForTextView(NSView< X11Window > *textView)
NSComparisonResult CompareViewsToLower(id view1, id view2, void *context)
int LocalYCocoaToROOT(NSView< X11Window > *parentView, CGFloat yCocoa)
QuartzWindow * CreateTopLevelWindow(Int_t x, Int_t y, UInt_t w, UInt_t h, UInt_t border, Int_t depth, UInt_t clss, void *visual, SetWindowAttributes_t *attr, UInt_t)
NSView< X11Window > * FindViewUnderPointer()
void UnlockFocus(NSView< X11Window > *view)
int GlobalXROOTToCocoa(CGFloat xROOT)
QuartzView * CreateChildView(QuartzView *parent, Int_t x, Int_t y, UInt_t w, UInt_t h, UInt_t border, Int_t depth, UInt_t clss, void *visual, SetWindowAttributes_t *attr, UInt_t wtype)
bool AdjustCropArea(const Rectangle &srcRect, Rectangle &cropArea)
QuartzWindow * FindWindowForPointerEvent(NSEvent *pointerEvent)
bool ViewIsTextView(unsigned viewID)
void GetRootWindowAttributes(WindowAttributes_t *attr)
bool ViewIsHtmlView(unsigned viewID)
QuartzWindow * FindWindowUnderPointer()
bool ViewIsTextViewFrame(NSView< X11Window > *view, bool checkParent)
NSPoint TranslateFromScreen(NSPoint point, NSView< X11Window > *to)
void ClipToShapeMask(NSView< X11Window > *view, CGContextRef ctx)
void SetWindowAttributes(const SetWindowAttributes_t *attr, NSObject< X11Window > *window)
NSCursor * CreateCursor(ECursor currentCursor)
bool LockFocus(NSView< X11Window > *view)
NSComparisonResult CompareViewsToRaise(id view1, id view2, void *context)
std::vector< unsigned char > DownscaledImageData(unsigned w, unsigned h, CGImageRef image)
Attributes that can be used when creating or changing a window.
Window attributes that can be inquired.