From 265cf6c9478860336816570a141198d9257a27a1 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Mon, 10 Feb 2003 16:56:03 +0000 Subject: [PATCH] show desktop mode works! --- src/client.cc | 17 +++++++++++------ src/screen.cc | 22 +++++++++++++++++++--- src/screen.hh | 10 ++++++++++ 3 files changed, 40 insertions(+), 9 deletions(-) diff --git a/src/client.cc b/src/client.cc index 8a3a46b8..453bf745 100644 --- a/src/client.cc +++ b/src/client.cc @@ -764,12 +764,17 @@ void Client::setDesktop(unsigned int target) void Client::showhide() { - if (!_iconic && - (_desktop == openbox->screen(_screen)->desktop() || - _desktop == 0xffffffff)) - frame->show(); - else - frame->hide(); + bool show; + Screen *s = openbox->screen(_screen); + + if (_iconic) show = false; + else if (!(_desktop == s->desktop() || + _desktop == 0xffffffff)) show = false; + else if (normal() && s->showingDesktop()) show = false; + else show = true; + + if (show) frame->show(); + else frame->hide(); } diff --git a/src/screen.cc b/src/screen.cc index dfcc8375..3a064560 100644 --- a/src/screen.cc +++ b/src/screen.cc @@ -44,6 +44,8 @@ Screen::Screen(int screen) assert(screen >= 0); assert(screen < ScreenCount(**otk::display)); _info = otk::display->screenInfo(screen); + _showing_desktop = false; + ::running = false; XErrorHandler old = XSetErrorHandler(::anotherWMRunning); XSelectInput(**otk::display, _info->rootWindow(), @@ -397,13 +399,13 @@ void Screen::changeSupportedAtoms() otk::Property::atoms.net_client_list_stacking, otk::Property::atoms.net_desktop_names, otk::Property::atoms.net_close_window, + otk::Property::atoms.net_desktop_layout, + otk::Property::atoms.net_showing_desktop, otk::Property::atoms.net_wm_name, otk::Property::atoms.net_wm_visible_name, otk::Property::atoms.net_wm_icon_name, otk::Property::atoms.net_wm_visible_icon_name, -/* otk::Property::atoms.net_wm_desktop, -*/ otk::Property::atoms.net_wm_strut, otk::Property::atoms.net_wm_window_type, otk::Property::atoms.net_wm_window_type_desktop, @@ -878,6 +880,15 @@ void Screen::installColormap(bool install) const XUninstallColormap(**otk::display, _info->colormap()); } +void Screen::showDesktop(bool show) +{ + if (show == _showing_desktop) return; // no change + + _showing_desktop = show; + ClientList::iterator it, end = clients.end(); + for (it = clients.begin(); it != end; ++it) + (*it)->showhide(); +} void Screen::propertyHandler(const XPropertyEvent &e) { @@ -912,6 +923,8 @@ void Screen::clientMessageHandler(const XClientMessageEvent &e) changeDesktop(e.data.l[0]); } else if (e.message_type == otk::Property::atoms.net_number_of_desktops) { changeNumDesktops(e.data.l[0]); + } else if (e.message_type == otk::Property::atoms.net_showing_desktop) { + showDesktop(e.data.l[0] != 0); } } @@ -929,8 +942,11 @@ void Screen::mapRequestHandler(const XMapRequestEvent &e) #ifdef DEBUG printf("DEBUG: MAP REQUEST CAUGHT IN SCREEN. IGNORED.\n"); #endif - } else + } else { + if (_showing_desktop) + showDesktop(false); // leave showing-the-desktop mode manageWindow(e.window); + } } } diff --git a/src/screen.hh b/src/screen.hh index adccf180..e8306933 100644 --- a/src/screen.hh +++ b/src/screen.hh @@ -95,8 +95,12 @@ private: //! The names of all desktops otk::Property::StringVect _desktop_names; + //! The layout of the desktops as specified by an EWMH compliant pager DesktopLayout _layout; + //! True when the window manager is in 'showing desktop' mode + bool _showing_desktop; + //! Calculate the Screen::_area member void calcArea(); //! Set the list of supported NETWM atoms on the root window @@ -139,6 +143,10 @@ private: */ void changeNumDesktops(unsigned int num); + //! Shows and focuses the desktop and hides all the client windows, or + //! returns to the normal state, showing client windows. + void showDesktop(bool show); + public: #ifndef SWIG //! Constructs a new Screen object @@ -161,6 +169,8 @@ public: inline unsigned int desktop() const { return _desktop; } //! Returns the number of desktops inline unsigned int numDesktops() const { return _num_desktops; } + //! When true, the desktop is being shown and all clients are hidden + inline bool showingDesktop() const { return _showing_desktop; } //! Returns the area of the screen not reserved by applications' Struts /*! -- 2.39.2