Browse Source

get_rejected_properties(), etc.

David Rose 23 years ago
parent
commit
4b61f609ed

+ 46 - 6
panda/src/display/graphicsWindow.cxx

@@ -140,6 +140,37 @@ get_requested_properties() const {
   return result;
   return result;
 }
 }
 
 
+////////////////////////////////////////////////////////////////////
+//     Function: GraphicsWindow::clear_rejected_properties
+//       Access: Published
+//  Description: Empties the set of failed properties that will be
+//               returned by get_rejected_properties().
+////////////////////////////////////////////////////////////////////
+void GraphicsWindow::
+clear_rejected_properties() {
+  MutexHolder holder(_lock);
+  _rejected_properties.clear();
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: GraphicsWindow::get_rejected_properties
+//       Access: Published
+//  Description: Returns the set of properties that have recently been
+//               requested, but could not be applied to the window for
+//               some reason.  This set of properties will remain
+//               unchanged until they are changed by a new failed
+//               request, or clear_rejected_properties() is called.
+////////////////////////////////////////////////////////////////////
+WindowProperties GraphicsWindow::
+get_rejected_properties() const {
+  WindowProperties result;
+  {
+    MutexHolder holder(_lock);
+    result = _rejected_properties;
+  }
+  return result;
+}
+
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: GraphicsWindow::request_properties
 //     Function: GraphicsWindow::request_properties
 //       Access: Published
 //       Access: Published
@@ -700,12 +731,14 @@ process_events() {
     {
     {
       MutexHolder holder(_lock);
       MutexHolder holder(_lock);
       properties = _requested_properties;
       properties = _requested_properties;
-      _requested_properties = WindowProperties();
-    }
-    set_properties_now(properties);
-    if (properties.is_any_specified()) {
-      display_cat.info()
-        << "Unable to set window properties: " << properties << "\n";
+      _requested_properties.clear();
+
+      set_properties_now(properties);
+      if (properties.is_any_specified()) {
+        display_cat.info()
+          << "Unable to set window properties: " << properties << "\n";
+        _rejected_properties.add_properties(properties);
+      }
     }
     }
   }
   }
 }
 }
@@ -748,7 +781,14 @@ set_properties_now(WindowProperties &properties) {
           chan->window_resized(_properties.get_x_size(), 
           chan->window_resized(_properties.get_x_size(), 
                                _properties.get_y_size());
                                _properties.get_y_size());
         }
         }
+
       } else {
       } else {
+        // Since we can't even open the window, tag the
+        // _rejected_properties with all of the window properties that
+        // failed.
+        _rejected_properties.add_properties(_properties);
+
+        // And mark the window closed.
         _properties.set_open(false);
         _properties.set_open(false);
       }
       }
 
 

+ 3 - 0
panda/src/display/graphicsWindow.h

@@ -72,6 +72,8 @@ PUBLISHED:
 
 
   WindowProperties get_properties() const;
   WindowProperties get_properties() const;
   WindowProperties get_requested_properties() const;
   WindowProperties get_requested_properties() const;
+  void clear_rejected_properties();
+  WindowProperties get_rejected_properties() const;
   void request_properties(const WindowProperties &requested_properties);
   void request_properties(const WindowProperties &requested_properties);
   INLINE bool is_closed() const;
   INLINE bool is_closed() const;
   INLINE bool is_active() const;
   INLINE bool is_active() const;
@@ -177,6 +179,7 @@ private:
   bool _display_regions_stale;
   bool _display_regions_stale;
 
 
   WindowProperties _requested_properties;
   WindowProperties _requested_properties;
+  WindowProperties _rejected_properties;
   string _window_event;
   string _window_event;
   
   
 public:
 public:

+ 5 - 0
panda/src/glxdisplay/glxGraphicsWindow.cxx

@@ -156,6 +156,10 @@ void glxGraphicsWindow::
 process_events() {
 process_events() {
   GraphicsWindow::process_events();
   GraphicsWindow::process_events();
 
 
+  if (_xwindow == (Window)0) {
+    return;
+  }
+
   XEvent event;
   XEvent event;
   while (XCheckWindowEvent(_display, _xwindow, _event_mask, &event)) {
   while (XCheckWindowEvent(_display, _xwindow, _event_mask, &event)) {
     WindowProperties properties;
     WindowProperties properties;
@@ -273,6 +277,7 @@ void glxGraphicsWindow::
 set_properties_now(WindowProperties &properties) {
 set_properties_now(WindowProperties &properties) {
   GraphicsWindow::set_properties_now(properties);
   GraphicsWindow::set_properties_now(properties);
   if (!properties.is_any_specified()) {
   if (!properties.is_any_specified()) {
+    // The base class has already handled this case.
     return;
     return;
   }
   }