ソースを参照

add osx-disable-event-loop

David Rose 18 年 前
コミット
fcb83a251e

+ 7 - 0
panda/src/osxdisplay/config_osxdisplay.cxx

@@ -41,6 +41,13 @@ ConfigVariableBool show_resize_box
           "window would completely hide any resize control drawn by the "
           "OS.  Set this variable false to allow this control to be hidden."));
 
+ConfigVariableBool osx_disable_event_loop
+("osx-disable-event-loop", false,
+ PRC_DESC("Set this true to disable the window event loop for the Panda "
+          "windows.  This makes sense only in a publish environment where "
+          "the window event loop is already handled by another part of the "
+          "app."));
+
 ////////////////////////////////////////////////////////////////////
 //     Function: init_libosxdisplay
 //  Description: Initializes the library.  This must be called at

+ 1 - 0
panda/src/osxdisplay/config_osxdisplay.h

@@ -26,5 +26,6 @@ NotifyCategoryDecl( osxdisplay , EXPCL_PANDAGL, EXPTP_PANDAGL);
 extern EXPCL_PANDAGL void init_libosxdisplay();
 
 extern ConfigVariableBool show_resize_box;
+extern ConfigVariableBool osx_disable_event_loop;
 
 #endif /* __CONFIG_OSXDISPLAY_H__ */

+ 15 - 12
panda/src/osxdisplay/osxGraphicsWindow.mm

@@ -1157,21 +1157,24 @@ bool osxGraphicsWindow::OSOpenWindow(WindowProperties &req_properties)
 void osxGraphicsWindow::process_events()
 {
     GraphicsWindow::process_events();
-    EventRef theEvent;
-    EventTargetRef theTarget;
-    theTarget = GetEventDispatcherTarget();
 
-	if (!_properties.has_parent_window())
+    if (!osx_disable_event_loop) {
+      EventRef theEvent;
+      EventTargetRef theTarget;
+      theTarget = GetEventDispatcherTarget();
+      
+      if (!_properties.has_parent_window())
 	{
-    //    while  (ReceiveNextEvent(0, NULL,kEventDurationForever,true, &theEvent)== noErr)
-		while  (ReceiveNextEvent(0, NULL,kEventDurationNoWait,true, &theEvent)== noErr)
-		{
-	//	    cerr << "--------------------------------------------Dispatch Event " << pass++ << "\n";
-			SendEventToEventTarget (theEvent, theTarget);
-			ReleaseEvent(theEvent);
-	//		cerr << "------------------------------------Done Dispatch \n";
-		}
+          //    while  (ReceiveNextEvent(0, NULL,kEventDurationForever,true, &theEvent)== noErr)
+          while  (ReceiveNextEvent(0, NULL,kEventDurationNoWait,true, &theEvent)== noErr)
+            {
+              //	    cerr << "--------------------------------------------Dispatch Event " << pass++ << "\n";
+              SendEventToEventTarget (theEvent, theTarget);
+              ReleaseEvent(theEvent);
+              //		cerr << "------------------------------------Done Dispatch \n";
+            }
 	}
+    }
 };
 
 // handle display config changes meaing we need to update the GL context via the resize function and check for windwo dimension changes