From 4b61f609ed573eb225a49c8ffa17d32dad275999 Mon Sep 17 00:00:00 2001 From: David Rose Date: Tue, 14 Jan 2003 22:38:17 +0000 Subject: [PATCH] get_rejected_properties(), etc. --- panda/src/display/graphicsWindow.cxx | 52 +++++++++++++++++++--- panda/src/display/graphicsWindow.h | 3 ++ panda/src/glxdisplay/glxGraphicsWindow.cxx | 5 +++ 3 files changed, 54 insertions(+), 6 deletions(-) diff --git a/panda/src/display/graphicsWindow.cxx b/panda/src/display/graphicsWindow.cxx index bcb51edf28..475f7d7f49 100644 --- a/panda/src/display/graphicsWindow.cxx +++ b/panda/src/display/graphicsWindow.cxx @@ -140,6 +140,37 @@ get_requested_properties() const { 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 // Access: Published @@ -700,12 +731,14 @@ process_events() { { MutexHolder holder(_lock); 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(), _properties.get_y_size()); } + } 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); } diff --git a/panda/src/display/graphicsWindow.h b/panda/src/display/graphicsWindow.h index 80dbaef80e..63ac0116f1 100644 --- a/panda/src/display/graphicsWindow.h +++ b/panda/src/display/graphicsWindow.h @@ -72,6 +72,8 @@ PUBLISHED: WindowProperties get_properties() const; WindowProperties get_requested_properties() const; + void clear_rejected_properties(); + WindowProperties get_rejected_properties() const; void request_properties(const WindowProperties &requested_properties); INLINE bool is_closed() const; INLINE bool is_active() const; @@ -177,6 +179,7 @@ private: bool _display_regions_stale; WindowProperties _requested_properties; + WindowProperties _rejected_properties; string _window_event; public: diff --git a/panda/src/glxdisplay/glxGraphicsWindow.cxx b/panda/src/glxdisplay/glxGraphicsWindow.cxx index 0214555d31..c832cd6062 100644 --- a/panda/src/glxdisplay/glxGraphicsWindow.cxx +++ b/panda/src/glxdisplay/glxGraphicsWindow.cxx @@ -156,6 +156,10 @@ void glxGraphicsWindow:: process_events() { GraphicsWindow::process_events(); + if (_xwindow == (Window)0) { + return; + } + XEvent event; while (XCheckWindowEvent(_display, _xwindow, _event_mask, &event)) { WindowProperties properties; @@ -273,6 +277,7 @@ void glxGraphicsWindow:: set_properties_now(WindowProperties &properties) { GraphicsWindow::set_properties_now(properties); if (!properties.is_any_specified()) { + // The base class has already handled this case. return; }