Blender  V3.3
GHOST_WindowCocoa.mm
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2001-2002 NaN Holding BV. All rights reserved. */
3 
4 #include "GHOST_WindowCocoa.h"
5 #include "GHOST_ContextNone.h"
6 #include "GHOST_Debug.h"
7 #include "GHOST_SystemCocoa.h"
8 
9 #include "GHOST_ContextCGL.h"
10 
11 #include <Cocoa/Cocoa.h>
12 #include <Metal/Metal.h>
13 #include <QuartzCore/QuartzCore.h>
14 
15 #include <sys/sysctl.h>
16 
17 #pragma mark Cocoa window delegate object
18 
19 @interface CocoaWindowDelegate : NSObject <NSWindowDelegate>
20 {
23 }
24 
25 - (void)setSystemAndWindowCocoa:(GHOST_SystemCocoa *)sysCocoa
26  windowCocoa:(GHOST_WindowCocoa *)winCocoa;
27 - (void)windowDidBecomeKey:(NSNotification *)notification;
28 - (void)windowDidResignKey:(NSNotification *)notification;
29 - (void)windowDidExpose:(NSNotification *)notification;
30 - (void)windowDidResize:(NSNotification *)notification;
31 - (void)windowDidMove:(NSNotification *)notification;
32 - (void)windowWillMove:(NSNotification *)notification;
33 - (BOOL)windowShouldClose:(id)sender;
34 - (void)windowDidChangeBackingProperties:(NSNotification *)notification;
35 @end
36 
37 @implementation CocoaWindowDelegate : NSObject
38 - (void)setSystemAndWindowCocoa:(GHOST_SystemCocoa *)sysCocoa
39  windowCocoa:(GHOST_WindowCocoa *)winCocoa
40 {
41  systemCocoa = sysCocoa;
42  associatedWindow = winCocoa;
43 }
44 
45 - (void)windowDidBecomeKey:(NSNotification *)notification
46 {
48  // work around for broken appswitching when combining cmd-tab and missioncontrol
49  [(NSWindow *)associatedWindow->getOSWindow() orderFrontRegardless];
50 }
51 
52 - (void)windowDidResignKey:(NSNotification *)notification
53 {
55 }
56 
57 - (void)windowDidExpose:(NSNotification *)notification
58 {
60 }
61 
62 - (void)windowDidMove:(NSNotification *)notification
63 {
65 }
66 
67 - (void)windowWillMove:(NSNotification *)notification
68 {
70 }
71 
72 - (void)windowWillEnterFullScreen:(NSNotification *)notification
73 {
75 }
76 
77 - (void)windowDidEnterFullScreen:(NSNotification *)notification
78 {
79  /* macOS does not send a window resize event when switching between zoomed
80  * and fullscreen, when automatic show/hide of dock and menu bar are enabled.
81  * Send our own to prevent artifacts. */
83 
85 }
86 
87 - (void)windowWillExitFullScreen:(NSNotification *)notification
88 {
90 }
91 
92 - (void)windowDidExitFullScreen:(NSNotification *)notification
93 {
94  /* See comment for windowWillEnterFullScreen. */
97 }
98 
99 - (void)windowDidResize:(NSNotification *)notification
100 {
101  // if (![[notification object] inLiveResize]) {
102  // Send event only once, at end of resize operation (when user has released mouse button)
104  //}
105  /* Live resize, send event, gets handled in wm_window.c.
106  * Needed because live resize runs in a modal loop, not letting main loop run */
107  if ([[notification object] inLiveResize]) {
109  }
110 }
111 
112 - (void)windowDidChangeBackingProperties:(NSNotification *)notification
113 {
116 }
117 
118 - (BOOL)windowShouldClose:(id)sender;
119 {
120  // Let Blender close the window rather than closing immediately
122  return false;
123 }
124 
125 @end
126 
127 #pragma mark NSWindow subclass
128 // We need to subclass it to tell that even borderless (fullscreen),
129 // it can become key (receive user events)
130 @interface CocoaWindow : NSWindow
131 {
135 }
136 - (void)setSystemAndWindowCocoa:(GHOST_SystemCocoa *)sysCocoa
137  windowCocoa:(GHOST_WindowCocoa *)winCocoa;
138 - (GHOST_SystemCocoa *)systemCocoa;
139 @end
140 
141 @implementation CocoaWindow
142 - (void)setSystemAndWindowCocoa:(GHOST_SystemCocoa *)sysCocoa
143  windowCocoa:(GHOST_WindowCocoa *)winCocoa
144 {
145  systemCocoa = sysCocoa;
146  associatedWindow = winCocoa;
147 }
149 {
150  return systemCocoa;
151 }
152 
153 - (BOOL)canBecomeKeyWindow
154 {
155  /* Don't make other windows active when a dialog window is open. */
157 }
158 
159 // The drag'n'drop dragging destination methods
160 - (NSDragOperation)draggingEntered:(id<NSDraggingInfo>)sender
161 {
162  NSPoint mouseLocation = [sender draggingLocation];
163  NSPasteboard *draggingPBoard = [sender draggingPasteboard];
164 
165  if ([[draggingPBoard types] containsObject:NSTIFFPboardType])
167  else if ([[draggingPBoard types] containsObject:NSFilenamesPboardType])
169  else if ([[draggingPBoard types] containsObject:NSStringPboardType])
171  else
172  return NSDragOperationNone;
173 
174  associatedWindow->setAcceptDragOperation(TRUE); // Drag operation is accepted by default
178  mouseLocation.x,
179  mouseLocation.y,
180  nil);
181  return NSDragOperationCopy;
182 }
183 
184 - (BOOL)wantsPeriodicDraggingUpdates
185 {
186  return NO; // No need to overflow blender event queue. Events shall be sent only on changes
187 }
188 
189 - (NSDragOperation)draggingUpdated:(id<NSDraggingInfo>)sender
190 {
191  NSPoint mouseLocation = [sender draggingLocation];
192 
196  mouseLocation.x,
197  mouseLocation.y,
198  nil);
199  return associatedWindow->canAcceptDragOperation() ? NSDragOperationCopy : NSDragOperationNone;
200 }
201 
202 - (void)draggingExited:(id<NSDraggingInfo>)sender
203 {
207 }
208 
209 - (BOOL)prepareForDragOperation:(id<NSDraggingInfo>)sender
210 {
212  return YES;
213  else
214  return NO;
215 }
216 
217 - (BOOL)performDragOperation:(id<NSDraggingInfo>)sender
218 {
219  NSPoint mouseLocation = [sender draggingLocation];
220  NSPasteboard *draggingPBoard = [sender draggingPasteboard];
221  NSImage *droppedImg;
222  id data;
223 
224  switch (m_draggedObjectType) {
226  if ([NSImage canInitWithPasteboard:draggingPBoard]) {
227  droppedImg = [[NSImage alloc] initWithPasteboard:draggingPBoard];
228  data = droppedImg; //[draggingPBoard dataForType:NSTIFFPboardType];
229  }
230  else
231  return NO;
232  break;
234  data = [draggingPBoard propertyListForType:NSFilenamesPboardType];
235  break;
237  data = [draggingPBoard stringForType:NSStringPboardType];
238  break;
239  default:
240  return NO;
241  break;
242  }
246  mouseLocation.x,
247  mouseLocation.y,
248  (void *)data);
249  return YES;
250 }
251 
252 @end
253 
254 /* NSView for handling input and drawing. */
255 #define COCOA_VIEW_CLASS CocoaOpenGLView
256 #define COCOA_VIEW_BASE_CLASS NSOpenGLView
257 #include "GHOST_WindowViewCocoa.h"
258 #undef COCOA_VIEW_CLASS
259 #undef COCOA_VIEW_BASE_CLASS
260 
261 #define COCOA_VIEW_CLASS CocoaMetalView
262 #define COCOA_VIEW_BASE_CLASS NSView
264 #undef COCOA_VIEW_CLASS
265 #undef COCOA_VIEW_BASE_CLASS
266 
267 #pragma mark initialization / finalization
268 
270  const char *title,
271  int32_t left,
272  int32_t bottom,
273  uint32_t width,
277  const bool stereoVisual,
278  bool is_debug,
279  bool is_dialog,
280  GHOST_WindowCocoa *parentWindow)
281  : GHOST_Window(width, height, state, stereoVisual, false),
282  m_openGLView(nil),
283  m_metalView(nil),
284  m_metalLayer(nil),
285  m_systemCocoa(systemCocoa),
286  m_customCursor(0),
287  m_immediateDraw(false),
288  m_debug_context(is_debug),
289  m_is_dialog(is_dialog)
290 {
291  m_fullScreen = false;
292 
293  NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
294 
295  // Creates the window
296  NSRect rect;
297  NSSize minSize;
298 
299  rect.origin.x = left;
300  rect.origin.y = bottom;
301  rect.size.width = width;
302  rect.size.height = height;
303 
304  NSWindowStyleMask styleMask = NSWindowStyleMaskTitled | NSWindowStyleMaskClosable |
305  NSWindowStyleMaskResizable;
306  if (!is_dialog) {
307  styleMask |= NSWindowStyleMaskMiniaturizable;
308  }
309 
310  m_window = [[CocoaWindow alloc] initWithContentRect:rect
311  styleMask:styleMask
312  backing:NSBackingStoreBuffered
313  defer:NO];
314 
315  [m_window setSystemAndWindowCocoa:systemCocoa windowCocoa:this];
316 
317  // Forbid to resize the window below the blender defined minimum one
318  minSize.width = 320;
319  minSize.height = 240;
320  [m_window setContentMinSize:minSize];
321 
322  // Create NSView inside the window
323  id<MTLDevice> metalDevice = MTLCreateSystemDefaultDevice();
324  NSView *view;
325 
326  if (metalDevice) {
327  // Create metal layer and view if supported
328  m_metalLayer = [[CAMetalLayer alloc] init];
329  [m_metalLayer setEdgeAntialiasingMask:0];
330  [m_metalLayer setMasksToBounds:NO];
331  [m_metalLayer setOpaque:YES];
332  [m_metalLayer setFramebufferOnly:YES];
333  [m_metalLayer setPresentsWithTransaction:NO];
334  [m_metalLayer removeAllAnimations];
335  [m_metalLayer setDevice:metalDevice];
336 
337  m_metalView = [[CocoaMetalView alloc] initWithFrame:rect];
338  [m_metalView setWantsLayer:YES];
339  [m_metalView setLayer:m_metalLayer];
340  [m_metalView setSystemAndWindowCocoa:systemCocoa windowCocoa:this];
341  view = m_metalView;
342  }
343  else {
344  // Fallback to OpenGL view if there is no Metal support
345  m_openGLView = [[CocoaOpenGLView alloc] initWithFrame:rect];
346  [m_openGLView setSystemAndWindowCocoa:systemCocoa windowCocoa:this];
347  view = m_openGLView;
348  }
349 
351  // Needs to happen early when building with the 10.14 SDK, otherwise
352  // has no effect until resizeing the window.
353  if ([view respondsToSelector:@selector(setWantsBestResolutionOpenGLSurface:)]) {
354  [view setWantsBestResolutionOpenGLSurface:YES];
355  }
356  }
357 
358  [m_window setContentView:view];
359  [m_window setInitialFirstResponder:view];
360 
361  [m_window makeKeyAndOrderFront:nil];
362 
366 
367  setTitle(title);
368 
370 
371  CocoaWindowDelegate *windowDelegate = [[CocoaWindowDelegate alloc] init];
372  [windowDelegate setSystemAndWindowCocoa:systemCocoa windowCocoa:this];
373  [m_window setDelegate:windowDelegate];
374 
375  [m_window setAcceptsMouseMovedEvents:YES];
376 
377  NSView *contentview = [m_window contentView];
378  [contentview setAllowedTouchTypes:(NSTouchTypeMaskDirect | NSTouchTypeMaskIndirect)];
379 
380  [m_window registerForDraggedTypes:[NSArray arrayWithObjects:NSFilenamesPboardType,
381  NSStringPboardType,
382  NSTIFFPboardType,
383  nil]];
384 
385  if (is_dialog && parentWindow) {
386  [parentWindow->getCocoaWindow() addChildWindow:m_window ordered:NSWindowAbove];
387  [m_window setCollectionBehavior:NSWindowCollectionBehaviorFullScreenAuxiliary];
388  }
389  else {
390  [m_window setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
391  }
392 
395 
397 
398  [pool drain];
399 }
400 
402 {
403  NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
404 
405  if (m_customCursor) {
406  [m_customCursor release];
407  m_customCursor = nil;
408  }
409 
411 
412  if (m_openGLView) {
413  [m_openGLView release];
414  m_openGLView = nil;
415  }
416  if (m_metalView) {
417  [m_metalView release];
418  m_metalView = nil;
419  }
420  if (m_metalLayer) {
421  [m_metalLayer release];
422  m_metalLayer = nil;
423  }
424 
425  if (m_window) {
426  [m_window close];
427  }
428 
429  /* Check for other blender opened windows and make the front-most key
430  * NOTE: for some reason the closed window is still in the list. */
431  NSArray *windowsList = [NSApp orderedWindows];
432  for (int a = 0; a < [windowsList count]; a++) {
433  if (m_window != (CocoaWindow *)[windowsList objectAtIndex:a]) {
434  [[windowsList objectAtIndex:a] makeKeyWindow];
435  break;
436  }
437  }
438  m_window = nil;
439 
440  [pool drain];
441 }
442 
443 #pragma mark accessors
444 
445 bool GHOST_WindowCocoa::getValid() const
446 {
447  NSView *view = (m_openGLView) ? m_openGLView : m_metalView;
448  return GHOST_Window::getValid() && m_window != NULL && view != NULL;
449 }
450 
451 void *GHOST_WindowCocoa::getOSWindow() const
452 {
453  return (void *)m_window;
454 }
455 
456 void GHOST_WindowCocoa::setTitle(const char *title)
457 {
458  GHOST_ASSERT(getValid(), "GHOST_WindowCocoa::setTitle(): window invalid");
459  NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
460 
461  NSString *windowTitle = [[NSString alloc] initWithCString:title encoding:NSUTF8StringEncoding];
462 
463  // Set associated file if applicable
464  if (windowTitle && [windowTitle hasPrefix:@"Blender"]) {
465  NSRange fileStrRange;
466  NSString *associatedFileName;
467  int len;
468 
469  fileStrRange.location = [windowTitle rangeOfString:@"["].location + 1;
470  len = [windowTitle rangeOfString:@"]"].location - fileStrRange.location;
471 
472  if (len > 0) {
473  fileStrRange.length = len;
474  associatedFileName = [windowTitle substringWithRange:fileStrRange];
475  [m_window setTitle:[associatedFileName lastPathComponent]];
476 
477  @try {
478  [m_window setRepresentedFilename:associatedFileName];
479  }
480  @catch (NSException *e) {
481  printf("\nInvalid file path given in window title");
482  }
483  }
484  else {
485  [m_window setTitle:windowTitle];
486  [m_window setRepresentedFilename:@""];
487  }
488  }
489  else {
490  [m_window setTitle:windowTitle];
491  [m_window setRepresentedFilename:@""];
492  }
493 
494  [windowTitle release];
495  [pool drain];
496 }
497 
498 std::string GHOST_WindowCocoa::getTitle() const
499 {
500  GHOST_ASSERT(getValid(), "GHOST_WindowCocoa::getTitle(): window invalid");
501 
502  NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
503 
504  NSString *windowTitle = [m_window title];
505 
506  std::string title;
507  if (windowTitle != nil) {
508  title = [windowTitle UTF8String];
509  }
510 
511  [pool drain];
512 
513  return title;
514 }
515 
517 {
518  NSRect rect;
519  GHOST_ASSERT(getValid(), "GHOST_WindowCocoa::getWindowBounds(): window invalid");
520 
521  NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
522 
523  NSRect screenSize = [[m_window screen] visibleFrame];
524 
525  rect = [m_window frame];
526 
527  bounds.m_b = screenSize.size.height - (rect.origin.y - screenSize.origin.y);
528  bounds.m_l = rect.origin.x - screenSize.origin.x;
529  bounds.m_r = rect.origin.x - screenSize.origin.x + rect.size.width;
530  bounds.m_t = screenSize.size.height - (rect.origin.y + rect.size.height - screenSize.origin.y);
531 
532  [pool drain];
533 }
534 
536 {
537  NSRect rect;
538  GHOST_ASSERT(getValid(), "GHOST_WindowCocoa::getClientBounds(): window invalid");
539 
540  NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
541 
542  NSRect screenSize = [[m_window screen] visibleFrame];
543 
544  // Max window contents as screen size (excluding title bar...)
545  NSRect contentRect = [CocoaWindow contentRectForFrameRect:screenSize
546  styleMask:[m_window styleMask]];
547 
548  rect = [m_window contentRectForFrameRect:[m_window frame]];
549 
550  bounds.m_b = contentRect.size.height - (rect.origin.y - contentRect.origin.y);
551  bounds.m_l = rect.origin.x - contentRect.origin.x;
552  bounds.m_r = rect.origin.x - contentRect.origin.x + rect.size.width;
553  bounds.m_t = contentRect.size.height - (rect.origin.y + rect.size.height - contentRect.origin.y);
554  [pool drain];
555 }
556 
558 {
559  GHOST_ASSERT(getValid(), "GHOST_WindowCocoa::setClientWidth(): window invalid");
560  NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
561  GHOST_Rect cBnds, wBnds;
562  getClientBounds(cBnds);
563  if (((uint32_t)cBnds.getWidth()) != width) {
564  NSSize size;
565  size.width = width;
566  size.height = cBnds.getHeight();
567  [m_window setContentSize:size];
568  }
569  [pool drain];
570  return GHOST_kSuccess;
571 }
572 
574 {
575  GHOST_ASSERT(getValid(), "GHOST_WindowCocoa::setClientHeight(): window invalid");
576  NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
577  GHOST_Rect cBnds, wBnds;
578  getClientBounds(cBnds);
579  if (((uint32_t)cBnds.getHeight()) != height) {
580  NSSize size;
581  size.width = cBnds.getWidth();
582  size.height = height;
583  [m_window setContentSize:size];
584  }
585  [pool drain];
586  return GHOST_kSuccess;
587 }
588 
590 {
591  GHOST_ASSERT(getValid(), "GHOST_WindowCocoa::setClientSize(): window invalid");
592  NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
593  GHOST_Rect cBnds, wBnds;
594  getClientBounds(cBnds);
595  if ((((uint32_t)cBnds.getWidth()) != width) || (((uint32_t)cBnds.getHeight()) != height)) {
596  NSSize size;
597  size.width = width;
598  size.height = height;
599  [m_window setContentSize:size];
600  }
601  [pool drain];
602  return GHOST_kSuccess;
603 }
604 
606 {
607  GHOST_ASSERT(getValid(), "GHOST_WindowCocoa::getState(): window invalid");
608  NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
610 
611  NSUInteger masks = [m_window styleMask];
612 
613  if (masks & NSWindowStyleMaskFullScreen) {
614  // Lion style fullscreen
615  if (!m_immediateDraw) {
617  }
618  else {
620  }
621  }
622  else if ([m_window isMiniaturized]) {
624  }
625  else if ([m_window isZoomed]) {
627  }
628  else {
629  if (m_immediateDraw) {
631  }
632  else {
634  }
635  }
636  [pool drain];
637  return state;
638 }
639 
641  int32_t inY,
642  int32_t &outX,
643  int32_t &outY) const
644 {
645  GHOST_ASSERT(getValid(), "GHOST_WindowCocoa::screenToClient(): window invalid");
646 
647  screenToClientIntern(inX, inY, outX, outY);
648 
649  /* switch y to match ghost convention */
650  GHOST_Rect cBnds;
651  getClientBounds(cBnds);
652  outY = (cBnds.getHeight() - 1) - outY;
653 }
654 
656  int32_t inY,
657  int32_t &outX,
658  int32_t &outY) const
659 {
660  GHOST_ASSERT(getValid(), "GHOST_WindowCocoa::clientToScreen(): window invalid");
661 
662  /* switch y to match ghost convention */
663  GHOST_Rect cBnds;
664  getClientBounds(cBnds);
665  inY = (cBnds.getHeight() - 1) - inY;
666 
667  clientToScreenIntern(inX, inY, outX, outY);
668 }
669 
671  int32_t inY,
672  int32_t &outX,
673  int32_t &outY) const
674 {
675  NSRect screenCoord;
676  NSRect baseCoord;
677 
678  screenCoord.origin.x = inX;
679  screenCoord.origin.y = inY;
680 
681  baseCoord = [m_window convertRectFromScreen:screenCoord];
682 
683  outX = baseCoord.origin.x;
684  outY = baseCoord.origin.y;
685 }
686 
688  int32_t inY,
689  int32_t &outX,
690  int32_t &outY) const
691 {
692  NSRect screenCoord;
693  NSRect baseCoord;
694 
695  baseCoord.origin.x = inX;
696  baseCoord.origin.y = inY;
697 
698  screenCoord = [m_window convertRectToScreen:baseCoord];
699 
700  outX = screenCoord.origin.x;
701  outY = screenCoord.origin.y;
702 }
703 
705 {
706  return [m_window screen];
707 }
708 
709 /* called for event, when window leaves monitor to another */
711 {
712  NSView *view = (m_openGLView) ? m_openGLView : m_metalView;
713  NSRect backingBounds = [view convertRectToBacking:[view bounds]];
714 
715  GHOST_Rect rect;
716  getClientBounds(rect);
717 
718  m_nativePixelSize = (float)backingBounds.size.width / (float)rect.getWidth();
719 }
720 
729 {
730  GHOST_ASSERT(getValid(), "GHOST_WindowCocoa::setState(): window invalid");
731  switch (state) {
733  [m_window miniaturize:nil];
734  break;
736  [m_window zoom:nil];
737  break;
738 
740  NSUInteger masks = [m_window styleMask];
741 
742  if (!(masks & NSWindowStyleMaskFullScreen)) {
743  [m_window toggleFullScreen:nil];
744  }
745  break;
746  }
748  default:
749  NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
750  NSUInteger masks = [m_window styleMask];
751 
752  if (masks & NSWindowStyleMaskFullScreen) {
753  // Lion style fullscreen
754  [m_window toggleFullScreen:nil];
755  }
756  else if ([m_window isMiniaturized])
757  [m_window deminiaturize:nil];
758  else if ([m_window isZoomed])
759  [m_window zoom:nil];
760  [pool drain];
761  break;
762  }
763 
764  return GHOST_kSuccess;
765 }
766 
768 {
769  NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
770 
771  [m_window setDocumentEdited:isUnsavedChanges];
772 
773  [pool drain];
774  return GHOST_Window::setModifiedState(isUnsavedChanges);
775 }
776 
778 {
779  NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
780 
781  GHOST_ASSERT(getValid(), "GHOST_WindowCocoa::setOrder(): window invalid");
782  if (order == GHOST_kWindowOrderTop) {
783  [NSApp activateIgnoringOtherApps:YES];
784  [m_window makeKeyAndOrderFront:nil];
785  }
786  else {
787  NSArray *windowsList;
788 
789  [m_window orderBack:nil];
790 
791  // Check for other blender opened windows and make the frontmost key
792  windowsList = [NSApp orderedWindows];
793  if ([windowsList count]) {
794  [[windowsList objectAtIndex:0] makeKeyAndOrderFront:nil];
795  }
796  }
797 
798  [pool drain];
799  return GHOST_kSuccess;
800 }
801 
802 #pragma mark Drawing context
803 
805 {
807 
810 
811  if (context->initializeDrawingContext())
812  return context;
813  else
814  delete context;
815  }
816 
817  return NULL;
818 }
819 
820 #pragma mark invalidate
821 
823 {
824  GHOST_ASSERT(getValid(), "GHOST_WindowCocoa::invalidate(): window invalid");
825  NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
826  NSView *view = (m_openGLView) ? m_openGLView : m_metalView;
827  [view setNeedsDisplay:YES];
828  [pool drain];
829  return GHOST_kSuccess;
830 }
831 
832 #pragma mark Progress bar
833 
835 {
836  NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
837 
838  if ((progress >= 0.0) && (progress <= 1.0)) {
839  NSImage *dockIcon = [[NSImage alloc] initWithSize:NSMakeSize(128, 128)];
840 
841  [dockIcon lockFocus];
842 
843  [[NSImage imageNamed:@"NSApplicationIcon"] drawAtPoint:NSZeroPoint
844  fromRect:NSZeroRect
845  operation:NSCompositingOperationSourceOver
846  fraction:1.0];
847 
848  NSRect progressRect = {{8, 8}, {112, 14}};
849  NSBezierPath *progressPath;
850 
851  /* Draw white track. */
852  [[[NSColor whiteColor] colorWithAlphaComponent:0.6] setFill];
853  progressPath = [NSBezierPath bezierPathWithRoundedRect:progressRect xRadius:7 yRadius:7];
854  [progressPath fill];
855 
856  /* Black progress fill. */
857  [[[NSColor blackColor] colorWithAlphaComponent:0.7] setFill];
858  progressRect = NSInsetRect(progressRect, 2, 2);
859  progressRect.size.width *= progress;
860  progressPath = [NSBezierPath bezierPathWithRoundedRect:progressRect xRadius:5 yRadius:5];
861  [progressPath fill];
862 
863  [dockIcon unlockFocus];
864 
865  [NSApp setApplicationIconImage:dockIcon];
866  [dockIcon release];
867 
868  m_progressBarVisible = true;
869  }
870 
871  [pool drain];
872  return GHOST_kSuccess;
873 }
874 
875 static void postNotification()
876 {
877  NSUserNotification *notification = [[NSUserNotification alloc] init];
878  notification.title = @"Blender Progress Notification";
879  notification.informativeText = @"Calculation is finished.";
880  notification.soundName = NSUserNotificationDefaultSoundName;
881  [[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification:notification];
882  [notification release];
883 }
884 
886 {
888  return GHOST_kFailure;
889  m_progressBarVisible = false;
890 
891  NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
892 
893  NSImage *dockIcon = [[NSImage alloc] initWithSize:NSMakeSize(128, 128)];
894  [dockIcon lockFocus];
895  [[NSImage imageNamed:@"NSApplicationIcon"] drawAtPoint:NSZeroPoint
896  fromRect:NSZeroRect
897  operation:NSCompositingOperationSourceOver
898  fraction:1.0];
899  [dockIcon unlockFocus];
900  [NSApp setApplicationIconImage:dockIcon];
901 
902  // We use notifications to inform the user when the progress reached 100%
903  // Atm. just fire this when the progressbar ends, the behavior is controlled
904  // in the NotificationCenter If Blender is not frontmost window, a message
905  // pops up with sound, in any case an entry in notifications
906  if ([NSUserNotificationCenter respondsToSelector:@selector(defaultUserNotificationCenter)]) {
908  }
909 
910  [dockIcon release];
911 
912  [pool drain];
913  return GHOST_kSuccess;
914 }
915 
916 #pragma mark Cursor handling
917 
918 static NSCursor *getImageCursor(GHOST_TStandardCursor shape, NSString *name, NSPoint hotspot)
919 {
920  static NSCursor *cursors[(int)GHOST_kStandardCursorNumCursors] = {0};
921  static bool loaded[(int)GHOST_kStandardCursorNumCursors] = {false};
922 
923  const int index = (int)shape;
924  if (!loaded[index]) {
925  /* Load image from file in application Resources folder. */
926  /* clang-format off */
927  @autoreleasepool {
928  /* clang-format on */
929  NSImage *image = [NSImage imageNamed:name];
930  if (image != NULL) {
931  cursors[index] = [[NSCursor alloc] initWithImage:image hotSpot:hotspot];
932  }
933  }
934 
935  loaded[index] = true;
936  }
937 
938  return cursors[index];
939 }
940 
942 {
943  switch (shape) {
945  if (m_customCursor) {
946  return m_customCursor;
947  }
948  else {
949  return NULL;
950  }
952  return [NSCursor disappearingItemCursor];
954  return [NSCursor IBeamCursor];
956  return [NSCursor crosshairCursor];
958  return [NSCursor resizeUpDownCursor];
960  return [NSCursor resizeLeftRightCursor];
962  return [NSCursor resizeUpCursor];
964  return [NSCursor resizeDownCursor];
966  return [NSCursor resizeLeftCursor];
968  return [NSCursor resizeRightCursor];
970  return [NSCursor dragCopyCursor];
972  return [NSCursor operationNotAllowedCursor];
974  return [NSCursor pointingHandCursor];
976  return [NSCursor arrowCursor];
978  return getImageCursor(shape, @"knife.pdf", NSMakePoint(6, 24));
980  return getImageCursor(shape, @"eraser.pdf", NSMakePoint(6, 24));
982  return getImageCursor(shape, @"pen.pdf", NSMakePoint(6, 24));
984  return getImageCursor(shape, @"eyedropper.pdf", NSMakePoint(6, 24));
986  return getImageCursor(shape, @"zoomin.pdf", NSMakePoint(8, 7));
988  return getImageCursor(shape, @"zoomout.pdf", NSMakePoint(8, 7));
990  return getImageCursor(shape, @"scrollnsew.pdf", NSMakePoint(16, 16));
992  return getImageCursor(shape, @"scrollns.pdf", NSMakePoint(16, 16));
994  return getImageCursor(shape, @"scrollew.pdf", NSMakePoint(16, 16));
996  return getImageCursor(shape, @"arrowup.pdf", NSMakePoint(16, 16));
998  return getImageCursor(shape, @"arrowdown.pdf", NSMakePoint(16, 16));
1000  return getImageCursor(shape, @"arrowleft.pdf", NSMakePoint(16, 16));
1002  return getImageCursor(shape, @"arrowright.pdf", NSMakePoint(16, 16));
1004  return getImageCursor(shape, @"splitv.pdf", NSMakePoint(16, 16));
1006  return getImageCursor(shape, @"splith.pdf", NSMakePoint(16, 16));
1008  return getImageCursor(shape, @"paint_cursor_cross.pdf", NSMakePoint(16, 15));
1010  return getImageCursor(shape, @"paint_cursor_dot.pdf", NSMakePoint(16, 15));
1012  return getImageCursor(shape, @"crossc.pdf", NSMakePoint(16, 16));
1013  default:
1014  return NULL;
1015  }
1016 }
1017 
1018 void GHOST_WindowCocoa::loadCursor(bool visible, GHOST_TStandardCursor shape) const
1020  static bool systemCursorVisible = true;
1021  if (visible != systemCursorVisible) {
1022  if (visible) {
1023  [NSCursor unhide];
1024  systemCursorVisible = true;
1025  }
1026  else {
1027  [NSCursor hide];
1028  systemCursorVisible = false;
1029  }
1030  }
1031 
1032  NSCursor *cursor = getStandardCursor(shape);
1033  if (cursor == NULL) {
1035  }
1036 
1037  [cursor set];
1038 }
1039 
1040 bool GHOST_WindowCocoa::isDialog() const
1042  return m_is_dialog;
1043 }
1044 
1047  NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
1048 
1049  if ([m_window isVisible]) {
1050  loadCursor(visible, getCursorShape());
1051  }
1052 
1053  [pool drain];
1054  return GHOST_kSuccess;
1055 }
1056 
1060 
1061  if (mode != GHOST_kGrabDisable) {
1062  // No need to perform grab without warp as it is always on in OS X
1063  if (mode != GHOST_kGrabNormal) {
1064  NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
1065 
1067  setCursorGrabAccum(0, 0);
1068 
1069  if (mode == GHOST_kGrabHide) {
1071  }
1072 
1073  // Make window key if it wasn't to get the mouse move events
1074  [m_window makeKeyWindow];
1075 
1076  [pool drain];
1077  }
1078  }
1079  else {
1080  if (m_cursorGrab == GHOST_kGrabHide) {
1083  }
1084 
1085  /* Almost works without but important otherwise the mouse GHOST location
1086  * can be incorrect on exit. */
1087  setCursorGrabAccum(0, 0);
1088  m_cursorGrabBounds.m_l = m_cursorGrabBounds.m_r = -1; /* disable */
1089  }
1090  return err;
1091 }
1092 
1095  NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
1096 
1097  if ([m_window isVisible]) {
1098  loadCursor(getCursorVisibility(), shape);
1099  }
1100 
1101  [pool drain];
1102  return GHOST_kSuccess;
1103 }
1104 
1107  NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
1109  [pool drain];
1110  return success;
1111 }
1112 
1113 /* Reverse the bits in a uint8_t */
1114 #if 0
1115 static uint8_t uns8ReverseBits(uint8_t ch)
1116 {
1117  ch= ((ch >> 1) & 0x55) | ((ch << 1) & 0xAA);
1118  ch= ((ch >> 2) & 0x33) | ((ch << 2) & 0xCC);
1119  ch= ((ch >> 4) & 0x0F) | ((ch << 4) & 0xF0);
1120  return ch;
1121 }
1122 #endif
1123 
1125 static uint16_t uns16ReverseBits(uint16_t shrt)
1127  shrt = ((shrt >> 1) & 0x5555) | ((shrt << 1) & 0xAAAA);
1128  shrt = ((shrt >> 2) & 0x3333) | ((shrt << 2) & 0xCCCC);
1129  shrt = ((shrt >> 4) & 0x0F0F) | ((shrt << 4) & 0xF0F0);
1130  shrt = ((shrt >> 8) & 0x00FF) | ((shrt << 8) & 0xFF00);
1131  return shrt;
1132 }
1133 
1135  uint8_t *bitmap, uint8_t *mask, int sizex, int sizey, int hotX, int hotY, bool canInvertColor)
1136 {
1137  int y, nbUns16;
1138  NSPoint hotSpotPoint;
1139  NSBitmapImageRep *cursorImageRep;
1140  NSImage *cursorImage;
1141  NSSize imSize;
1142  uint16_t *cursorBitmap;
1143 
1144  NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
1145 
1146  if (m_customCursor) {
1147  [m_customCursor release];
1148  m_customCursor = nil;
1149  }
1150 
1151  cursorImageRep = [[NSBitmapImageRep alloc]
1152  initWithBitmapDataPlanes:nil
1153  pixelsWide:sizex
1154  pixelsHigh:sizey
1155  bitsPerSample:1
1156  samplesPerPixel:2
1157  hasAlpha:YES
1158  isPlanar:YES
1159  colorSpaceName:NSDeviceWhiteColorSpace
1160  bytesPerRow:(sizex / 8 + (sizex % 8 > 0 ? 1 : 0))
1161  bitsPerPixel:1];
1162 
1163  cursorBitmap = (uint16_t *)[cursorImageRep bitmapData];
1164  nbUns16 = [cursorImageRep bytesPerPlane] / 2;
1165 
1166  for (y = 0; y < nbUns16; y++) {
1167 #if !defined(__LITTLE_ENDIAN__)
1168  cursorBitmap[y] = uns16ReverseBits((bitmap[2 * y] << 0) | (bitmap[2 * y + 1] << 8));
1169  cursorBitmap[nbUns16 + y] = uns16ReverseBits((mask[2 * y] << 0) | (mask[2 * y + 1] << 8));
1170 #else
1171  cursorBitmap[y] = uns16ReverseBits((bitmap[2 * y + 1] << 0) | (bitmap[2 * y] << 8));
1172  cursorBitmap[nbUns16 + y] = uns16ReverseBits((mask[2 * y + 1] << 0) | (mask[2 * y] << 8));
1173 #endif
1174 
1175  /* Flip white cursor with black outline to black cursor with white outline
1176  * to match macOS platform conventions. */
1177  if (canInvertColor) {
1178  cursorBitmap[y] = ~cursorBitmap[y];
1179  }
1180  }
1181 
1182  imSize.width = sizex;
1183  imSize.height = sizey;
1184  cursorImage = [[NSImage alloc] initWithSize:imSize];
1185  [cursorImage addRepresentation:cursorImageRep];
1186 
1187  hotSpotPoint.x = hotX;
1188  hotSpotPoint.y = hotY;
1189 
1190  // foreground and background color parameter is not handled for now (10.6)
1191  m_customCursor = [[NSCursor alloc] initWithImage:cursorImage hotSpot:hotSpotPoint];
1192 
1193  [cursorImageRep release];
1194  [cursorImage release];
1195 
1196  if ([m_window isVisible]) {
1198  }
1199  [pool drain];
1200  return GHOST_kSuccess;
1201 }
1202 
1203 #ifdef WITH_INPUT_IME
1204 void GHOST_WindowCocoa::beginIME(int32_t x, int32_t y, int32_t w, int32_t h, bool completed)
1205 {
1206  if (m_openGLView) {
1207  [m_openGLView beginIME:x y:y w:w h:h completed:completed];
1208  }
1209  else {
1210  [m_metalView beginIME:x y:y w:w h:h completed:completed];
1211  }
1212 }
1213 
1214 void GHOST_WindowCocoa::endIME()
1215 {
1216  if (m_openGLView) {
1217  [m_openGLView endIME];
1218  }
1219  else {
1220  [m_metalView endIME];
1221  }
1222 }
1223 #endif /* WITH_INPUT_IME */
typedef float(TangentPoint)[2]
static AppView * view
#define GHOST_ASSERT(x, info)
Definition: GHOST_Debug.h:54
static const std::unordered_map< GHOST_TStandardCursor, const char * > cursors
GHOST_TWindowState
Definition: GHOST_Types.h:129
@ GHOST_kWindowStateMinimized
Definition: GHOST_Types.h:132
@ GHOST_kWindowStateMaximized
Definition: GHOST_Types.h:131
@ GHOST_kWindowStateNormal
Definition: GHOST_Types.h:130
@ GHOST_kWindowStateFullScreen
Definition: GHOST_Types.h:133
GHOST_TStandardCursor
Definition: GHOST_Types.h:214
@ GHOST_kStandardCursorZoomIn
Definition: GHOST_Types.h:236
@ GHOST_kStandardCursorVerticalSplit
Definition: GHOST_Types.h:231
@ GHOST_kStandardCursorCopy
Definition: GHOST_Types.h:253
@ GHOST_kStandardCursorHorizontalSplit
Definition: GHOST_Types.h:232
@ GHOST_kStandardCursorTopSide
Definition: GHOST_Types.h:245
@ GHOST_kStandardCursorStop
Definition: GHOST_Types.h:242
@ GHOST_kStandardCursorCrosshair
Definition: GHOST_Types.h:224
@ GHOST_kStandardCursorCustom
Definition: GHOST_Types.h:254
@ GHOST_kStandardCursorNSEWScroll
Definition: GHOST_Types.h:239
@ GHOST_kStandardCursorLeftRight
Definition: GHOST_Types.h:244
@ GHOST_kStandardCursorPencil
Definition: GHOST_Types.h:228
@ GHOST_kStandardCursorNSScroll
Definition: GHOST_Types.h:240
@ GHOST_kStandardCursorCrosshairA
Definition: GHOST_Types.h:225
@ GHOST_kStandardCursorUpDown
Definition: GHOST_Types.h:243
@ GHOST_kStandardCursorUpArrow
Definition: GHOST_Types.h:229
@ GHOST_kStandardCursorBottomSide
Definition: GHOST_Types.h:246
@ GHOST_kStandardCursorEyedropper
Definition: GHOST_Types.h:235
@ GHOST_kStandardCursorKnife
Definition: GHOST_Types.h:234
@ GHOST_kStandardCursorMove
Definition: GHOST_Types.h:238
@ GHOST_kStandardCursorCrosshairB
Definition: GHOST_Types.h:226
@ GHOST_kStandardCursorDownArrow
Definition: GHOST_Types.h:230
@ GHOST_kStandardCursorEraser
Definition: GHOST_Types.h:233
@ GHOST_kStandardCursorDefault
Definition: GHOST_Types.h:216
@ GHOST_kStandardCursorEWScroll
Definition: GHOST_Types.h:241
@ GHOST_kStandardCursorRightSide
Definition: GHOST_Types.h:248
@ GHOST_kStandardCursorRightArrow
Definition: GHOST_Types.h:217
@ GHOST_kStandardCursorDestroy
Definition: GHOST_Types.h:220
@ GHOST_kStandardCursorCrosshairC
Definition: GHOST_Types.h:227
@ GHOST_kStandardCursorZoomOut
Definition: GHOST_Types.h:237
@ GHOST_kStandardCursorLeftSide
Definition: GHOST_Types.h:247
@ GHOST_kStandardCursorText
Definition: GHOST_Types.h:223
@ GHOST_kStandardCursorLeftArrow
Definition: GHOST_Types.h:218
@ GHOST_kEventWindowClose
Definition: GHOST_Types.h:189
@ GHOST_kEventWindowMove
Definition: GHOST_Types.h:194
@ GHOST_kEventWindowSize
Definition: GHOST_Types.h:193
@ GHOST_kEventDraggingDropDone
Definition: GHOST_Types.h:200
@ GHOST_kEventDraggingExited
Definition: GHOST_Types.h:199
@ GHOST_kEventNativeResolutionChange
Definition: GHOST_Types.h:203
@ GHOST_kEventDraggingUpdated
Definition: GHOST_Types.h:198
@ GHOST_kEventDraggingEntered
Definition: GHOST_Types.h:197
@ GHOST_kEventWindowActivate
Definition: GHOST_Types.h:190
@ GHOST_kEventWindowUpdate
Definition: GHOST_Types.h:192
@ GHOST_kEventWindowDeactivate
Definition: GHOST_Types.h:191
static const GHOST_TabletData GHOST_TABLET_DATA_NONE
Definition: GHOST_Types.h:104
GHOST_TDrawingContextType
Definition: GHOST_Types.h:148
@ GHOST_kDrawingContextTypeOpenGL
Definition: GHOST_Types.h:150
GHOST_TWindowOrder
Definition: GHOST_Types.h:146
@ GHOST_kWindowOrderTop
Definition: GHOST_Types.h:146
GHOST_TSuccess
Definition: GHOST_Types.h:74
@ GHOST_kFailure
Definition: GHOST_Types.h:74
@ GHOST_kSuccess
Definition: GHOST_Types.h:74
GHOST_TGrabCursorMode
Definition: GHOST_Types.h:404
@ GHOST_kGrabDisable
Definition: GHOST_Types.h:406
@ GHOST_kGrabHide
Definition: GHOST_Types.h:415
@ GHOST_kGrabNormal
Definition: GHOST_Types.h:408
GHOST_TDragnDropTypes
Definition: GHOST_Types.h:474
@ GHOST_kDragnDropTypeUnknown
Definition: GHOST_Types.h:475
@ GHOST_kDragnDropTypeFilenames
Definition: GHOST_Types.h:476
@ GHOST_kDragnDropTypeBitmap
Definition: GHOST_Types.h:478
@ GHOST_kDragnDropTypeString
Definition: GHOST_Types.h:477
static NSCursor * getImageCursor(GHOST_TStandardCursor shape, NSString *name, NSPoint hotspot)
static void postNotification()
static uint16_t uns16ReverseBits(uint16_t shrt)
associatedWindow
static uint8_t uns8ReverseBits(uint8_t ch)
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei height
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum type
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei width
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint order
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble bottom
ATTR_WARN_UNUSED_RESULT const BMVert const BMEdge * e
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition: btDbvt.cpp:52
static btDbvtVolume bounds(btDbvtNode **leaves, int count)
Definition: btDbvt.cpp:299
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
Definition: btQuadWord.h:119
int32_t m_l
Definition: GHOST_Rect.h:156
int32_t m_r
Definition: GHOST_Rect.h:160
virtual int32_t getHeight() const
Definition: GHOST_Rect.h:174
virtual int32_t getWidth() const
Definition: GHOST_Rect.h:169
GHOST_TSuccess handleWindowEvent(GHOST_TEventType eventType, GHOST_WindowCocoa *window)
GHOST_TSuccess handleDraggingEvent(GHOST_TEventType eventType, GHOST_TDragnDropTypes draggedObjectType, GHOST_WindowCocoa *window, int mouseX, int mouseY, void *data)
GHOST_TSuccess setCursorPosition(int32_t x, int32_t y)
GHOST_TSuccess getCursorPosition(int32_t &x, int32_t &y) const
void dispatchEvents()
bool m_nativePixel
Definition: GHOST_System.h:152
GHOST_SystemCocoa * m_systemCocoa
GHOST_TSuccess hasCursorShape(GHOST_TStandardCursor shape)
GHOST_TSuccess setClientWidth(uint32_t width)
void setImmediateDraw(bool value)
void setTitle(const char *title)
std::string getTitle() const
GHOST_Context * newDrawingContext(GHOST_TDrawingContextType type)
GHOST_TSuccess setWindowCursorVisibility(bool visible)
CocoaOpenGLView * m_openGLView
CAMetalLayer * m_metalLayer
CocoaWindow * m_window
GHOST_TSuccess setOrder(GHOST_TWindowOrder order)
NSCursor * getStandardCursor(GHOST_TStandardCursor cursor) const
GHOST_TWindowState getState() const
GHOST_TSuccess setWindowCustomCursorShape(uint8_t *bitmap, uint8_t *mask, int sizex, int sizey, int hotX, int hotY, bool canInvertColor)
GHOST_TabletData m_tablet
void getWindowBounds(GHOST_Rect &bounds) const
GHOST_WindowCocoa(GHOST_SystemCocoa *systemCocoa, const char *title, int32_t left, int32_t bottom, uint32_t width, uint32_t height, GHOST_TWindowState state, GHOST_TDrawingContextType type=GHOST_kDrawingContextTypeNone, const bool stereoVisual=false, bool is_debug=false, bool dialog=false, GHOST_WindowCocoa *parentWindow=0)
void clientToScreenIntern(int32_t inX, int32_t inY, int32_t &outX, int32_t &outY) const
void getClientBounds(GHOST_Rect &bounds) const
void * getOSWindow() const
GHOST_TSuccess setClientHeight(uint32_t height)
GHOST_TSuccess setModifiedState(bool isUnsavedChanges)
GHOST_TSuccess setState(GHOST_TWindowState state)
void setNativePixelSize(void)
void screenToClientIntern(int32_t inX, int32_t inY, int32_t &outX, int32_t &outY) const
GHOST_TSuccess setClientSize(uint32_t width, uint32_t height)
GHOST_TSuccess invalidate()
CocoaMetalView * m_metalView
GHOST_TSuccess setWindowCursorShape(GHOST_TStandardCursor shape)
GHOST_TSuccess setWindowCursorGrab(GHOST_TGrabCursorMode mode)
void loadCursor(bool visible, GHOST_TStandardCursor cursor) const
void screenToClient(int32_t inX, int32_t inY, int32_t &outX, int32_t &outY) const
GHOST_TSuccess setProgressBar(float progress)
GHOST_TSuccess endProgressBar()
void clientToScreen(int32_t inX, int32_t inY, int32_t &outX, int32_t &outY) const
GHOST_Rect m_cursorGrabBounds
Definition: GHOST_Window.h:371
bool getCursorVisibility() const
Definition: GHOST_Window.h:408
void setCursorGrabAccum(int32_t x, int32_t y)
Definition: GHOST_Window.h:440
GHOST_TGrabCursorMode m_cursorGrab
Definition: GHOST_Window.h:359
bool m_wantStereoVisual
Definition: GHOST_Window.h:389
int32_t m_cursorGrabInitPos[2]
Definition: GHOST_Window.h:365
GHOST_TSuccess setDrawingContextType(GHOST_TDrawingContextType type)
GHOST_TSuccess releaseNativeHandles()
virtual GHOST_TSuccess setModifiedState(bool isUnsavedChanges)
bool canAcceptDragOperation() const
virtual bool getValid() const
Definition: GHOST_Window.h:75
float m_nativePixelSize
Definition: GHOST_Window.h:397
void setAcceptDragOperation(bool canAccept)
GHOST_TSuccess updateDrawingContext()
bool m_progressBarVisible
Definition: GHOST_Window.h:377
virtual GHOST_TSuccess activateDrawingContext()
GHOST_TStandardCursor getCursorShape() const
Definition: GHOST_Window.h:446
SyclQueue void void size_t num_bytes void
int len
Definition: draw_manager.c:108
depth_tx normal_tx diffuse_light_tx specular_light_tx volume_light_tx environment_tx ambient_occlusion_tx aov_value_tx in_weight_img image(1, GPU_R32F, Qualifier::WRITE, ImageType::FLOAT_2D_ARRAY, "out_weight_img") .image(3
GHOST_WindowCocoa * associatedWindow
void setSystemAndWindowCocoa:windowCocoa:(GHOST_SystemCocoa *sysCocoa,[windowCocoa] GHOST_WindowCocoa *winCocoa)
GHOST_SystemCocoa * systemCocoa
GHOST_SystemCocoa * systemCocoa
GHOST_WindowCocoa * associatedWindow
void setSystemAndWindowCocoa:windowCocoa:(GHOST_SystemCocoa *sysCocoa,[windowCocoa] GHOST_WindowCocoa *winCocoa)
GHOST_TDragnDropTypes m_draggedObjectType
int count
const int state
static char ** types
Definition: makesdna.c:67
ccl_device_inline float4 mask(const int4 &mask, const float4 &a)
Definition: math_float4.h:513
static int left
static unsigned a[3]
Definition: RandGen.cpp:78
unsigned short uint16_t
Definition: stdint.h:79
unsigned int uint32_t
Definition: stdint.h:80
signed int int32_t
Definition: stdint.h:77
unsigned char uint8_t
Definition: stdint.h:78
static FT_Error err