From f0cdd7519759dbad4ad13fa9a9ff434787436123 Mon Sep 17 00:00:00 2001 From: Preston Brown Date: Fri, 3 Dec 1999 21:08:07 +0000 Subject: [PATCH] implemented desktop cascading and uncluttering. svn path=/trunk/kdebase/kwin/; revision=35765 --- atoms.cpp | 29 ++++++++++++++++------------- atoms.h | 2 ++ workspace.cpp | 41 +++++++++++++++++++++++++++++++++++++++++ workspace.h | 4 ++++ 4 files changed, 63 insertions(+), 13 deletions(-) diff --git a/atoms.cpp b/atoms.cpp index 34559f3d61..5bc92c45ee 100644 --- a/atoms.cpp +++ b/atoms.cpp @@ -11,45 +11,48 @@ Atoms::Atoms() int n = 0; atoms[n] = &wm_protocols; - names[n++] = "WM_PROTOCOLS"; + names[n++] = (char *) "WM_PROTOCOLS"; atoms[n] = &wm_delete_window; - names[n++] = "WM_DELETE_WINDOW"; + names[n++] = (char *) "WM_DELETE_WINDOW"; atoms[n] = &wm_take_focus; - names[n++] = "WM_TAKE_FOCUS"; + names[n++] = (char *) "WM_TAKE_FOCUS"; atoms[n] = &wm_change_state; - names[n++] = "WM_CHANGE_STATE"; + names[n++] = (char *) "WM_CHANGE_STATE"; // compatibility atoms[n] = &kwm_win_icon; - names[n++] = "KWM_WIN_ICON"; + names[n++] = (char *) "KWM_WIN_ICON"; // compatibility atoms[n] = &kwm_running; - names[n++] = "KWM_RUNNING"; + names[n++] = (char *) "KWM_RUNNING"; + + atoms[n] = &kwm_command; + names[n++] = (char *) "KWM_COMMAND"; atoms[n] = &net_number_of_desktops; - names[n++] = "_NET_NUMBER_OF_DESKTOPS"; + names[n++] = (char *) "_NET_NUMBER_OF_DESKTOPS"; atoms[n] = &net_current_desktop; - names[n++] = "_NET_CURRENT_DESKTOP"; + names[n++] = (char *) "_NET_CURRENT_DESKTOP"; atoms[n] = &net_active_window; - names[n++] = "_NET_ACTIVE_WINDOW"; + names[n++] = (char *) "_NET_ACTIVE_WINDOW"; atoms[n] = &net_wm_context_help; - names[n++] = "_NET_WM_CONTEXT_HELP"; + names[n++] = (char *) "_NET_WM_CONTEXT_HELP"; atoms[n] = &net_client_list; - names[n++] = "_NET_CLIENT_LIST"; + names[n++] = (char *) "_NET_CLIENT_LIST"; atoms[n] = &net_client_list_stacking; - names[n++] = "_NET_CLIENT_LIST_STACKING"; + names[n++] = (char *) "_NET_CLIENT_LIST_STACKING"; atoms[n] = &net_kde_docking_windows; - names[n++] = "_NET_KDE_DOCKING_WINDOWS"; + names[n++] = (char *) "_NET_KDE_DOCKING_WINDOWS"; XInternAtoms( qt_xdisplay(), names, n, FALSE, atoms_return ); for (int i = 0; i < n; i++ ) diff --git a/atoms.h b/atoms.h index f272f3376b..069d43ff0d 100644 --- a/atoms.h +++ b/atoms.h @@ -11,6 +11,7 @@ public: Atom wm_take_focus; Atom wm_change_state; Atom kwm_win_icon; // compatibility + Atom kwm_command; // compatibility Atom kwm_running; Atom net_number_of_desktops; @@ -21,6 +22,7 @@ public: Atom net_wm_context_help; Atom net_kde_docking_windows; + }; diff --git a/workspace.cpp b/workspace.cpp index 89087e6936..02a8d5decd 100644 --- a/workspace.cpp +++ b/workspace.cpp @@ -1201,6 +1201,32 @@ void Workspace::cascadePlacement (Client* c, bool re_init) { cci[d].pos = QPoint( xp + delta_x, yp + delta_y ); } +void Workspace::deskCleanup(CleanupType ct) +{ + QValueList::Iterator it(clients.fromLast()); + for (; it != clients.begin(); --it) { + QString s; + char *name = 0; + if ( XFetchName( qt_xdisplay(), (*it)->window(), &name ) && name ) { + s = QString::fromLatin1( name ); + XFree( name ); + } + if (s == "Kicker" || + s == "THE DESKTOP") + continue; + if((!(*it)->isOnDesktop(currentDesktop())) || + ((*it)->isIconified()) || + ((*it)->isSticky()) ) + continue; + + else { + if (ct == Cascade) + cascadePlacement(*it); + else if (ct == Unclutter) + smartPlacement(*it); + } + } +} /*! Raises the client \a c taking layers, transient windows and window @@ -1424,6 +1450,21 @@ bool Workspace::clientMessage( XClientMessageEvent msg ) return TRUE; } + if (msg.message_type == atoms->kwm_command) { + char c[21]; + int i; + for (i=0;i<20;i++) + c[i] = msg.data.b[i]; + c[i] = '\0'; + QString com = c; + if (com == "deskUnclutter") { + deskCleanup(Unclutter); + } else if (com == "deskCascade") { + deskCleanup(Cascade); + } + return TRUE; + } + return FALSE; } diff --git a/workspace.h b/workspace.h index 486eca9d5b..f03a981f03 100644 --- a/workspace.h +++ b/workspace.h @@ -160,6 +160,9 @@ private: void smartPlacement(Client* c); void cascadePlacement(Client* c, bool re_init = false); + enum CleanupType { Cascade, Unclutter }; + void deskCleanup(CleanupType); + void focusToNull(); Client* desktop_client; int current_desktop; @@ -188,6 +191,7 @@ private: QValueList cci; // -cascading + Atom kwm_command; }; inline WId Workspace::rootWin() const