21 #include <ApplicationServices/ApplicationServices.h> 22 #include <OpenGL/OpenGL.h> 23 #include <Cocoa/Cocoa.h> 24 #include <OpenGL/gl.h> 81 #pragma mark - Display configuration management. 84 void DisplayReconfigurationCallback(CGDirectDisplayID , CGDisplayChangeSummaryFlags flags,
void * )
86 if (flags & kCGDisplayBeginConfigurationFlag)
89 if (flags & kCGDisplayDesktopShapeChangedFlag) {
90 assert(dynamic_cast<TGCocoa *>(
gVirtualX) != 0 &&
"DisplayReconfigurationCallback, gVirtualX" 91 " is either null or has a wrong type");
97 #pragma mark - Aux. functions called from GUI-rendering part. 100 void SetStrokeForegroundColorFromX11Context(CGContextRef ctx,
const GCValues_t &gcVals)
102 assert(ctx != 0 &&
"SetStrokeForegroundColorFromX11Context, parameter 'ctx' is null");
108 ::Warning(
"SetStrokeForegroundColorFromX11Context",
109 "x11 context does not have line color information");
111 CGContextSetRGBStrokeColor(ctx, rgb[0], rgb[1], rgb[2], 1.);
115 void SetStrokeDashFromX11Context(CGContextRef ctx,
const GCValues_t &gcVals)
118 assert(ctx != 0 &&
"SetStrokeDashFromX11Context, ctx parameter is null");
120 SetStrokeForegroundColorFromX11Context(ctx, gcVals);
122 static const std::size_t maxLength =
sizeof gcVals.
fDashes /
sizeof gcVals.
fDashes[0];
123 assert(maxLength >= std::size_t(gcVals.
fDashLen) &&
124 "SetStrokeDashFromX11Context, x11 context has bad dash length > sizeof(fDashes)");
126 CGFloat dashes[maxLength] = {};
134 void SetStrokeDoubleDashFromX11Context(CGContextRef ,
const GCValues_t & )
137 ::Warning(
"SetStrokeDoubleDashFromX11Context",
"Not implemented yet, kick tpochep!");
141 void SetStrokeParametersFromX11Context(CGContextRef ctx,
const GCValues_t &gcVals)
145 assert(ctx != 0 &&
"SetStrokeParametersFromX11Context, parameter 'ctx' is null");
149 CGContextSetLineWidth(ctx, gcVals.
fLineWidth);
151 CGContextSetLineWidth(ctx, 1.);
153 CGContextSetLineDash(ctx, 0., 0, 0);
157 SetStrokeForegroundColorFromX11Context(ctx, gcVals);
159 SetStrokeDashFromX11Context(ctx, gcVals);
161 SetStrokeDoubleDashFromX11Context(ctx ,gcVals);
163 ::Warning(
"SetStrokeParametersFromX11Context",
"line style bit is set," 164 " but line style is unknown");
165 SetStrokeForegroundColorFromX11Context(ctx, gcVals);
168 SetStrokeForegroundColorFromX11Context(ctx, gcVals);
172 void SetFilledAreaColorFromX11Context(CGContextRef ctx,
const GCValues_t &gcVals)
176 assert(ctx != 0 &&
"SetFilledAreaColorFromX11Context, parameter 'ctx' is null");
182 ::Warning(
"SetFilledAreaColorFromX11Context",
"no fill color found in x11 context");
184 CGContextSetRGBFillColor(ctx, rgb[0], rgb[1], rgb[2], 1.);
187 struct PatternContext {
192 NSObject<X11Drawable> *fImage;
198 bool HasFillTiledStyle(
Mask_t mask,
Int_t fillStyle)
204 bool HasFillTiledStyle(
const GCValues_t &gcVals)
210 bool HasFillStippledStyle(
Mask_t mask,
Int_t fillStyle)
216 bool HasFillStippledStyle(
const GCValues_t &gcVals)
222 bool HasFillOpaqueStippledStyle(
Mask_t mask,
Int_t fillStyle)
228 bool HasFillOpaqueStippledStyle(
const GCValues_t &gcVals)
234 void DrawTile(NSObject<X11Drawable> *patternImage, CGContextRef ctx)
236 assert(patternImage != nil &&
"DrawTile, parameter 'patternImage' is nil");
237 assert(ctx != 0 &&
"DrawTile, ctx parameter is null");
239 const CGRect patternRect = CGRectMake(0, 0, patternImage.fWidth, patternImage.fHeight);
240 if ([patternImage isKindOfClass : [
QuartzImage class]]) {
241 CGContextDrawImage(ctx, patternRect, ((QuartzImage *)patternImage).fImage);
242 }
else if ([patternImage isKindOfClass : [
QuartzPixmap class]]){
243 const Util::CFScopeGuard<CGImageRef> imageFromPixmap([((QuartzPixmap *)patternImage) createImageFromPixmap]);
244 assert(imageFromPixmap.Get() != 0 &&
"DrawTile, createImageFromPixmap failed");
245 CGContextDrawImage(ctx, patternRect, imageFromPixmap.Get());
247 assert(0 &&
"DrawTile, pattern is neither a QuartzImage, nor a QuartzPixmap");
257 assert(info != 0 &&
"DrawPattern, parameter 'info' is null");
258 assert(ctx != 0 &&
"DrawPattern, parameter 'ctx' is null");
260 const PatternContext *
const patternContext = (PatternContext *)info;
261 const Mask_t mask = patternContext->fMask;
262 const Int_t fillStyle = patternContext->fFillStyle;
264 NSObject<X11Drawable> *
const patternImage = patternContext->fImage;
265 assert(patternImage != nil &&
"DrawPattern, pattern (stipple) image is nil");
266 const CGRect patternRect = CGRectMake(0, 0, patternImage.fWidth, patternImage.fHeight);
268 if (HasFillTiledStyle(mask, fillStyle)) {
269 DrawTile(patternImage, ctx);
270 }
else if (HasFillStippledStyle(mask, fillStyle) || HasFillOpaqueStippledStyle(mask, fillStyle)) {
271 assert([patternImage isKindOfClass : [QuartzImage
class]] &&
272 "DrawPattern, stipple must be a QuartzImage object");
273 QuartzImage *
const image = (QuartzImage *)patternImage;
274 assert(image.
fIsStippleMask == YES &&
"DrawPattern, image is not a stipple mask");
278 if (HasFillOpaqueStippledStyle(mask,fillStyle)) {
281 "DrawPattern, fill style is FillOpaqueStippled, but background color is not set in a context");
283 CGContextSetRGBFillColor(ctx, rgb[0], rgb[1], rgb[2], 1.);
284 CGContextFillRect(ctx, patternRect);
288 assert((mask &
kGCForeground) &&
"DrawPattern, foreground color is not set");
290 CGContextSetRGBFillColor(ctx, rgb[0], rgb[1], rgb[2], 1.);
291 CGContextClipToMask(ctx, patternRect, image.
fImage);
292 CGContextFillRect(ctx, patternRect);
295 DrawTile(patternImage, ctx);
300 void SetFillPattern(CGContextRef ctx,
const PatternContext *patternContext)
306 assert(ctx != 0 &&
"SetFillPattern, parameter 'ctx' is null");
307 assert(patternContext != 0 &&
"SetFillPattern, parameter 'patternContext' is null");
308 assert(patternContext->fImage != nil &&
"SetFillPattern, pattern image is nil");
310 const Util::CFScopeGuard<CGColorSpaceRef> patternColorSpace(CGColorSpaceCreatePattern(0));
311 CGContextSetFillColorSpace(ctx, patternColorSpace.Get());
313 CGPatternCallbacks callbacks = {};
315 const CGRect patternRect = CGRectMake(0, 0, patternContext->fImage.fWidth, patternContext->fImage.fHeight);
316 const Util::CFScopeGuard<CGPatternRef>
pattern(CGPatternCreate((
void *)patternContext, patternRect, CGAffineTransformIdentity,
317 patternContext->fImage.fWidth, patternContext->fImage.fHeight,
318 kCGPatternTilingNoDistortion,
true, &callbacks));
319 const CGFloat alpha = 1.;
320 CGContextSetFillPattern(ctx,
pattern.Get(), &alpha);
321 CGContextSetPatternPhase(ctx, patternContext->fPhase);
325 bool ParentRendersToChild(NSView<X11Window> *child)
327 assert(child != nil &&
"ParentRendersToChild, parameter 'child' is nil");
331 child.fMapState ==
kIsViewable && child.fParentView.fContext &&
332 !child.fIsOverlapped;
336 bool IsNonPrintableAsciiCharacter(UniChar
c)
338 if (c == 9 || (c >= 32 && c < 127))
345 void FixAscii(std::vector<UniChar> &
text)
362 std::replace(text.begin(), text.end(), UniChar(16), UniChar(
' '));
365 text.erase(std::remove_if(text.begin(), text.end(), IsNonPrintableAsciiCharacter), text.end());
376 : fSelectedDrawable(0),
380 fForegroundProcess(false),
382 fDisplayShapeChanged(true)
384 assert(dynamic_cast<TMacOSXSystem *>(
gSystem) !=
nullptr &&
385 "TGCocoa, gSystem is eihter null or has a wrong type");
396 CGDisplayRegisterReconfigurationCallback (DisplayReconfigurationCallback, 0);
410 assert(dynamic_cast<TMacOSXSystem *>(
gSystem) !=
nullptr &&
411 "TGCocoa, gSystem is eihter null or has a wrong type");
422 CGDisplayRegisterReconfigurationCallback (DisplayReconfigurationCallback, 0);
429 CGDisplayRemoveReconfigurationCallback (DisplayReconfigurationCallback, 0);
498 return CGDisplayScreenSize(CGMainDisplayID()).width;
509 NSArray *
const screens = [NSScreen screens];
510 assert(screens != nil &&
"screens array is nil");
512 NSScreen *
const mainScreen = [screens objectAtIndex : 0];
513 assert(mainScreen != nil &&
"screen with index 0 is nil");
515 return NSBitsPerPixelFromDepth([mainScreen depth]);
524 assert(
gClient != 0 &&
"Update, gClient is null");
526 }
else if (mode > 0) {
545 NSArray *
const screens = [NSScreen screens];
546 assert(screens != nil && screens.count != 0 &&
"GetDisplayGeometry, no screens found");
548 NSRect frame = [(NSScreen *)[screens objectAtIndex : 0] frame];
549 CGFloat xMin = frame.origin.x, xMax = xMin + frame.size.width;
550 CGFloat yMin = frame.origin.y, yMax = yMin + frame.size.height;
552 for (NSUInteger i = 1,
e = screens.count; i <
e; ++i) {
553 frame = [(NSScreen *)[screens objectAtIndex : i] frame];
554 xMin = std::min(xMin, frame.origin.x);
555 xMax = std::max(xMax, frame.origin.x + frame.size.width);
556 yMin = std::min(yMin, frame.origin.y);
557 yMax = std::max(yMax, frame.origin.y + frame.size.height);
571 #pragma mark - Window management part. 577 return fPimpl->GetRootWindowID();
593 assert(parentID != 0 &&
"InitWindow, parameter 'parentID' is 0");
597 if (
fPimpl->IsRootWindow(parentID))
600 [
fPimpl->GetWindow(parentID) getAttributes : &attr];
602 return CreateWindow(parentID, 0, 0, attr.
fWidth, attr.
fHeight, 0, attr.
fDepth, attr.
fClass, 0, 0, 0);
626 "ClearWindow, fSelectedDrawable is invalid");
629 if (drawable.fIsPixmap) {
634 CGContextRef pixmapCtx = drawable.fContext;
635 assert(pixmapCtx != 0 &&
"ClearWindow, pixmap's context is null");
640 CGContextClearRect(pixmapCtx, CGRectMake(0, 0, drawable.fWidth, drawable.fHeight));
657 if (windowID < 0 || fPimpl->IsRootWindow(windowID)) {
667 NSObject<X11Drawable> *
const drawable =
fPimpl->GetDrawable(windowID);
671 h = drawable.fHeight;
673 if (!drawable.fIsPixmap) {
674 NSObject<X11Window> *
const window = (NSObject<X11Window> *)drawable;
675 NSPoint srcPoint = {};
678 NSView<X11Window> *
const view = window.fContentView.fParentView ? window.fContentView.fParentView : window.fContentView;
695 assert(!
fPimpl->IsRootWindow(windowID) &&
"MoveWindow, called for root window");
700 [
fPimpl->GetWindow(windowID) setX : x
Y :
y];
720 assert(!
fPimpl->IsRootWindow(windowID) &&
721 "ResizeWindow, parameter 'windowID' is a root window's id");
723 const Util::AutoreleasePool pool;
725 NSObject<X11Window> *
const window =
fPimpl->GetWindow(windowID);
726 if (window.fBackBuffer) {
746 "UpdateWindow, fSelectedDrawable is not a valid window id");
754 if (QuartzPixmap *
const pixmap = window.fBackBuffer) {
755 assert([window.fContentView isKindOfClass : [
QuartzView class]] &&
"UpdateWindow, content view is not a QuartzView");
763 const X11::Rectangle copyArea(0, 0, pixmap.fWidth, pixmap.fHeight);
764 [dstView copy : pixmap area : copyArea withMask : nil clipOrigin :
X11::Point() toPoint :
X11::Point()];
767 fPimpl->fX11CommandBuffer.AddUpdateWindow(dstView);
811 const Util::AutoreleasePool pool;
813 if (
fPimpl->IsRootWindow(parentID)) {
816 depth, clss, visual, attr, wtype);
819 const Util::NSScopeGuard<QuartzWindow> winGuard(newWindow);
822 [newWindow setAcceptsMouseMovedEvents : YES];
826 NSObject<X11Window> *
const parentWin =
fPimpl->GetWindow(parentID);
828 assert([parentWin.fContentView isKindOfClass : [
QuartzView class]] &&
829 "CreateWindow, parent view must be QuartzView");
833 x, y, w, h, border, depth, clss, visual, attr, wtype);
834 const Util::NSScopeGuard<QuartzView> viewGuard(childView);
837 [parentWin addChild : childView];
864 if (
fPimpl->IsRootWindow(wid))
867 BOOL needFocusChange = NO;
870 const Util::AutoreleasePool pool;
872 fPimpl->fX11EventTranslator.CheckUnmappedView(wid);
874 assert(
fPimpl->GetDrawable(wid).fIsPixmap == NO &&
875 "DestroyWindow, can not be called for QuartzPixmap or QuartzImage object");
877 NSObject<X11Window> *
const window =
fPimpl->GetWindow(wid);
878 if (
fPimpl->fX11CommandBuffer.BufferSize())
879 fPimpl->fX11CommandBuffer.RemoveOperationsForDrawable(wid);
882 if ((needFocusChange = window == window.fQuartzWindow && window.fQuartzWindow.fHasFocus))
883 window.fHasFocus = NO;
887 fPimpl->fX11EventTranslator.GenerateDestroyNotify(wid);
893 fPimpl->DeleteDrawable(wid);
913 if (
fPimpl->IsRootWindow(wid))
916 const Util::AutoreleasePool pool;
918 assert(
fPimpl->GetDrawable(wid).fIsPixmap == NO &&
919 "DestroySubwindows, can not be called for QuartzPixmap or QuartzImage object");
921 NSObject<X11Window> *window =
fPimpl->GetWindow(wid);
926 const Util::NSScopeGuard<NSArray> children([[window.fContentView subviews] copy]);
928 for (NSView<X11Window> *child in children.Get())
940 if (
fPimpl->IsRootWindow(wid))
943 [
fPimpl->GetWindow(wid) getAttributes : &attr];
954 const Util::AutoreleasePool pool;
956 assert(!
fPimpl->IsRootWindow(wid) &&
"ChangeWindowAttributes, called for root window");
957 assert(attr != 0 &&
"ChangeWindowAttributes, parameter 'attr' is null");
959 [
fPimpl->GetWindow(wid) setAttributes : attr];
974 if (windowID <= fPimpl->GetRootWindowID())
977 NSObject<X11Window> *
const window =
fPimpl->GetWindow(windowID);
979 window.fEventMask = eventMask;
988 assert(!
fPimpl->IsRootWindow(wid) &&
"ReparentChild, can not re-parent root window");
990 const Util::AutoreleasePool pool;
992 NSView<X11Window> *
const view =
fPimpl->GetWindow(wid).fContentView;
993 if (
fPimpl->IsRootWindow(pid)) {
996 [view removeFromSuperview];
997 view.fParentView = nil;
999 NSRect frame = view.frame;
1000 frame.origin = NSPoint();
1003 if (!view.fOverrideRedirect)
1007 styleMask : styleMask
1008 backing : NSBackingStoreBuffered
1010 [view setX : x
Y :
y];
1011 [newTopLevel addChild : view];
1013 fPimpl->ReplaceDrawable(wid, newTopLevel);
1016 [newTopLevel release];
1019 [view removeFromSuperview];
1021 NSObject<X11Window> *
const newParent =
fPimpl->GetWindow(pid);
1022 assert(newParent.fIsPixmap == NO &&
"ReparentChild, pixmap can not be a new parent");
1023 [view setX : x
Y :
y];
1024 [newParent addChild : view];
1035 if (
fPimpl->IsRootWindow(pid))
1038 const Util::AutoreleasePool pool;
1040 NSView<X11Window> *
const contentView =
fPimpl->GetWindow(wid).fContentView;
1042 [contentView retain];
1043 [contentView removeFromSuperview];
1044 [topLevel setContentView : nil];
1045 fPimpl->ReplaceDrawable(wid, contentView);
1046 [contentView setX : x
Y :
y];
1047 [
fPimpl->GetWindow(pid) addChild : contentView];
1048 [contentView release];
1059 assert(!
fPimpl->IsRootWindow(wid) &&
"ReparentWindow, can not re-parent root window");
1061 NSView<X11Window> *
const view =
fPimpl->GetWindow(wid).fContentView;
1062 if (view.fParentView)
1075 assert(!
fPimpl->IsRootWindow(wid) &&
"MapWindow, called for root window");
1077 const Util::AutoreleasePool pool;
1080 [
fPimpl->GetWindow(wid) mapWindow];
1095 assert(!
fPimpl->IsRootWindow(wid) &&
"MapSubwindows, called for 'root' window");
1097 const Util::AutoreleasePool pool;
1100 [
fPimpl->GetWindow(wid) mapSubwindows];
1110 assert(!
fPimpl->IsRootWindow(wid) &&
"MapRaised, called for root window");
1112 const Util::AutoreleasePool pool;
1115 [
fPimpl->GetWindow(wid) mapRaised];
1131 assert(!
fPimpl->IsRootWindow(wid) &&
"UnmapWindow, called for root window");
1133 const Util::AutoreleasePool pool;
1136 fPimpl->fX11EventTranslator.CheckUnmappedView(wid);
1138 NSObject<X11Window> *
const win =
fPimpl->GetWindow(wid);
1141 if (win == win.fQuartzWindow && win.fQuartzWindow.fHasFocus)
1163 assert(!
fPimpl->IsRootWindow(wid) &&
"RaiseWindow, called for root window");
1165 if (!
fPimpl->GetWindow(wid).fParentView)
1168 [
fPimpl->GetWindow(wid) raiseWindow];
1180 assert(!
fPimpl->IsRootWindow(wid) &&
"LowerWindow, called for root window");
1182 if (!
fPimpl->GetWindow(wid).fParentView)
1185 [
fPimpl->GetWindow(wid) lowerWindow];
1201 assert(!
fPimpl->IsRootWindow(wid) &&
"MoveWindow, called for root window");
1202 const Util::AutoreleasePool pool;
1203 [
fPimpl->GetWindow(wid) setX : x
Y :
y];
1220 assert(!
fPimpl->IsRootWindow(wid) &&
"MoveResizeWindow, called for 'root' window");
1222 const Util::AutoreleasePool pool;
1223 [
fPimpl->GetWindow(wid) setX : x
Y : y width : w height :
h];
1232 assert(!
fPimpl->IsRootWindow(wid) &&
"ResizeWindow, called for 'root' window");
1234 const Util::AutoreleasePool pool;
1237 const UInt_t siMax = std::numeric_limits<Int_t>::max();
1238 if (w > siMax || h > siMax)
1241 NSSize newSize = {};
1245 [
fPimpl->GetWindow(wid) setDrawableSize : newSize];
1255 assert(!
fPimpl->IsRootWindow(wid) &&
"IconifyWindow, can not iconify the root window");
1256 assert(
fPimpl->GetWindow(wid).fIsPixmap == NO &&
"IconifyWindow, invalid window id");
1258 NSObject<X11Window> *
const win =
fPimpl->GetWindow(wid);
1259 assert(win.fQuartzWindow == win &&
"IconifyWindow, can be called only for a top level window");
1261 fPimpl->fX11EventTranslator.CheckUnmappedView(wid);
1263 NSObject<X11Window> *
const window =
fPimpl->GetWindow(wid);
1264 if (
fPimpl->fX11CommandBuffer.BufferSize())
1265 fPimpl->fX11CommandBuffer.RemoveOperationsForDrawable(wid);
1267 if (window.fQuartzWindow.fHasFocus) {
1269 window.fQuartzWindow.fHasFocus = NO;
1272 [win.fQuartzWindow miniaturize : win.fQuartzWindow];
1287 if (!srcWin || !dstWin)
1290 const bool srcIsRoot =
fPimpl->IsRootWindow(srcWin);
1291 const bool dstIsRoot =
fPimpl->IsRootWindow(dstWin);
1293 if (srcIsRoot && dstIsRoot) {
1305 NSPoint srcPoint = {};
1309 NSPoint dstPoint = {};
1313 NSView<X11Window> *
const srcView =
fPimpl->GetWindow(srcWin).fContentView;
1315 }
else if (srcIsRoot) {
1316 NSView<X11Window> *
const dstView =
fPimpl->GetWindow(dstWin).fContentView;
1319 if ([dstView superview]) {
1323 dstPoint = [[dstView superview] convertPoint : dstPoint fromView : dstView];
1324 if (NSView<X11Window> *
const view = (NSView<X11Window> *)[dstView hitTest : dstPoint]) {
1325 if (view != dstView && view.fMapState ==
kIsViewable)
1330 NSView<X11Window> *
const srcView =
fPimpl->GetWindow(srcWin).fContentView;
1331 NSView<X11Window> *
const dstView =
fPimpl->GetWindow(dstWin).fContentView;
1334 if ([dstView superview]) {
1338 const NSPoint
pt = [[dstView superview] convertPoint : dstPoint fromView : dstView];
1339 if (NSView<X11Window> *
const view = (NSView<X11Window> *)[dstView hitTest : pt]) {
1340 if (view != dstView && view.fMapState ==
kIsViewable)
1363 if (
fPimpl->IsRootWindow(wid)) {
1371 NSObject<X11Drawable> *window =
fPimpl->GetDrawable(wid);
1373 if (!window.fIsPixmap) {
1393 assert(!
fPimpl->IsRootWindow(wid) &&
"SetWindowBackground, can not set color for root window");
1395 fPimpl->GetWindow(wid).fBackgroundPixel = color;
1408 assert(!
fPimpl->IsRootWindow(windowID) &&
1409 "SetWindowBackgroundPixmap, can not set background for a root window");
1410 assert(
fPimpl->GetDrawable(windowID).fIsPixmap == NO &&
1411 "SetWindowBackgroundPixmap, invalid window id");
1413 NSObject<X11Window> *
const window =
fPimpl->GetWindow(windowID);
1414 if (pixmapID ==
kNone) {
1415 window.fBackgroundPixmap = nil;
1419 assert(pixmapID >
fPimpl->GetRootWindowID() &&
1420 "SetWindowBackgroundPixmap, parameter 'pixmapID' is not a valid pixmap id");
1421 assert(
fPimpl->GetDrawable(pixmapID).fIsPixmap == YES &&
1422 "SetWindowBackgroundPixmap, bad drawable");
1424 NSObject<X11Drawable> *
const pixmapOrImage =
fPimpl->GetDrawable(pixmapID);
1427 Util::NSScopeGuard<QuartzImage> backgroundImage;
1429 if ([pixmapOrImage isKindOfClass : [QuartzPixmap
class]]) {
1430 backgroundImage.Reset([[QuartzImage alloc] initFromPixmap : (QuartzPixmap *)pixmapOrImage]);
1431 if (backgroundImage.Get())
1432 window.fBackgroundPixmap = backgroundImage.Get();
1434 backgroundImage.Reset([[QuartzImage alloc] initFromImage : (QuartzImage *)pixmapOrImage]);
1435 if (backgroundImage.Get())
1436 window.fBackgroundPixmap = backgroundImage.Get();
1439 if (!backgroundImage.Get())
1441 Error(
"SetWindowBackgroundPixmap",
"QuartzImage initialization failed");
1450 if (windowID <= fPimpl->GetRootWindowID())
1453 NSView<X11Window> *view =
fPimpl->GetWindow(windowID).fContentView;
1454 return view.fParentView ? view.fParentView.fID :
fPimpl->GetRootWindowID();
1463 const Util::AutoreleasePool pool;
1465 NSObject<X11Drawable> *
const drawable =
fPimpl->GetDrawable(wid);
1467 if ([(NSObject *)drawable isKindOfClass : [NSWindow
class]]) {
1468 NSString *
const windowTitle = [NSString stringWithCString : name encoding : NSASCIIStringEncoding];
1469 [(NSWindow *)drawable setTitle : windowTitle];
1499 assert(!
fPimpl->IsRootWindow(windowID) &&
1500 "ShapeCombineMask, windowID parameter is a 'root' window");
1501 assert(
fPimpl->GetDrawable(windowID).fIsPixmap == NO &&
1502 "ShapeCombineMask, windowID parameter is a bad window id");
1503 assert([
fPimpl->GetDrawable(pixmapID) isKindOfClass : [QuartzImage
class]] &&
1504 "ShapeCombineMask, pixmapID parameter must point to QuartzImage object");
1511 if (
fPimpl->GetWindow(windowID).fContentView.fParentView)
1514 QuartzImage *
const srcImage = (QuartzImage *)
fPimpl->GetDrawable(pixmapID);
1515 assert(srcImage.
fIsStippleMask == YES &&
"ShapeCombineMask, source image is not a stipple mask");
1519 const Util::NSScopeGuard<QuartzImage> image([[QuartzImage alloc] initFromImageFlipped : srcImage]);
1523 [qw setOpaque : NO];
1524 [qw setBackgroundColor : [NSColor clearColor]];
1528 #pragma mark - "Window manager hints" set of functions. 1536 assert(!
fPimpl->IsRootWindow(wid) &&
"SetMWMHints, called for 'root' window");
1539 NSUInteger newMask = 0;
1555 [qw setStyleMask : newMask];
1558 if (!qw.fMainWindow) {
1559 [[qw standardWindowButton : NSWindowZoomButton] setEnabled : YES];
1560 [[qw standardWindowButton : NSWindowMiniaturizeButton] setEnabled : YES];
1563 if (!qw.fMainWindow) {
1564 [[qw standardWindowButton : NSWindowZoomButton] setEnabled : funcs &
kMWMDecorMaximize];
1565 [[qw standardWindowButton : NSWindowMiniaturizeButton] setEnabled : funcs &
kMWMDecorMinimize];
1587 assert(!
fPimpl->IsRootWindow(wid) &&
"SetWMSizeHints, called for root window");
1590 const NSRect minRect = [NSWindow frameRectForContentRect : NSMakeRect(0., 0., wMin, hMin) styleMask : styleMask];
1591 const NSRect maxRect = [NSWindow frameRectForContentRect : NSMakeRect(0., 0., wMax, hMax) styleMask : styleMask];
1594 [qw setMinSize : minRect.size];
1595 [qw setMaxSize : maxRect.size];
1616 assert(wid >
fPimpl->GetRootWindowID() &&
"SetWMTransientHint, wid parameter is not a valid window id");
1618 if (
fPimpl->IsRootWindow(mainWid))
1623 if (![mainWindow isVisible])
1628 if (mainWindow != transientWindow) {
1631 Error(
"SetWMTransientHint",
"window is already transient for other window");
1633 [[transientWindow standardWindowButton : NSWindowZoomButton] setEnabled : NO];
1634 [mainWindow addTransientWindow : transientWindow];
1637 Warning(
"SetWMTransientHint",
"transient and main windows are the same window");
1640 #pragma mark - GUI-rendering part. 1646 assert(!
fPimpl->IsRootWindow(wid) &&
"DrawLineAux, called for root window");
1648 NSObject<X11Drawable> *
const drawable =
fPimpl->GetDrawable(wid);
1649 CGContextRef ctx = drawable.fContext;
1650 assert(ctx != 0 &&
"DrawLineAux, context is null");
1663 CGContextSetAllowsAntialiasing(ctx,
false);
1665 if (!drawable.fIsPixmap)
1666 CGContextTranslateCTM(ctx, 0.5, 0.5);
1674 SetStrokeParametersFromX11Context(ctx, gcVals);
1675 CGContextBeginPath(ctx);
1676 CGContextMoveToPoint(ctx, x1, y1);
1677 CGContextAddLineToPoint(ctx, x2, y2);
1678 CGContextStrokePath(ctx);
1680 CGContextSetAllowsAntialiasing(ctx,
true);
1695 assert(!
fPimpl->IsRootWindow(wid) &&
"DrawLine, called for root window");
1696 assert(gc > 0 && gc <=
fX11Contexts.size() &&
"DrawLine, invalid context index");
1700 NSObject<X11Drawable> *
const drawable =
fPimpl->GetDrawable(wid);
1701 if (!drawable.fIsPixmap) {
1702 NSObject<X11Window> *
const window = (NSObject<X11Window> *)drawable;
1705 if (ParentRendersToChild(view)) {
1715 fPimpl->fX11CommandBuffer.AddDrawLine(wid, gcVals, x1, y1, x2, y2);
1721 fPimpl->fX11CommandBuffer.AddDrawLine(wid, gcVals, x1, y1, x2, y2);
1731 assert(!
fPimpl->IsRootWindow(wid) &&
"DrawSegmentsAux, called for root window");
1732 assert(segments != 0 &&
"DrawSegmentsAux, segments parameter is null");
1733 assert(nSegments > 0 &&
"DrawSegmentsAux, nSegments <= 0");
1735 for (
Int_t i = 0; i < nSegments; ++i)
1736 DrawLineAux(wid, gcVals, segments[i].fX1, segments[i].fY1 - 3, segments[i].fX2, segments[i].fY2 - 3);
1748 assert(!
fPimpl->IsRootWindow(wid) &&
"DrawSegments, called for root window");
1749 assert(gc > 0 && gc <=
fX11Contexts.size() &&
"DrawSegments, invalid context index");
1750 assert(segments != 0 &&
"DrawSegments, parameter 'segments' is null");
1751 assert(nSegments > 0 &&
"DrawSegments, number of segments <= 0");
1753 NSObject<X11Drawable> *
const drawable =
fPimpl->GetDrawable(wid);
1756 if (!drawable.fIsPixmap) {
1759 if (ParentRendersToChild(view)) {
1769 fPimpl->fX11CommandBuffer.AddDrawSegments(wid, gcVals, segments, nSegments);
1775 fPimpl->fX11CommandBuffer.AddDrawSegments(wid, gcVals, segments, nSegments);
1785 assert(!
fPimpl->IsRootWindow(wid) &&
"DrawRectangleAux, called for root window");
1787 NSObject<X11Drawable> *
const drawable =
fPimpl->GetDrawable(wid);
1789 if (!drawable.fIsPixmap) {
1802 CGContextRef ctx =
fPimpl->GetDrawable(wid).fContext;
1803 assert(ctx &&
"DrawRectangleAux, context is null");
1806 CGContextSetAllowsAntialiasing(ctx,
false);
1808 SetStrokeParametersFromX11Context(ctx, gcVals);
1810 const CGRect rect = CGRectMake(x, y, w, h);
1811 CGContextStrokeRect(ctx, rect);
1813 CGContextSetAllowsAntialiasing(ctx,
true);
1825 assert(!
fPimpl->IsRootWindow(wid) &&
"DrawRectangle, called for root window");
1826 assert(gc > 0 && gc <=
fX11Contexts.size() &&
"DrawRectangle, invalid context index");
1830 NSObject<X11Drawable> *
const drawable =
fPimpl->GetDrawable(wid);
1832 if (!drawable.fIsPixmap) {
1833 NSObject<X11Window> *
const window = (NSObject<X11Window> *)drawable;
1836 if (ParentRendersToChild(view)) {
1846 fPimpl->fX11CommandBuffer.AddDrawRectangle(wid, gcVals, x, y, w, h);
1852 fPimpl->fX11CommandBuffer.AddDrawRectangle(wid, gcVals, x, y, w, h);
1868 assert(!
fPimpl->IsRootWindow(wid) &&
"FillRectangleAux, called for root window");
1870 NSObject<X11Drawable> *
const drawable =
fPimpl->GetDrawable(wid);
1871 CGContextRef ctx = drawable.fContext;
1872 CGSize patternPhase = {};
1874 if (drawable.fIsPixmap) {
1880 const CGRect fillRect = CGRectMake(x, y, w, h);
1882 if (!drawable.fIsPixmap) {
1885 const NSPoint origin = [view.
fParentView convertPoint : view.frame.origin toView : nil];
1886 patternPhase.width = origin.x;
1887 patternPhase.height = origin.y;
1893 if (HasFillStippledStyle(gcVals) || HasFillOpaqueStippledStyle(gcVals) || HasFillTiledStyle(gcVals)) {
1894 PatternContext patternContext = {gcVals.
fMask, gcVals.
fFillStyle, 0, 0, nil, patternPhase};
1896 if (HasFillStippledStyle(gcVals) || HasFillOpaqueStippledStyle(gcVals)) {
1898 "FillRectangleAux, fill_style is FillStippled/FillOpaqueStippled," 1899 " but no stipple is set in a context");
1904 if (HasFillOpaqueStippledStyle(gcVals))
1908 "FillRectangleAux, fill_style is FillTiled, but not tile is set in a context");
1910 patternContext.fImage =
fPimpl->GetDrawable(gcVals.
fTile);
1914 CGContextFillRect(ctx, fillRect);
1919 SetFilledAreaColorFromX11Context(ctx, gcVals);
1920 CGContextFillRect(ctx, fillRect);
1933 assert(!
fPimpl->IsRootWindow(wid) &&
"FillRectangle, called for root window");
1934 assert(gc > 0 && gc <=
fX11Contexts.size() &&
"FillRectangle, invalid context index");
1937 NSObject<X11Drawable> *
const drawable =
fPimpl->GetDrawable(wid);
1939 if (!drawable.fIsPixmap) {
1940 NSObject<X11Window> *
const window = (NSObject<X11Window> *)drawable;
1943 if (ParentRendersToChild(view)) {
1953 fPimpl->fX11CommandBuffer.AddFillRectangle(wid, gcVals, x, y, w, h);
1970 assert(!
fPimpl->IsRootWindow(wid) &&
"FillPolygonAux, called for root window");
1971 assert(polygon != 0 &&
"FillPolygonAux, parameter 'polygon' is null");
1972 assert(nPoints > 0 &&
"FillPolygonAux, number of points must be positive");
1974 NSObject<X11Drawable> *
const drawable =
fPimpl->GetDrawable(wid);
1975 CGContextRef ctx = drawable.fContext;
1977 CGSize patternPhase = {};
1979 if (!drawable.fIsPixmap) {
1981 const NSPoint origin = [view convertPoint : view.frame.origin toView : nil];
1982 patternPhase.width = origin.x;
1983 patternPhase.height = origin.y;
1988 CGContextSetAllowsAntialiasing(ctx,
false);
1990 if (HasFillStippledStyle(gcVals) || HasFillOpaqueStippledStyle(gcVals) || HasFillTiledStyle(gcVals)) {
1991 PatternContext patternContext = {gcVals.
fMask, gcVals.
fFillStyle, 0, 0, nil, patternPhase};
1993 if (HasFillStippledStyle(gcVals) || HasFillOpaqueStippledStyle(gcVals)) {
1995 "FillRectangleAux, fill style is FillStippled/FillOpaqueStippled," 1996 " but no stipple is set in a context");
2001 if (HasFillOpaqueStippledStyle(gcVals))
2005 "FillRectangleAux, fill_style is FillTiled, but not tile is set in a context");
2007 patternContext.fImage =
fPimpl->GetDrawable(gcVals.
fTile);
2012 SetFilledAreaColorFromX11Context(ctx, gcVals);
2017 CGContextBeginPath(ctx);
2018 if (!drawable.fIsPixmap) {
2019 CGContextMoveToPoint(ctx, polygon[0].fX, polygon[0].fY - 2);
2020 for (
Int_t i = 1; i < nPoints; ++i)
2021 CGContextAddLineToPoint(ctx, polygon[i].fX, polygon[i].fY - 2);
2024 for (
Int_t i = 1; i < nPoints; ++i)
2028 CGContextFillPath(ctx);
2029 CGContextSetAllowsAntialiasing(ctx,
true);
2052 assert(polygon != 0 &&
"FillPolygon, parameter 'polygon' is null");
2053 assert(nPoints > 0 &&
"FillPolygon, number of points must be positive");
2054 assert(gc > 0 && gc <=
fX11Contexts.size() &&
"FillPolygon, invalid context index");
2056 NSObject<X11Drawable> *
const drawable =
fPimpl->GetDrawable(wid);
2059 if (!drawable.fIsPixmap) {
2062 if (ParentRendersToChild(view)) {
2072 fPimpl->fX11CommandBuffer.AddFillPolygon(wid, gcVals, polygon, nPoints);
2078 fPimpl->fX11CommandBuffer.AddFillPolygon(wid, gcVals, polygon, nPoints);
2092 assert(!
fPimpl->IsRootWindow(src) &&
"CopyAreaAux, src parameter is root window");
2093 assert(!
fPimpl->IsRootWindow(dst) &&
"CopyAreaAux, dst parameter is root window");
2097 const Util::AutoreleasePool pool;
2099 NSObject<X11Drawable> *
const srcDrawable =
fPimpl->GetDrawable(src);
2100 NSObject<X11Drawable> *
const dstDrawable =
fPimpl->GetDrawable(dst);
2105 QuartzImage *mask = nil;
2108 "CopyArea, mask is not a pixmap");
2118 [dstDrawable copy : srcDrawable area : copyArea withMask : mask clipOrigin : clipOrigin toPoint : dstPoint];
2128 assert(!
fPimpl->IsRootWindow(src) &&
"CopyArea, src parameter is root window");
2129 assert(!
fPimpl->IsRootWindow(dst) &&
"CopyArea, dst parameter is root window");
2130 assert(gc > 0 && gc <=
fX11Contexts.size() &&
"CopyArea, invalid context index");
2132 NSObject<X11Drawable> *
const drawable =
fPimpl->GetDrawable(dst);
2135 if (!drawable.fIsPixmap) {
2138 if (ParentRendersToChild(view)) {
2140 CopyAreaAux(src, dst, gcVals, srcX, srcY, width, height, dstX, dstY);
2148 fPimpl->fX11CommandBuffer.AddCopyArea(src, dst, gcVals, srcX, srcY, width, height, dstX, dstY);
2150 CopyAreaAux(src, dst, gcVals, srcX, srcY, width, height, dstX, dstY);
2153 if (
fPimpl->GetDrawable(src).fIsPixmap) {
2155 CopyAreaAux(src, dst, gcVals, srcX, srcY, width, height, dstX, dstY);
2158 fPimpl->fX11CommandBuffer.AddCopyArea(src, dst, gcVals, srcX, srcY, width, height, dstX, dstY);
2160 CopyAreaAux(src, dst, gcVals, srcX, srcY, width, height, dstX, dstY);
2169 assert(!
fPimpl->IsRootWindow(wid) &&
"DrawStringAux, called for root window");
2171 NSObject<X11Drawable> *
const drawable =
fPimpl->GetDrawable(wid);
2172 CGContextRef ctx = drawable.fContext;
2173 assert(ctx != 0 &&
"DrawStringAux, context is null");
2177 CGContextSetTextMatrix(ctx, CGAffineTransformIdentity);
2180 if (!drawable.fIsPixmap) {
2181 CGContextTranslateCTM(ctx, 0., drawable.fHeight);
2182 CGContextScaleCTM(ctx, 1., -1.);
2186 CGContextSetAllowsAntialiasing(ctx,
true);
2188 assert(gcVals.
fMask &
kGCFont &&
"DrawString, font is not set in a context");
2191 len = std::strlen(text);
2193 CGFloat textColor[4] = {0., 0., 0., 1.};
2198 CGContextSetRGBFillColor(ctx, textColor[0], textColor[1], textColor[2], textColor[3]);
2203 std::vector<UniChar> unichars((
unsigned char *)text, (
unsigned char *)text + len);
2216 assert(!
fPimpl->IsRootWindow(wid) &&
"DrawString, called for root window");
2217 assert(gc > 0 && gc <=
fX11Contexts.size() &&
"DrawString, invalid context index");
2219 NSObject<X11Drawable> *
const drawable =
fPimpl->GetDrawable(wid);
2221 assert(gcVals.
fMask &
kGCFont &&
"DrawString, font is not set in a context");
2223 if (!drawable.fIsPixmap) {
2226 if (ParentRendersToChild(view)) {
2231 }
catch (
const std::exception &) {
2243 fPimpl->fX11CommandBuffer.AddDrawString(wid, gcVals, x, y, text, len);
2250 fPimpl->fX11CommandBuffer.AddDrawString(wid, gcVals, x, y, text, len);
2259 assert(!
fPimpl->IsRootWindow(windowID) &&
"ClearAreaAux, called for root window");
2262 assert(view.fContext != 0 &&
"ClearAreaAux, view.fContext is null");
2270 if (!view.fBackgroundPixmap) {
2272 CGFloat rgb[3] = {};
2276 CGContextSetRGBFillColor(view.fContext, rgb[0], rgb[1], rgb[2], 1.);
2277 CGContextFillRect(view.fContext, CGRectMake(x, y, w, h));
2279 const CGRect fillRect = CGRectMake(x, y, w, h);
2281 CGSize patternPhase = {};
2282 if (view.fParentView) {
2283 const NSPoint origin = [view.fParentView convertPoint : view.frame.origin toView : nil];
2284 patternPhase.width = origin.x;
2285 patternPhase.height = origin.y;
2289 PatternContext patternContext = {
Mask_t(), 0, 0, 0, view.fBackgroundPixmap, patternPhase};
2291 CGContextFillRect(view.fContext, fillRect);
2305 assert(!
fPimpl->IsRootWindow(wid) &&
"ClearArea, called for root window");
2310 if (ParentRendersToChild(view)) {
2318 if (!view.fIsOverlapped && view.fMapState ==
kIsViewable) {
2320 fPimpl->fX11CommandBuffer.AddClearArea(wid, x, y, w, h);
2338 #pragma mark - Pixmap management. 2344 NSSize newSize = {};
2349 Util::NSScopeGuard<QuartzPixmap> pixmap([[QuartzPixmap alloc] initWithW : w
H : h
2350 scaleFactor : [[NSScreen mainScreen] backingScaleFactor]]);
2352 pixmap.Get().fID =
fPimpl->RegisterDrawable(pixmap.Get());
2353 return (
Int_t)pixmap.Get().fID;
2356 Error(
"OpenPixmap",
"QuartzPixmap initialization failed");
2364 assert(!
fPimpl->IsRootWindow(wid) &&
"ResizePixmap, called for root window");
2366 NSObject<X11Drawable> *
const drawable =
fPimpl->GetDrawable(wid);
2367 assert(drawable.fIsPixmap == YES &&
"ResizePixmap, invalid drawable");
2369 QuartzPixmap *pixmap = (QuartzPixmap *)drawable;
2374 if ([pixmap resizeW : w
H : h scaleFactor : [[NSScreen mainScreen] backingScaleFactor]])
2383 assert(pixmapID > (
Int_t)
fPimpl->GetRootWindowID() &&
2384 "SelectPixmap, parameter 'pixmapID' is not a valid id");
2392 assert(pixmapID > (
Int_t)
fPimpl->GetRootWindowID() &&
2393 "CopyPixmap, parameter 'pixmapID' is not a valid id");
2395 "CopyPixmap, fSelectedDrawable is not a valid window id");
2397 NSObject<X11Drawable> *
const source =
fPimpl->GetDrawable(pixmapID);
2398 assert([source isKindOfClass : [QuartzPixmap
class]] &&
2399 "CopyPixmap, source is not a pixmap");
2400 QuartzPixmap *
const pixmap = (QuartzPixmap *)source;
2403 NSObject<X11Drawable> * destination = nil;
2405 if (drawable.fIsPixmap) {
2406 destination = drawable;
2409 if (window.fBackBuffer) {
2410 destination = window.fBackBuffer;
2412 Warning(
"CopyPixmap",
"Operation skipped, since destination" 2413 " window is not double buffered");
2421 [destination copy : pixmap area : copyArea withMask : nil clipOrigin :
X11::Point() toPoint : dstPoint];
2430 #pragma mark - Different functions to create pixmap from different data sources. Used by GUI. 2431 #pragma mark - These functions implement TVirtualX interface, some of them dupilcate others. 2447 assert(bitmap != 0 &&
"CreatePixmap, parameter 'bitmap' is null");
2448 assert(width > 0 &&
"CreatePixmap, parameter 'width' is 0");
2449 assert(height > 0 &&
"CreatePixmap, parameter 'height' is 0");
2451 std::vector<unsigned char> imageData (depth > 1 ? width * height * 4 : width * height);
2454 backgroundPixel, depth, &imageData[0]);
2457 Util::NSScopeGuard<QuartzImage> image;
2460 image.Reset([[QuartzImage alloc] initWithW : width
H : height
data: &imageData[0]]);
2462 image.Reset([[QuartzImage alloc] initMaskWithW : width
H : height bitmapMask : &imageData[0]]);
2465 Error(
"CreatePixmap",
"QuartzImage initialization failed");
2469 image.Get().fID =
fPimpl->RegisterDrawable(image.Get());
2470 return image.Get().fID;
2477 assert(bits != 0 &&
"CreatePixmapFromData, data parameter is null");
2478 assert(width != 0 &&
"CreatePixmapFromData, width parameter is 0");
2479 assert(height != 0 &&
"CreatePixmapFromData, height parameter is 0");
2483 std::vector<unsigned char> imageData(bits, bits + width * height * 4);
2486 unsigned char *p = &imageData[0];
2487 for (
unsigned i = 0,
e = width * height; i <
e; ++i, p += 4)
2491 Util::NSScopeGuard<QuartzImage> image([[QuartzImage alloc] initWithW : width
2492 H : height
data : &imageData[0]]);
2496 Error(
"CreatePixmapFromData",
"QuartzImage initialziation failed");
2500 image.Get().fID =
fPimpl->RegisterDrawable(image.Get());
2501 return image.Get().fID;
2508 assert(std::numeric_limits<unsigned char>::digits == 8 &&
"CreateBitmap, ASImage requires octets");
2516 std::vector<unsigned char> imageData(width * height);
2519 for (
unsigned i = 0, j = 0,
e = width / 8 * height; i <
e; ++i) {
2520 for(
unsigned bit = 0; bit < 8; ++bit, ++j) {
2521 if (bitmap[i] & (1 << bit))
2529 Util::NSScopeGuard<QuartzImage> image([[QuartzImage alloc] initMaskWithW : width
2530 H : height bitmapMask : &imageData[0]]);
2533 Error(
"CreateBitmap",
"QuartzImage initialization failed");
2537 image.Get().fID =
fPimpl->RegisterDrawable(image.Get());
2538 return image.Get().fID;
2544 fPimpl->DeleteDrawable(pixmapID);
2551 assert(
fPimpl->GetDrawable(pixmapID).fIsPixmap == YES &&
"DeletePixmap, object is not a pixmap");
2552 fPimpl->fX11CommandBuffer.AddDeletePixmap(pixmapID);
2568 if (
fPimpl->IsRootWindow(wid)) {
2569 Warning(
"GetColorBits",
"Called for root window");
2571 assert(x >= 0 &&
"GetColorBits, parameter 'x' is negative");
2572 assert(y >= 0 &&
"GetColorBits, parameter 'y' is negative");
2573 assert(w != 0 &&
"GetColorBits, parameter 'w' is 0");
2574 assert(h != 0 &&
"GetColorBits, parameter 'h' is 0");
2577 return [
fPimpl->GetDrawable(wid) readColorBits : area];
2583 #pragma mark - XImage emulation. 2599 assert(wid >
fPimpl->GetRootWindowID() &&
"GetImageSize, parameter 'wid' is invalid");
2601 NSObject<X11Drawable> *
const drawable =
fPimpl->GetDrawable(wid);
2602 width = drawable.fWidth;
2603 height = drawable.fHeight;
2616 assert([
fPimpl->GetDrawable(imageID) isKindOfClass : [QuartzPixmap
class]] &&
2617 "PutPixel, parameter 'imageID' is a bad pixmap id");
2618 assert(x >= 0 &&
"PutPixel, parameter 'x' is negative");
2619 assert(y >= 0 &&
"PutPixel, parameter 'y' is negative");
2621 QuartzPixmap *
const pixmap = (QuartzPixmap *)
fPimpl->GetDrawable(imageID);
2623 unsigned char rgb[3] = {};
2625 [pixmap putPixel : rgb
X : x
Y :
y];
2636 CopyArea(imageID, drawableID, gc, srcX, srcY, width, height, dstX, dstY);
2643 assert([
fPimpl->GetDrawable(imageID) isKindOfClass : [QuartzPixmap
class]] &&
2644 "DeleteImage, imageID parameter is not a valid image id");
2648 #pragma mark - Mouse related code. 2666 assert(!
fPimpl->IsRootWindow(wid) &&
"GrabButton, called for 'root' window");
2668 NSObject<X11Window> *
const widget =
fPimpl->GetWindow(wid);
2671 widget.fPassiveGrabOwnerEvents = YES;
2672 widget.fPassiveGrabButton = button;
2673 widget.fPassiveGrabEventMask = eventMask;
2674 widget.fPassiveGrabKeyModifiers = keyModifiers;
2677 widget.fPassiveGrabOwnerEvents = NO;
2678 widget.fPassiveGrabButton = -1;
2679 widget.fPassiveGrabEventMask = 0;
2680 widget.fPassiveGrabKeyModifiers = 0;
2693 NSView<X11Window> *
const view =
fPimpl->GetWindow(wid).fContentView;
2694 assert(!
fPimpl->IsRootWindow(wid) &&
"GrabPointer, called for 'root' window");
2697 fPimpl->fX11EventTranslator.SetPointerGrab(view, eventMask, ownerEvents);
2701 fPimpl->fX11EventTranslator.CancelPointerGrab();
2752 assert(!
fPimpl->IsRootWindow(wid) &&
"GrabKey, called for root window");
2754 NSView<X11Window> *
const view =
fPimpl->GetWindow(wid).fContentView;
2758 [view addPassiveKeyGrab : keyCode modifiers : cocoaKeyModifiers];
2760 [view removePassiveKeyGrab : keyCode modifiers : cocoaKeyModifiers];
2779 return fPimpl->fX11EventTranslator.GetInputFocus();
2786 assert(!
fPimpl->IsRootWindow(wid) &&
"SetInputFocus, called for root window");
2789 fPimpl->fX11EventTranslator.SetInputFocus(nil);
2791 fPimpl->fX11EventTranslator.SetInputFocus(
fPimpl->GetWindow(wid).fContentView);
2807 assert(buf != 0 &&
"LookupString, parameter 'buf' is null");
2808 assert(length >= 2 &&
"LookupString, parameter 'length' - not enough memory to return null-terminated ASCII string");
2813 #pragma mark - Font management. 2820 assert(fontName != 0 &&
"LoadQueryFont, fontName is null");
2829 return fPimpl->fFontManager.LoadFont(xlfd);
2844 fPimpl->fFontManager.UnloadFont(fs);
2859 return fPimpl->fFontManager.GetTextWidth(font, s, len);
2866 fPimpl->fFontManager.GetFontProperties(font, maxAscent, maxDescent);
2893 if (fontName && fontName[0]) {
2896 return fPimpl->fFontManager.ListFonts(xlfd, maxNames, count);
2909 fPimpl->fFontManager.FreeFontNames(fontList);
2912 #pragma mark - Color management. 2920 return fPimpl->fX11ColorParser.ParseColor(colorName, color);
2926 const unsigned red = unsigned(
double(color.
fRed) / 0xFFFF * 0xFF);
2927 const unsigned green = unsigned(
double(color.
fGreen) / 0xFFFF * 0xFF);
2928 const unsigned blue = unsigned(
double(color.
fBlue) / 0xFFFF * 0xFF);
2929 color.
fPixel = red << 16 | green << 8 | blue;
2937 color.
fRed = (color.
fPixel >> 16 & 0xFF) * 0xFFFF / 0xFF;
2938 color.
fGreen = (color.
fPixel >> 8 & 0xFF) * 0xFFFF / 0xFF;
2939 color.
fBlue = (color.
fPixel & 0xFF) * 0xFFFF / 0xFF;
2952 if (
const TColor *
const color =
gROOT->GetColor(rootColorIndex)) {
2953 Float_t red = 0.f, green = 0.f, blue = 0.f;
2954 color->GetRGB(red, green, blue);
2955 pixel = unsigned(red * 255) << 16;
2956 pixel |= unsigned(green * 255) << 8;
2957 pixel |= unsigned(blue * 255);
2991 #pragma mark - Graphical context management. 3011 assert(gc <=
fX11Contexts.size() && gc > 0 &&
"ChangeGC, invalid context id");
3015 x11Context.fForeground = foreground;
3022 assert(gc <=
fX11Contexts.size() && gc > 0 &&
"ChangeGC, invalid context id");
3023 assert(gval != 0 &&
"ChangeGC, gval parameter is null");
3027 x11Context.
fMask |= mask;
3040 if (mask & kGCLineWidth)
3042 if (mask & kGCLineStyle)
3077 const unsigned nDashes =
sizeof x11Context.
fDashes /
sizeof x11Context.
fDashes[0];
3078 for (
unsigned i = 0; i < nDashes; ++i)
3087 assert(src <=
fX11Contexts.size() && src > 0 &&
"CopyGC, bad source context");
3088 assert(dst <=
fX11Contexts.size() && dst > 0 &&
"CopyGC, bad destination context");
3091 srcContext.fMask = mask;
3111 #pragma mark - Cursor management. 3133 assert(!
fPimpl->IsRootWindow(wid) &&
"SetCursor, called for root window");
3135 NSView<X11Window> *
const view =
fPimpl->GetWindow(wid).fContentView;
3136 view.fCurrentCursor = cursor;
3156 const NSPoint screenPoint = [NSEvent mouseLocation];
3172 rootWinID =
fPimpl->GetRootWindowID();
3174 NSPoint screenPoint = [NSEvent mouseLocation];
3177 rootX = screenPoint.x;
3178 rootY = screenPoint.y;
3181 if (winID >
fPimpl->GetRootWindowID()) {
3182 NSObject<X11Window> *
const window =
fPimpl->GetWindow(winID);
3187 winX = screenPoint.x;
3188 winY = screenPoint.y;
3193 childWinID = childWin.fID;
3201 #pragma mark - OpenGL management. 3210 return [[NSScreen mainScreen] backingScaleFactor];
3215 const std::vector<std::pair<UInt_t, Int_t> > &formatComponents)
3219 typedef std::pair<UInt_t, Int_t> component_type;
3220 typedef std::vector<component_type>::size_type size_type;
3223 std::vector<NSOpenGLPixelFormatAttribute> attribs;
3224 for (size_type i = 0,
e = formatComponents.size(); i <
e; ++i) {
3225 const component_type &comp = formatComponents[i];
3228 attribs.push_back(NSOpenGLPFADoubleBuffer);
3230 attribs.push_back(NSOpenGLPFADepthSize);
3231 attribs.push_back(comp.second > 0 ? comp.second : 32);
3233 attribs.push_back(NSOpenGLPFAAccumSize);
3234 attribs.push_back(comp.second > 0 ? comp.second : 1);
3236 attribs.push_back(NSOpenGLPFAStencilSize);
3237 attribs.push_back(comp.second > 0 ? comp.second : 8);
3239 attribs.push_back(NSOpenGLPFAMultisample);
3240 attribs.push_back(NSOpenGLPFASampleBuffers);
3241 attribs.push_back(1);
3242 attribs.push_back(NSOpenGLPFASamples);
3243 attribs.push_back(comp.second ? comp.second : 8);
3247 attribs.push_back(0);
3249 NSOpenGLPixelFormat *
const pixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes : &attribs[0]];
3250 const Util::NSScopeGuard<NSOpenGLPixelFormat> formatGuard(pixelFormat);
3252 NSView<X11Window> *parentView = nil;
3253 if (!
fPimpl->IsRootWindow(parentID)) {
3254 parentView =
fPimpl->GetWindow(parentID).fContentView;
3255 assert([parentView isKindOfClass : [
QuartzView class]] &&
3256 "CreateOpenGLWindow, parent view must be QuartzView");
3259 NSRect viewFrame = {};
3260 viewFrame.size.width = width;
3261 viewFrame.size.height = height;
3264 const Util::NSScopeGuard<ROOTOpenGLView> viewGuard(glView);
3269 [parentView addChild : glView];
3270 glID =
fPimpl->RegisterDrawable(glView);
3276 const Util::NSScopeGuard<QuartzWindow> winGuard(parent);
3280 Error(
"CreateOpenGLWindow",
"QuartzWindow allocation/initialization" 3281 " failed for a top-level GL widget");
3285 glID =
fPimpl->RegisterDrawable(parent);
3295 assert(!
fPimpl->IsRootWindow(windowID) &&
3296 "CreateOpenGLContext, parameter 'windowID' is a root window");
3298 "CreateOpenGLContext, view is not an OpenGL view");
3300 NSOpenGLContext *
const sharedContext =
fPimpl->GetGLContextForHandle(sharedID);
3303 const Util::NSScopeGuard<NSOpenGLContext>
3304 newContext([[NSOpenGLContext alloc] initWithFormat : glView.
pixelFormat shareContext : sharedContext]);
3306 const Handle_t ctxID =
fPimpl->RegisterGLContext(newContext.Get());
3322 assert(ctxID > 0 &&
"MakeOpenGLContextCurrent, invalid context id");
3324 NSOpenGLContext *
const glContext =
fPimpl->GetGLContextForHandle(ctxID);
3326 Error(
"MakeOpenGLContextCurrent",
"No OpenGL context found for id %d",
int(ctxID));
3334 if ([glContext view] != glView)
3335 [glContext setView : glView];
3343 [glContext makeCurrentContext];
3356 NSView *fakeView = nil;
3363 const UInt_t width = std::max(glView.frame.size.width, CGFloat(100));
3364 const UInt_t height = std::max(glView.frame.size.height, CGFloat(100));
3366 NSRect viewFrame = {};
3367 viewFrame.size.width = width;
3368 viewFrame.size.height = height;
3374 fakeWindow = [[
QuartzWindow alloc] initWithContentRect : viewFrame styleMask : styleMask
3375 backing : NSBackingStoreBuffered defer : NO windowAttributes : &attr];
3376 Util::NSScopeGuard<QuartzWindow> winGuard(fakeWindow);
3379 [fakeView setHidden : NO];
3381 fPimpl->SetFakeGLWindow(fakeWindow);
3385 [fakeView setHidden : NO];
3389 [glContext setView : fakeView];
3390 [glContext makeCurrentContext];
3399 NSOpenGLContext *
const currentContext = [NSOpenGLContext currentContext];
3400 if (!currentContext) {
3401 Error(
"GetCurrentOpenGLContext",
"The current OpenGL context is null");
3405 const Handle_t contextID =
fPimpl->GetHandleForGLContext(currentContext);
3407 Error(
"GetCurrentOpenGLContext",
"The current OpenGL context was" 3408 " not created/registered by TGCocoa");
3416 assert(ctxID > 0 &&
"FlushOpenGLBuffer, invalid context id");
3418 NSOpenGLContext *
const glContext =
fPimpl->GetGLContextForHandle(ctxID);
3419 assert(glContext != nil &&
"FlushOpenGLBuffer, bad context id");
3421 if (glContext != [NSOpenGLContext currentContext])
3425 [glContext flushBuffer];
3434 NSOpenGLContext *
const glContext =
fPimpl->GetGLContextForHandle(ctxID);
3435 if (NSView *
const v = [glContext view]) {
3437 ((ROOTOpenGLView *)
v).fOpenGLContext = nil;
3439 [glContext clearDrawable];
3442 if (glContext == [NSOpenGLContext currentContext])
3443 [NSOpenGLContext clearCurrentContext];
3445 fPimpl->DeleteGLContext(ctxID);
3448 #pragma mark - Off-screen rendering for TPad/TCanvas. 3454 assert(windowID > (
Int_t)
fPimpl->GetRootWindowID() &&
"SetDoubleBuffer called for root window");
3456 if (windowID == 999) {
3457 Warning(
"SetDoubleBuffer",
"called with wid == 999");
3478 "SetDoubleBufferON, called, but no correct window was selected before");
3482 assert(window.fIsPixmap == NO &&
3483 "SetDoubleBufferON, selected drawable is a pixmap, can not attach pixmap to pixmap");
3485 const unsigned currW = window.fWidth;
3486 const unsigned currH = window.fHeight;
3488 if (QuartzPixmap *
const currentPixmap = window.fBackBuffer) {
3489 if (currH == currentPixmap.fHeight && currW == currentPixmap.fWidth)
3494 Util::NSScopeGuard<QuartzPixmap> pixmap([[QuartzPixmap alloc] initWithW : currW
3495 H : currH scaleFactor : [[NSScreen mainScreen] backingScaleFactor]]);
3497 window.fBackBuffer = pixmap.Get();
3500 Error(
"SetDoubleBufferON",
"QuartzPixmap initialization failed");
3512 #pragma mark - Event management part. 3517 if (
fPimpl->IsRootWindow(wid))
3526 fPimpl->fX11EventTranslator.fEventQueue.push_back(newEvent);
3532 assert(
fPimpl->fX11EventTranslator.fEventQueue.size() > 0 &&
"NextEvent, event queue is empty");
3534 event =
fPimpl->fX11EventTranslator.fEventQueue.front();
3535 fPimpl->fX11EventTranslator.fEventQueue.pop_front();
3541 return (
Int_t)
fPimpl->fX11EventTranslator.fEventQueue.size();
3548 typedef X11::EventQueue_t::iterator iterator_type;
3550 iterator_type it =
fPimpl->fX11EventTranslator.fEventQueue.begin();
3551 iterator_type eIt =
fPimpl->fX11EventTranslator.fEventQueue.end();
3553 for (; it != eIt; ++it) {
3554 const Event_t &queuedEvent = *it;
3555 if (queuedEvent.
fWindow == windowID && queuedEvent.
fType == type) {
3556 event = queuedEvent;
3557 fPimpl->fX11EventTranslator.fEventQueue.erase(it);
3573 #pragma mark - "Drag and drop", "Copy and paste", X11 properties. 3582 assert(name != 0 &&
"InternAtom, parameter 'name' is null");
3583 return FindAtom(name, !onlyIfExist);
3600 assert(!
fPimpl->IsRootWindow(windowID) &&
3601 "SetPrimarySelectionOwner, windowID parameter is a 'root' window");
3602 assert(
fPimpl->GetDrawable(windowID).fIsPixmap == NO &&
3603 "SetPrimarySelectionOwner, windowID parameter is not a valid window");
3605 const Atom_t primarySelectionAtom =
FindAtom(
"XA_PRIMARY",
false);
3606 assert(primarySelectionAtom !=
kNone &&
3607 "SetPrimarySelectionOwner, predefined XA_PRIMARY atom was not found");
3625 assert(!
fPimpl->IsRootWindow(windowID) &&
3626 "SetSelectionOwner, windowID parameter is a 'root' window'");
3627 assert(
fPimpl->GetDrawable(windowID).fIsPixmap == NO &&
3628 "SetSelectionOwner, windowID parameter is not a valid window");
3643 const Atom_t primarySelectionAtom =
FindAtom(
"XA_PRIMARY",
false);
3644 assert(primarySelectionAtom !=
kNone &&
3645 "GetPrimarySelectionOwner, predefined XA_PRIMARY atom was not found");
3668 assert(!
fPimpl->IsRootWindow(windowID) &&
3669 "ConvertPrimarySelection, parameter 'windowID' is root window");
3670 assert(
fPimpl->GetDrawable(windowID).fIsPixmap == NO &&
3671 "ConvertPrimarySelection, parameter windowID parameter is not a window id");
3674 assert(primarySelectionAtom !=
kNone &&
3675 "ConvertPrimarySelection, XA_PRIMARY predefined atom not found");
3678 assert(stringAtom !=
kNone &&
3679 "ConvertPrimarySelection, XA_STRING predefined atom not found");
3681 ConvertSelection(windowID, primarySelectionAtom, stringAtom, clipboard, when);
3697 assert(!
fPimpl->IsRootWindow(windowID) &&
3698 "ConvertSelection, parameter 'windowID' is root window'");
3699 assert(
fPimpl->GetDrawable(windowID).fIsPixmap == NO &&
3700 "ConvertSelection, parameter 'windowID' is not a window id");
3710 newEvent.fWindow = windowID;
3711 newEvent.fUser[0] = windowID;
3712 newEvent.fUser[1] = selection;
3713 newEvent.fUser[2] = target;
3714 newEvent.fUser[3] = property;
3722 ULong_t *bytesAfterReturn,
unsigned char **propertyReturn)
3733 if (
fPimpl->IsRootWindow(windowID))
3736 assert(
fPimpl->GetDrawable(windowID).fIsPixmap == NO &&
3737 "GetProperty, parameter 'windowID' is not a valid window id");
3738 assert(propertyID > 0 && propertyID <=
fAtomToName.size() &&
3739 "GetProperty, parameter 'propertyID' is not a valid atom");
3740 assert(actualType != 0 &&
"GetProperty, parameter 'actualType' is null");
3741 assert(actualFormat != 0 &&
"GetProperty, parameter 'actualFormat' is null");
3742 assert(bytesAfterReturn != 0 &&
"GetProperty, parameter 'bytesAfterReturn' is null");
3743 assert(propertyReturn != 0 &&
"GetProperty, parameter 'propertyReturn' is null");
3745 const Util::AutoreleasePool pool;
3747 *bytesAfterReturn = 0;
3748 *propertyReturn = 0;
3751 const std::string &atomName =
fAtomToName[propertyID - 1];
3752 NSObject<X11Window> *window =
fPimpl->GetWindow(windowID);
3754 if (![window hasProperty : atomName.c_str()]) {
3755 Error(
"GetProperty",
"Unknown property %s requested", atomName.c_str());
3759 unsigned tmpFormat = 0, tmpElements = 0;
3760 *propertyReturn = [window getProperty : atomName.c_str() returnType : actualType
3761 returnFormat : &tmpFormat nElements : &tmpElements];
3762 *actualFormat = (
Int_t)tmpFormat;
3763 *nItems = tmpElements;
3782 assert(!
fPimpl->IsRootWindow(windowID) &&
3783 "GetPasteBuffer, parameter 'windowID' is root window");
3784 assert(
fPimpl->GetDrawable(windowID).fIsPixmap == NO &&
3785 "GetPasteBuffer, parameter 'windowID' is not a valid window");
3786 assert(propertyID && propertyID <=
fAtomToName.size() &&
3787 "GetPasteBuffer, parameter 'propertyID' is not a valid atom");
3789 const Util::AutoreleasePool pool;
3791 const std::string &atomString =
fAtomToName[propertyID - 1];
3792 NSObject<X11Window> *window =
fPimpl->GetWindow(windowID);
3794 if (![window hasProperty : atomString.c_str()]) {
3795 Error(
"GetPasteBuffer",
"No property %s on a window", atomString.c_str());
3800 unsigned tmpFormat = 0, nElements = 0;
3802 const Util::ScopedArray<char>
3803 propertyData((
char *)[window getProperty : atomString.c_str()
3804 returnType : &tmpType returnFormat : &tmpFormat
3805 nElements : &nElements]);
3807 assert(tmpFormat == 8 &&
"GetPasteBuffer, property has wrong format");
3809 text.
Insert(0, propertyData.Get(), nElements);
3810 nChars = (
Int_t)nElements;
3815 [window removeProperty : atomString.c_str()];
3846 assert(!
fPimpl->IsRootWindow(windowID) &&
3847 "ChangeProperty, parameter 'windowID' is root window");
3848 assert(
fPimpl->GetDrawable(windowID).fIsPixmap == NO &&
3849 "ChangeProperty, parameter 'windowID' is not a valid window id");
3850 assert(propertyID && propertyID <=
fAtomToName.size() &&
3851 "ChangeProperty, parameter 'propertyID' is not a valid atom");
3853 const Util::AutoreleasePool pool;
3855 const std::string &atomString =
fAtomToName[propertyID - 1];
3857 NSObject<X11Window> *
const window =
fPimpl->GetWindow(windowID);
3858 [window setProperty : atomString.c_str()
data : data size : len forType : type
format : 8];
3880 assert(!
fPimpl->IsRootWindow(windowID) &&
3881 "ChangeProperties, parameter 'windowID' is root window");
3882 assert(
fPimpl->GetDrawable(windowID).fIsPixmap == NO &&
3883 "ChangeProperties, parameter 'windowID' is not a valid window id");
3884 assert(propertyID && propertyID <=
fAtomToName.size() &&
3885 "ChangeProperties, parameter 'propertyID' is not a valid atom");
3887 const Util::AutoreleasePool pool;
3889 const std::string &atomName =
fAtomToName[propertyID - 1];
3891 NSObject<X11Window> *
const window =
fPimpl->GetWindow(windowID);
3892 [window setProperty : atomName.c_str()
data : data
3911 assert(!
fPimpl->IsRootWindow(windowID) &&
3912 "DeleteProperty, parameter 'windowID' is root window");
3913 assert(
fPimpl->GetDrawable(windowID).fIsPixmap == NO &&
3914 "DeleteProperty, parameter 'windowID' is not a valid window");
3915 assert(propertyID && propertyID <=
fAtomToName.size() &&
3916 "DeleteProperty, parameter 'propertyID' is not a valid atom");
3918 const std::string &atomString =
fAtomToName[propertyID - 1];
3919 [
fPimpl->GetWindow(windowID) removeProperty : atomString.c_str()];
3935 assert(windowID >
fPimpl->GetRootWindowID() &&
3936 "SetDNDAware, parameter 'windowID' is not a valid window id");
3937 assert(
fPimpl->GetDrawable(windowID).fIsPixmap == NO &&
3938 "SetDNDAware, parameter 'windowID' is not a window");
3940 const Util::AutoreleasePool pool;
3943 NSArray *
const supportedTypes = [NSArray arrayWithObjects : NSFilenamesPboardType, nil];
3947 [view registerForDraggedTypes : supportedTypes];
3954 assert(xaAtomAtom == 4 &&
"SetDNDAware, XA_ATOM is not defined");
3959 assert(
sizeof(
unsigned) == 4 &&
"SetDNDAware, sizeof(unsigned) must be 4");
3962 std::vector<unsigned> propertyData;
3963 propertyData.push_back(4);
3966 for (
unsigned i = 0; typeList[i]; ++i)
3967 propertyData.push_back(
unsigned(typeList[i]));
3970 [view setProperty :
"XdndAware" data : (
unsigned char *)&propertyData[0]
3971 size : propertyData.size() forType : xaAtomAtom
format : 32];
3979 if (windowID <= fPimpl->GetRootWindowID())
3982 assert(
fPimpl->GetDrawable(windowID).fIsPixmap == NO &&
3983 "IsDNDAware, windowID parameter is not a window");
3986 return view.fIsDNDAware;
3994 ::Warning(
"SetTypeList",
"Not implemented");
4018 fPimpl->IsRootWindow(winID) ? nil :
fPimpl->GetWindow(winID).fContentView,
4019 dragWinID, inputWinID,
x,
y, maxDepth);
4021 return testView.fID;
4026 #pragma mark - Noops. 4046 chupx = chupy = 0.f;
4151 NSPoint newCursorPosition = {};
4152 newCursorPosition.x = ix;
4153 newCursorPosition.y = iy;
4155 if (
fPimpl->GetRootWindowID() == winID) {
4159 assert(
fPimpl->GetDrawable(winID).fIsPixmap == NO &&
4160 "Warp, drawable is not a window");
4165 CGWarpMouseCursorPosition(NSPointToCGPoint(newCursorPosition));
4397 #pragma mark - Details and aux. functions. 4402 return &
fPimpl->fX11EventTranslator;
4408 return &
fPimpl->fX11CommandBuffer;
4420 assert(
fCocoaDraw > 0 &&
"CocoaDrawOFF, was already off");
4434 if (!drawable.fIsPixmap) {
4435 Error(
"GetCurrentContext",
"TCanvas/TPad's internal error," 4436 " selected drawable is not a pixmap!");
4440 return drawable.fContext;
4453 ProcessSerialNumber psn = {0, kCurrentProcess};
4455 const OSStatus res1 = TransformProcessType(&psn, kProcessTransformToForegroundApplication);
4460 if (res1 != noErr && res1 != paramErr) {
4461 Error(
"MakeProcessForeground",
"TransformProcessType failed with code %d",
int(res1));
4464 #ifdef MAC_OS_X_VERSION_10_9 4466 [[NSApplication sharedApplication] activateIgnoringOtherApps : YES];
4468 const OSErr res2 = SetFrontProcess(&psn);
4469 if (res2 != noErr) {
4470 Error(
"MakeProcessForeground",
"SetFrontProcess failed with code %d", res2);
4477 #ifdef MAC_OS_X_VERSION_10_9 4479 [[NSApplication sharedApplication] activateIgnoringOtherApps : YES];
4481 ProcessSerialNumber psn = {};
4483 OSErr res = GetCurrentProcess(&psn);
4485 Error(
"MakeProcessForeground",
"GetCurrentProcess failed with code %d", res);
4489 res = SetFrontProcess(&psn);
4491 Error(
"MapProcessForeground",
"SetFrontProcess failed with code %d", res);
4503 const std::map<std::string, Atom_t>::const_iterator it =
fNameToAtom.find(atomName);
4507 else if (addIfNotFound) {
4522 const char *
const iconDirectoryPath =
gEnv->
GetValue(
"Gui.IconPath",
"$(ROOTSYS)/icons");
4523 if (iconDirectoryPath) {
4525 if (fileName.Get()) {
4526 const Util::AutoreleasePool pool;
4528 NSString *cocoaStr = [NSString stringWithCString : fileName.Get() encoding : NSASCIIStringEncoding];
4529 NSImage *image = [[[NSImage alloc] initWithContentsOfFile : cocoaStr] autorelease];
4530 [NSApp setApplicationIconImage : image];
NSUInteger GetCocoaKeyModifiersFromROOTKeyModifiers(UInt_t rootKeyModifiers)
bool ParseXLFDName(const std::string &xlfdName, XLFDName &dst)
virtual void SetClipRectangles(GContext_t gc, Int_t x, Int_t y, Rectangle_t *recs, Int_t n)
Sets clipping rectangles in graphics context.
virtual Int_t GetDepth() const
Returns depth of screen (number of bit planes).
virtual void GetGCValues(GContext_t gc, GCValues_t &gval)
Returns the components specified by the mask in "gval" for the specified GC "gc" (see also the GCValu...
int GlobalXCocoaToROOT(CGFloat xCocoa)
virtual Window_t GetInputFocus()
Returns the window id of the window having the input focus.
virtual Pixmap_t CreatePixmap(Drawable_t wid, UInt_t w, UInt_t h)
Creates a pixmap of the specified width and height and returns a pixmap ID that identifies it...
virtual void MoveResizeWindow(Window_t wid, Int_t x, Int_t y, UInt_t w, UInt_t h)
Changes the size and location of the specified window "id" without raising it.
virtual void DeletePixmap(Pixmap_t pixmapID)
Explicitly deletes the pixmap resource "pmap".
virtual Int_t KeysymToKeycode(UInt_t keysym)
Converts the "keysym" to the appropriate keycode.
virtual void SetWindowBackground(Window_t wid, ULong_t color)
Sets the background of the window "id" to the specified color value "color".
virtual Drawable_t CreateImage(UInt_t width, UInt_t height)
Allocates the memory needed for an drawable.
Semi-Abstract base class defining a generic interface to the underlying, low level, native graphics backend (X11, Win32, MacOS, OpenGL...).
std::unique_ptr< ROOT::MacOSX::Details::CocoaPrivate > fPimpl
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)
virtual GContext_t CreateGC(Drawable_t wid, GCValues_t *gval)
Creates a graphics context using the provided GCValues_t *gval structure.
void GetRootWindowAttributes(WindowAttributes_t *attr)
virtual void ChangeWindowAttributes(Window_t wid, SetWindowAttributes_t *attr)
Changes the attributes of the specified window "id" according the values provided in "attr"...
bool fDisplayShapeChanged
std::vector< GCValues_t > fX11Contexts
virtual void GrabPointer(Window_t wid, UInt_t evmask, Window_t confine, Cursor_t cursor, Bool_t grab=kTRUE, Bool_t owner_events=kTRUE)
Establishes an active pointer grab.
void DrawSegmentsAux(Drawable_t wid, const GCValues_t &gcVals, const Segment_t *segments, Int_t nSegments)
void ReparentTopLevel(Window_t wid, Window_t pid, Int_t x, Int_t y)
void InitWithPredefinedAtoms(name_to_atom_map &nameToAtom, std::vector< std::string > &atomNames)
virtual void GetRegionBox(Region_t reg, Rectangle_t *rect)
Returns smallest enclosing rectangle.
virtual Int_t AddWindow(ULong_t qwid, UInt_t w, UInt_t h)
Registers a window created by Qt as a ROOT window.
bool LockFocus(NSView< X11Window > *view)
ROOT::MacOSX::Util::CFScopeGuard< CGImageRef > fImage
Int_t MapKeySymToKeyCode(Int_t keySym)
virtual void CopyArea(Drawable_t src, Drawable_t dst, GContext_t gc, Int_t srcX, Int_t srcY, UInt_t width, UInt_t height, Int_t dstX, Int_t dstY)
Combines the specified rectangle of "src" with the specified rectangle of "dest" according to the "gc...
virtual FontStruct_t GetFontStruct(FontH_t fh)
Retrieves the associated font structure of the font specified font handle "fh".
virtual Int_t AddPixmap(ULong_t pixid, UInt_t w, UInt_t h)
Registers a pixmap created by TGLManager as a ROOT pixmap.
virtual Int_t SupportsExtension(const char *extensionName) const
Returns 1 if window system server supports extension given by the argument, returns 0 in case extensi...
virtual void MapRaised(Window_t wid)
Maps the window "id" and all of its subwindows that have had map requests on the screen and put this ...
virtual Handle_t CreateOpenGLContext(Window_t windowID, Handle_t sharedContext)
Creates OpenGL context for window "windowID".
void swap(TDirectoryEntry &e1, TDirectoryEntry &e2) noexcept
QuartzWindow * FindWindowInPoint(Int_t x, Int_t y)
const Mask_t kGCDashOffset
virtual Region_t CreateRegion()
Creates a new empty region.
NSView< X11Window > * FindDNDAwareViewInPoint(NSView *parentView, Window_t dragWinID, Window_t inputWinID, Int_t x, Int_t y, Int_t maxDepth)
virtual void SetWMSize(Window_t winID, UInt_t w, UInt_t h)
Tells window manager the desired size of window "id".
virtual void SetDrawMode(EDrawMode mode)
Sets the drawing mode.
virtual Window_t FindRWindow(Window_t win, Window_t dragwin, Window_t input, int x, int y, int maxd)
Recursively search in the children of Window for a Window which is at location x, y and is DND aware...
virtual void SetIconPixmap(Window_t wid, Pixmap_t pix)
Sets the icon name pixmap.
void DrawRectangleAux(Drawable_t wid, const GCValues_t &gcVals, Int_t x, Int_t y, UInt_t w, UInt_t h)
virtual Bool_t SetSelectionOwner(Window_t windowID, Atom_t &selectionID)
Changes the owner and last-change time for the specified selection.
virtual void DrawLine(Drawable_t wid, GContext_t gc, Int_t x1, Int_t y1, Int_t x2, Int_t y2)
Uses the components of the specified GC to draw a line between the specified set of points (x1...
void MapUnicharToKeySym(unichar key, char *buf, Int_t len, UInt_t &rootKeySym)
virtual Window_t GetWindowID(Int_t wid)
Returns the X11 window identifier.
virtual void CloseDisplay()
Closes connection to display server and destroys all windows.
virtual void UpdateWindow(Int_t mode)
Updates or synchronises client and server once (not permanent).
virtual Window_t GetDefaultRootWindow() const
Returns handle to the default root window created when calling XOpenDisplay().
virtual void DeleteOpenGLContext(Int_t ctxID)
Deletes OpenGL context for window "wid".
virtual void SetDoubleBufferON()
Turns double buffer mode on.
void DeletePixmapAux(Pixmap_t pixmapID)
virtual void Bell(Int_t percent)
Sets the sound bell. Percent is loudness from -100% to 100%.
QuartzImage * fShapeCombineMask
bool GLViewIsValidDrawable(ROOTOpenGLView *glView)
virtual void FreeFontNames(char **fontlist)
Frees the specified the array of strings "fontlist".
virtual void GetPlanes(Int_t &nplanes)
Returns the maximum number of planes.
const Mask_t kGCLineStyle
virtual Int_t RequestLocator(Int_t mode, Int_t ctyp, Int_t &x, Int_t &y)
Requests Locator position.
R__EXTERN TVirtualMutex * gROOTMutex
virtual char * Which(const char *search, const char *file, EAccessMode mode=kFileExists)
Find location of file in a search path.
virtual Bool_t ParseColor(Colormap_t cmap, const char *cname, ColorStruct_t &color)
Looks up the string name of a color "cname" with respect to the screen associated with the specified ...
NSView< X11Window > * fContentView
std::map< Atom_t, Window_t >::iterator selection_iterator
virtual void RaiseWindow(Window_t wid)
Raises the specified window to the top of the stack so that no sibling window obscures it...
Atom_t FindAtom(const std::string &atomName, bool addIfNotFound)
virtual void IconifyWindow(Window_t wid)
Iconifies the window "id".
virtual void ConvertPrimarySelection(Window_t wid, Atom_t clipboard, Time_t when)
Causes a SelectionRequest event to be sent to the current primary selection owner.
static std::string format(double x, double y, int digits, int width)
virtual Atom_t InternAtom(const char *atom_name, Bool_t only_if_exist)
Returns the atom identifier associated with the specified "atom_name" string.
virtual void QueryColor(Colormap_t cmap, ColorStruct_t &color)
Returns the current RGB value for the pixel in the "color" structure.
ROOT::MacOSX::X11::name_to_atom_map fNameToAtom
virtual void SetTypeList(Window_t win, Atom_t prop, Atom_t *typelist)
Add the list of drag and drop types to the Window win.
virtual void SetIconName(Window_t wid, char *name)
Sets the window icon name.
bool CocoaInitialized() const
const NSUInteger kTitledWindowMask
TString & Insert(Ssiz_t pos, const char *s)
virtual void GrabKey(Window_t wid, Int_t keycode, UInt_t modifier, Bool_t grab=kTRUE)
Establishes a passive grab on the keyboard.
void SetApplicationIcon()
virtual void SetWMState(Window_t winID, EInitialState state)
Sets the initial state of the window "id": either kNormalState or kIconicState.
bool SetFillPattern(CGContextRef ctx, const unsigned *patternIndex)
void ClearAreaAux(Window_t wid, Int_t x, Int_t y, UInt_t w, UInt_t h)
EGraphicsFunction fFunction
const NSUInteger kResizableWindowMask
NSOpenGLPixelFormat * pixelFormat()
virtual void SelectWindow(Int_t wid)
Selects the window "wid" to which subsequent output is directed.
virtual void SetCursor(Window_t wid, Cursor_t curid)
Sets the cursor "curid" to be used when the pointer is in the window "id".
void FillPixmapBuffer(const unsigned char *bitmap, unsigned width, unsigned height, ULong_t foregroundPixel, ULong_t backgroundPixel, unsigned depth, unsigned char *imageData)
virtual void GetImageSize(Drawable_t wid, UInt_t &width, UInt_t &height)
Returns the width and height of the image id.
virtual void UnmapWindow(Window_t wid)
Unmaps the specified window "id".
virtual void DrawRectangle(Drawable_t wid, GContext_t gc, Int_t x, Int_t y, UInt_t w, UInt_t h)
Draws rectangle outlines of [x,y] [x+w,y] [x+w,y+h] [x,y+h].
virtual void SetDashes(GContext_t gc, Int_t offset, const char *dash_list, Int_t n)
Sets the dash-offset and dash-list attributes for dashed line styles in the specified GC...
virtual void MapSubwindows(Window_t wid)
Maps all subwindows for the specified window "id" in top-to-bottom stacking order.
virtual void CopyGC(GContext_t org, GContext_t dest, Mask_t mask)
Copies the specified components from the source GC "org" to the destination GC "dest".
static const double x2[5]
virtual Bool_t ReadPictureDataFromFile(const char *filename, char ***ret_data)
Reads picture data from file "filename" and store it in "ret_data".
virtual void ResizeWindow(Int_t wid)
Resizes the window "wid" if necessary.
virtual Bool_t CreatePictureFromFile(Drawable_t wid, const char *filename, Pixmap_t &pict, Pixmap_t &pict_mask, PictureAttributes_t &attr)
Creates a picture pict from data in file "filename".
virtual void SetWMSizeHints(Window_t winID, UInt_t wMin, UInt_t hMin, UInt_t wMax, UInt_t hMax, UInt_t wInc, UInt_t hInc)
Gives the window manager minimum and maximum size hints of the window "id".
virtual void MapWindow(Window_t wid)
Maps the window "id" and all of its subwindows that have had map requests.
virtual void MoveWindow(Int_t wid, Int_t x, Int_t y)
Moves the window "wid" to the specified x and y coordinates.
NSPoint TranslateCoordinates(NSView< X11Window > *fromView, NSView< X11Window > *toView, NSPoint sourcePoint)
virtual Int_t ResizePixmap(Int_t wid, UInt_t w, UInt_t h)
Resizes the specified pixmap "wid".
virtual void GetPasteBuffer(Window_t wid, Atom_t atom, TString &text, Int_t &nchar, Bool_t del)
Gets contents of the paste buffer "atom" into the string "text".
virtual void FillPolygon(Window_t wid, GContext_t gc, Point_t *polygon, Int_t nPoints)
Fills the region closed by the specified path.
virtual void ClearWindow()
Clears the entire area of the current window.
virtual Bool_t NeedRedraw(ULong_t tgwindow, Bool_t force)
Notify the low level GUI layer ROOT requires "tgwindow" to be updated.
void DrawLineAux(Drawable_t wid, const GCValues_t &gcVals, Int_t x1, Int_t y1, Int_t x2, Int_t y2)
virtual void ConvertSelection(Window_t, Atom_t &, Atom_t &, Atom_t &, Time_t &)
Requests that the specified selection be converted to the specified target type.
virtual void ChangeActivePointerGrab(Window_t, UInt_t, Cursor_t)
Changes the specified dynamic parameters if the pointer is actively grabbed by the client and if the ...
virtual void Sync(Int_t mode)
Set synchronisation on or off.
virtual void DestroyWindow(Window_t wid)
Destroys the window "id" as well as all of its subwindows.
virtual Bool_t CheckEvent(Window_t wid, EGEventType type, Event_t &ev)
Check if there is for window "id" an event of type "type".
virtual Double_t GetOpenGLScalingFactor()
On a HiDPI resolution it can be > 1., this means glViewport should use scaled width and height...
const Mask_t kGCLineWidth
void FillRectangleAux(Drawable_t wid, const GCValues_t &gcVals, Int_t x, Int_t y, UInt_t w, UInt_t h)
ROOT::MacOSX::X11::Rectangle GetDisplayGeometry() const
virtual void DeleteProperty(Window_t, Atom_t &)
Deletes the specified property only if the property was defined on the specified window and causes th...
virtual Int_t EventsPending()
Returns the number of events that have been received from the X server but have not been removed from...
virtual void DeleteImage(Drawable_t img)
Deallocates the memory associated with the image img.
const Mask_t kGCGraphicsExposures
virtual Int_t OpenDisplay(const char *displayName)
Opens connection to display server (if such a thing exist on the current platform).
void ReconfigureDisplay()
void DrawPattern(void *data, CGContextRef ctx)
virtual void SelectInput(Window_t wid, UInt_t evmask)
Defines which input events the window is interested in.
virtual void ReparentWindow(Window_t wid, Window_t pid, Int_t x, Int_t y)
If the specified window is mapped, ReparentWindow automatically performs an UnmapWindow request on it...
virtual void UnionRegion(Region_t rega, Region_t regb, Region_t result)
Computes the union of two regions.
virtual Bool_t EqualRegion(Region_t rega, Region_t regb)
Returns kTRUE if the two regions have the same offset, size, and shape.
virtual unsigned char * GetColorBits(Drawable_t wid, Int_t x, Int_t y, UInt_t w, UInt_t h)
Returns an array of pixels created from a part of drawable (defined by x, y, w, h) in format: ...
virtual Window_t GetParent(Window_t wid) const
Returns the parent of the window "id".
NSPoint TranslateFromScreen(NSPoint point, NSView< X11Window > *to)
const NSUInteger kClosableWindowMask
virtual Bool_t AllocColor(Colormap_t cmap, ColorStruct_t &color)
Allocates a read-only colormap entry corresponding to the closest RGB value supported by the hardware...
const NSUInteger kMiniaturizableWindowMask
virtual void XorRegion(Region_t rega, Region_t regb, Region_t result)
Calculates the difference between the union and intersection of two regions.
virtual void SetDNDAware(Window_t, Atom_t *)
Add XdndAware property and the list of drag and drop types to the Window win.
Drawable_t fSelectedDrawable
void CopyAreaAux(Drawable_t src, Drawable_t dst, const GCValues_t &gc, Int_t srcX, Int_t srcY, UInt_t width, UInt_t height, Int_t dstX, Int_t dstY)
int GlobalXROOTToCocoa(CGFloat xROOT)
virtual Visual_t GetVisual() const
Returns handle to visual.
NSPoint TranslateToScreen(NSView< X11Window > *from, NSPoint point)
virtual void NextEvent(Event_t &event)
The "event" is set to default event.
virtual Int_t TextWidth(FontStruct_t font, const char *s, Int_t len)
Return length of the string "s" in pixels. Size depends on font.
Bool_t fGraphicsExposures
int GlobalYCocoaToROOT(CGFloat yCocoa)
virtual void SetKeyAutoRepeat(Bool_t on=kTRUE)
Turns key auto repeat on (kTRUE) or off (kFALSE).
bool ViewIsHtmlViewFrame(NSView< X11Window > *view, bool checkParent)
virtual Bool_t Init(void *display)
Initializes the X system.
virtual void SetTextMagnitude(Float_t mgn)
Sets the current text magnification factor to "mgn".
virtual Int_t GetScreen() const
Returns screen number.
virtual void SetCharacterUp(Float_t chupx, Float_t chupy)
Sets character up vector.
virtual void SetInputFocus(Window_t wid)
Changes the input focus to specified window "id".
R__EXTERN TSystem * gSystem
void DrawStringAux(Drawable_t wid, const GCValues_t &gc, Int_t x, Int_t y, const char *s, Int_t len)
static Atom_t fgDeleteWindowAtom
virtual void GetWindowAttributes(Window_t wid, WindowAttributes_t &attr)
The WindowAttributes_t structure is set to default.
const Mask_t kGCClipXOrigin
virtual FontH_t GetFontHandle(FontStruct_t fs)
Returns the font handle of the specified font structure "fs".
virtual void SubtractRegion(Region_t rega, Region_t regb, Region_t result)
Subtracts regb from rega and stores the results in result.
virtual Int_t GetValue(const char *name, Int_t dflt)
Returns the integer value for a resource.
bool MakeProcessForeground()
virtual char ** ListFonts(const char *fontname, Int_t max, Int_t &count)
Returns list of font names matching fontname regexp, like "-*-times-*".
std::map< Atom_t, Window_t > fSelectionOwners
virtual Bool_t IsDNDAware(Window_t win, Atom_t *typelist)
Checks if the Window is DND aware, and knows any of the DND formats passed in argument.
void ReparentChild(Window_t wid, Window_t pid, Int_t x, Int_t y)
static void update(gsl_integration_workspace *workspace, double a1, double b1, double area1, double error1, double a2, double b2, double area2, double error2)
virtual void SetClassHints(Window_t wid, char *className, char *resourceName)
Sets the windows class and resource name.
virtual Int_t WriteGIF(char *name)
Writes the current window into GIF file.
virtual void QueryPointer(Int_t &x, Int_t &y)
Returns the pointer position.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
virtual Window_t CreateOpenGLWindow(Window_t parentID, UInt_t width, UInt_t height, const std::vector< std::pair< UInt_t, Int_t > > &format)
Create window with special pixel format. Noop everywhere except Cocoa.
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)
ROOT::MacOSX::X11::Rectangle fDisplayRect
virtual void RemoveWindow(ULong_t qwid)
Removes the created by Qt window "qwid".
const Mask_t kGCClipYOrigin
const Mask_t kGCJoinStyle
virtual void SetMWMHints(Window_t winID, UInt_t value, UInt_t decorators, UInt_t inputMode)
Sets decoration style.
virtual void GetFontProperties(FontStruct_t font, Int_t &max_ascent, Int_t &max_descent)
Returns the font properties.
virtual Int_t RequestString(Int_t x, Int_t y, char *text)
Requests string: text is displayed and can be edited with Emacs-like keybinding.
virtual void IntersectRegion(Region_t rega, Region_t regb, Region_t result)
Computes the intersection of two regions.
void UnlockFocus(NSView< X11Window > *view)
virtual void Update(Int_t mode)
Flushes (mode = 0, default) or synchronizes (mode = 1) X output buffer.
void PixelToRGB(Pixel_t pixelColor, CGFloat *rgb)
void Warning(const char *location, const char *msgfmt,...)
virtual void GetCharacterUp(Float_t &chupx, Float_t &chupy)
Returns character up vector.
virtual void FreeColor(Colormap_t cmap, ULong_t pixel)
Frees color cell with specified pixel value.
virtual void PutImage(Drawable_t wid, GContext_t gc, Drawable_t img, Int_t dx, Int_t dy, Int_t x, Int_t y, UInt_t w, UInt_t h)
Combines an image with a rectangle of the specified drawable.
int LocalYROOTToCocoa(NSView< X11Window > *parentView, CGFloat yROOT)
virtual Window_t GetCurrentWindow() const
pointer to the current internal window used in canvas graphics
#define R__LOCKGUARD2(mutex)
virtual void FillRectangle(Drawable_t wid, GContext_t gc, Int_t x, Int_t y, UInt_t w, UInt_t h)
Fills the specified rectangle defined by [x,y] [x+w,y] [x+w,y+h] [x,y+h].
virtual void SetDoubleBufferOFF()
Turns double buffer mode off.
virtual Display_t GetDisplay() const
Returns handle to display (might be useful in some cases where direct X11 manipulation outside of TVi...
virtual void CloseWindow()
Deletes current window.
virtual FontStruct_t LoadQueryFont(const char *font_name)
Provides the most common way for accessing a font: opens (loads) the specified font and returns a poi...
virtual void SetClipRegion(Int_t wid, Int_t x, Int_t y, UInt_t w, UInt_t h)
Sets clipping region for the window "wid".
virtual void ChangeGC(GContext_t gc, GCValues_t *gval)
Changes the components specified by the mask in gval for the specified GC.
static const double x1[5]
QuartzWindow * fMainWindow
virtual Bool_t EmptyRegion(Region_t reg)
Returns kTRUE if the region reg is empty.
const Mask_t kGCFillStyle
virtual ULong_t GetPixel(Color_t cindex)
Returns pixel value associated to specified ROOT color number "cindex".
const Mask_t kStructureNotifyMask
virtual Window_t CreateWindow(Window_t 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)
Creates an unmapped subwindow for a specified parent window and returns the created window...
virtual void SetWindowName(Window_t wid, char *name)
Sets the window name.
virtual void ClosePixmap()
Deletes current pixmap.
virtual Bool_t PointInRegion(Int_t x, Int_t y, Region_t reg)
Returns kTRUE if the point [x, y] is contained in the region reg.
virtual void ClearArea(Window_t wid, Int_t x, Int_t y, UInt_t w, UInt_t h)
Paints a rectangular area in the specified window "id" according to the specified dimensions with the...
virtual Bool_t HasTTFonts() const
Returns True when TrueType fonts are used.
virtual void WritePixmap(Int_t wid, UInt_t w, UInt_t h, char *pxname)
Writes the pixmap "wid" in the bitmap file "pxname".
virtual void PutPixel(Drawable_t wid, Int_t x, Int_t y, ULong_t pixel)
Overwrites the pixel in the image with the specified pixel value.
virtual Pixmap_t ReadGIF(Int_t x0, Int_t y0, const char *file, Window_t wid)
If id is NULL - loads the specified gif file at position [x0,y0] in the current window.
virtual void DestroyRegion(Region_t reg)
Destroys the region "reg".
virtual const char * DisplayName(const char *)
Returns hostname on which the display is opened.
void WindowLostFocus(Window_t winID)
virtual Int_t GetProperty(Window_t, Atom_t, Long_t, Long_t, Bool_t, Atom_t, Atom_t *, Int_t *, ULong_t *, ULong_t *, unsigned char **)
Returns the actual type of the property; the actual format of the property; the number of 8-bit...
you should not use this method at all Int_t Int_t Double_t Double_t Double_t e
virtual void SetWMPosition(Window_t winID, Int_t x, Int_t y)
Tells the window manager the desired position [x,y] of window "id".
const Mask_t kGCForeground
The color creation and management class.
virtual Pixmap_t CreatePixmapFromData(unsigned char *bits, UInt_t width, UInt_t height)
create pixmap from RGB data.
virtual void SetDoubleBuffer(Int_t wid, Int_t mode)
Sets the double buffer on/off on the window "wid".
virtual UInt_t ScreenWidthMM() const
Returns the width of the screen in millimeters.
virtual void RescaleWindow(Int_t wid, UInt_t w, UInt_t h)
Rescales the window "wid".
virtual void ShapeCombineMask(Window_t wid, Int_t x, Int_t y, Pixmap_t mask)
The Non-rectangular Window Shape Extension adds non-rectangular windows to the System.
virtual void GrabButton(Window_t wid, EMouseButton button, UInt_t modifier, UInt_t evmask, Window_t confine, Cursor_t cursor, Bool_t grab=kTRUE)
Establishes a passive grab on a certain mouse button.
virtual void GetWindowSize(Drawable_t wid, Int_t &x, Int_t &y, UInt_t &w, UInt_t &h)
Returns the location and the size of window "id".
NSOpenGLContext * fOpenGLContext
virtual void ChangeProperty(Window_t wid, Atom_t property, Atom_t type, UChar_t *data, Int_t len)
Alters the property for the specified window and causes the X server to generate a PropertyNotify eve...
ROOT::MacOSX::X11::CommandBuffer * GetCommandBuffer() const
virtual void SetWindowBackgroundPixmap(Window_t wid, Pixmap_t pxm)
Sets the background pixmap of the window "id" to the specified pixmap "pxm".
virtual void SetRGB(Int_t cindex, Float_t r, Float_t g, Float_t b)
Sets color intensities the specified color index "cindex".
virtual Int_t OpenPixmap(UInt_t w, UInt_t h)
Creates a pixmap of the width "w" and height "h" you specified.
virtual void SelectPixmap(Int_t qpixid)
Selects the pixmap "qpixid".
virtual void DeleteFont(FontStruct_t fs)
Explicitly deletes the font structure "fs" obtained via LoadQueryFont().
virtual void CopyPixmap(Int_t wid, Int_t xpos, Int_t ypos)
Copies the pixmap "wid" at the position [xpos,ypos] in the current window.
This class implements TVirtualX interface for MacOS X, using Cocoa and Quartz 2D. ...
virtual void SetClipOFF(Int_t wid)
Turns off the clipping for the window "wid".
virtual Bool_t MakeOpenGLContextCurrent(Handle_t ctx, Window_t windowID)
Makes context ctx current OpenGL context.
QuartzView * fContentView
const Mask_t kGCTileStipYOrigin
virtual void UnionRectWithRegion(Rectangle_t *rect, Region_t src, Region_t dest)
Updates the destination region from a union of the specified rectangle and the specified source regio...
const Mask_t kGCSubwindowMode
virtual void TranslateCoordinates(Window_t src, Window_t dest, Int_t src_x, Int_t src_y, Int_t &dest_x, Int_t &dest_y, Window_t &child)
Translates coordinates in one window to the coordinate space of another window.
virtual void ChangeProperties(Window_t wid, Atom_t property, Atom_t type, Int_t format, UChar_t *data, Int_t len)
Alters the property for the specified window and causes the X server to generate a PropertyNotify eve...
virtual void LowerWindow(Window_t wid)
Lowers the specified window "id" to the bottom of the stack so that it does not obscure any sibling w...
const Mask_t kGCBackground
virtual void DrawSegments(Drawable_t wid, GContext_t gc, Segment_t *segments, Int_t nSegments)
Draws multiple line segments.
const Mask_t kGCTileStipXOrigin
virtual void SetWMTransientHint(Window_t winID, Window_t mainWinID)
Tells window manager that the window "id" is a transient window of the window "main_id".
virtual void GetRGB(Int_t index, Float_t &r, Float_t &g, Float_t &b)
Returns RGB values for color "index".
virtual void DestroySubwindows(Window_t wid)
The DestroySubwindows function destroys all inferior windows of the specified window, in bottom-to-top stacking order.
std::vector< std::string > fAtomToName
virtual Region_t PolygonRegion(Point_t *points, Int_t np, Bool_t winding)
Returns a region for the polygon defined by the points array.
virtual Colormap_t GetColormap() const
Returns handle to colormap.
virtual Cursor_t CreateCursor(ECursor cursor)
Creates the specified cursor.
virtual void FlushOpenGLBuffer(Handle_t ctxID)
Flushes OpenGL buffer.
virtual void LookupString(Event_t *event, char *buf, Int_t buflen, UInt_t &keysym)
Converts the keycode from the event structure to a key symbol (according to the modifiers specified i...
virtual void SetPrimarySelectionOwner(Window_t wid)
Makes the window "id" the current owner of the primary selection.
virtual void SendEvent(Window_t wid, Event_t *ev)
Specifies the event "ev" is to be sent to the window "id".
virtual void WMDeleteNotify(Window_t wid)
Tells WM to send message when window is closed via WM.
void FillPolygonAux(Window_t wid, const GCValues_t &gcVals, const Point_t *polygon, Int_t nPoints)
virtual void DeletePictureData(void *data)
Delete picture data created by the function ReadPictureDataFromFile.
virtual void FreeFontStruct(FontStruct_t fs)
Frees the font structure "fs".
virtual void DrawString(Drawable_t wid, GContext_t gc, Int_t x, Int_t y, const char *s, Int_t len)
Each character image, as defined by the font in the GC, is treated as an additional mask for a fill o...
virtual void Warp(Int_t ix, Int_t iy, Window_t wid)
Sets the pointer position.
bool ViewIsTextViewFrame(NSView< X11Window > *view, bool checkParent)
virtual Handle_t GetNativeEvent() const
Returns the current native event handle.
void DrawTextLineNoKerning(CGContextRef ctx, CTFontRef font, const std::vector< UniChar > &text, Int_t x, Int_t y)
virtual Window_t GetPrimarySelectionOwner()
Returns the window id of the current owner of the primary selection.
virtual Int_t InitWindow(ULong_t window)
Creates a new window and return window number.
virtual void DeleteGC(GContext_t gc)
Deletes the specified GC "gc".
virtual void GetGeometry(Int_t wid, Int_t &x, Int_t &y, UInt_t &w, UInt_t &h)
Returns position and size of window "wid".
ROOT::MacOSX::X11::EventTranslator * GetEventTranslator() const
virtual Handle_t GetCurrentOpenGLContext()
Asks OpenGL subsystem about the current OpenGL context.
Bool_t IsCocoaDraw() const
virtual UInt_t ExecCommand(TGWin32Command *code)
Executes the command "code" coming from the other threads (Win32)
virtual Int_t GetDoubleBuffer(Int_t wid)
Queries the double buffer value for the window "wid".
void * GetCurrentContext()
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
const Mask_t kGCPlaneMask
virtual Bool_t CreatePictureFromData(Drawable_t wid, char **data, Pixmap_t &pict, Pixmap_t &pict_mask, PictureAttributes_t &attr)
Creates a picture pict from data in bitmap format.
if(line.BeginsWith("/*"))
virtual void SetForeground(GContext_t gc, ULong_t foreground)
Sets the foreground color for the specified GC (shortcut for ChangeGC with only foreground mask set)...
virtual Pixmap_t CreateBitmap(Drawable_t wid, const char *bitmap, UInt_t width, UInt_t height)
Creates a bitmap (i.e.