]> Dogcows Code - chaz/openbox/commitdiff
support for showing the root and workspace menu with epist
authorDana Jansens <danakj@orodu.net>
Thu, 22 Aug 2002 00:57:29 +0000 (00:57 +0000)
committerDana Jansens <danakj@orodu.net>
Thu, 22 Aug 2002 00:57:29 +0000 (00:57 +0000)
src/Screen.cc
src/Screen.hh
src/XAtom.cc
src/XAtom.hh
src/blackbox.cc
util/epist/screen.cc

index 31811fe63d740996b8745d9846e53006d57509cb..acde773640a5007749a35f17d1fe705ed6f9aa78 100644 (file)
@@ -2308,43 +2308,9 @@ void BScreen::buttonPressEvent(const XButtonEvent *xbutton) {
     if (rootmenu->isVisible())
       rootmenu->hide();
   } else if (xbutton->button == 2) {
-    int mx = xbutton->x_root - (workspacemenu->getWidth() / 2);
-    int my = xbutton->y_root - (workspacemenu->getTitleHeight() / 2);
-
-    if (mx < 0) mx = 0;
-    if (my < 0) my = 0;
-
-    if (mx + workspacemenu->getWidth() > getWidth())
-      mx = getWidth() - workspacemenu->getWidth() - getBorderWidth();
-
-    if (my + workspacemenu->getHeight() > getHeight())
-      my = getHeight() - workspacemenu->getHeight() - getBorderWidth();
-
-    workspacemenu->move(mx, my);
-
-    if (! workspacemenu->isVisible()) {
-      workspacemenu->removeParent();
-      workspacemenu->show();
-    }
+    showWorkspaceMenu(xbutton->x_root, xbutton->y_root);
   } else if (xbutton->button == 3) {
-    int mx = xbutton->x_root - (rootmenu->getWidth() / 2);
-    int my = xbutton->y_root - (rootmenu->getTitleHeight() / 2);
-
-    if (mx < 0) mx = 0;
-    if (my < 0) my = 0;
-
-    if (mx + rootmenu->getWidth() > getWidth())
-      mx = getWidth() - rootmenu->getWidth() - getBorderWidth();
-
-    if (my + rootmenu->getHeight() > getHeight())
-      my = getHeight() - rootmenu->getHeight() - getBorderWidth();
-
-    rootmenu->move(mx, my);
-
-    if (! rootmenu->isVisible()) {
-      blackbox->checkMenu();
-      rootmenu->show();
-    }
+    showRootMenu(xbutton->x_root, xbutton->y_root);
   // mouse wheel up
   } else if ((xbutton->button == 4 && resource.root_scroll == NormalScroll) ||
              (xbutton->button == 5 && resource.root_scroll == ReverseScroll)) {
@@ -2363,6 +2329,50 @@ void BScreen::buttonPressEvent(const XButtonEvent *xbutton) {
 }
 
 
+void BScreen::showWorkspaceMenu(int x, int y) {
+  int mx = x - (workspacemenu->getWidth() / 2);
+  int my = y - (workspacemenu->getTitleHeight() / 2);
+
+  if (mx < 0) mx = 0;
+  if (my < 0) my = 0;
+
+  if (mx + workspacemenu->getWidth() > getWidth())
+    mx = getWidth() - workspacemenu->getWidth() - getBorderWidth();
+
+  if (my + workspacemenu->getHeight() > getHeight())
+    my = getHeight() - workspacemenu->getHeight() - getBorderWidth();
+
+  workspacemenu->move(mx, my);
+
+  if (! workspacemenu->isVisible()) {
+    workspacemenu->removeParent();
+    workspacemenu->show();
+  }
+}
+
+
+void BScreen::showRootMenu(int x, int y) {
+  int mx = x - (rootmenu->getWidth() / 2);
+  int my = y - (rootmenu->getTitleHeight() / 2);
+
+  if (mx < 0) mx = 0;
+  if (my < 0) my = 0;
+
+  if (mx + rootmenu->getWidth() > getWidth())
+    mx = getWidth() - rootmenu->getWidth() - getBorderWidth();
+
+  if (my + rootmenu->getHeight() > getHeight())
+    my = getHeight() - rootmenu->getHeight() - getBorderWidth();
+
+  rootmenu->move(mx, my);
+
+  if (! rootmenu->isVisible()) {
+    blackbox->checkMenu();
+    rootmenu->show();
+  }
+}
+
+
 void BScreen::propertyNotifyEvent(const XPropertyEvent *pe) {
   if (pe->atom == xatom->getAtom(XAtom::net_desktop_names)) {
     // _NET_WM_DESKTOP_NAMES
index 4b454e0253699dd9e613e70e04276081fe3f60c0..6d12f3208b8d41533e715af369554cf272b87b86 100644 (file)
@@ -376,6 +376,9 @@ public:
   void showGeometry(unsigned int gx, unsigned int gy);
   void hideGeometry(void);
 
+  void showWorkspaceMenu(int x, int y);
+  void showRootMenu(int x, int y);
+
   void buttonPressEvent(const XButtonEvent *xbutton);
   void propertyNotifyEvent(const XPropertyEvent *pe);
 
index 15bbc262e55defaa3b40ee6b8cfd338b0d04d881..e0fac57cd15de4e948beae47a20616e814e68eca 100644 (file)
@@ -77,6 +77,9 @@ XAtom::XAtom(Display *d) {
     create("_BLACKBOX_CHANGE_WINDOW_FOCUS");
   _atoms[blackbox_cycle_window_focus] = create("_BLACKBOX_CYCLE_WINDOW_FOCUS");
 
+  _atoms[openbox_show_root_menu] = create("_OPENBOX_SHOW_ROOT_MENU");
+  _atoms[openbox_show_workspace_menu] = create("_OPENBOX_SHOW_WORKSPACE_MENU");
+
   _atoms[net_supported] = create("_NET_SUPPORTED");
   _atoms[net_client_list] = create("_NET_CLIENT_LIST");
   _atoms[net_client_list_stacking] = create("_NET_CLIENT_LIST_STACKING");
index 2def1c6caf56399d5b1110704ecb7c768915ee83..d92b01f0f0b3265d69423c03ffb7f8427ce8c26b 100644 (file)
@@ -78,6 +78,9 @@ public:
     blackbox_change_window_focus,
     blackbox_cycle_window_focus,
 
+    openbox_show_root_menu,
+    openbox_show_workspace_menu,
+
     // NETWM atoms
     // root window properties
     net_supported,
index efb782a559ecea0f970336a7bd58b743a4ba590e..e8b8dcaaf5210b4985acda63be926f2d3075a5b9 100644 (file)
@@ -908,6 +908,28 @@ void Blackbox::process_event(XEvent *e) {
             }
           }
         }
+      } else if (e->xclient.message_type ==
+                 xatom->getAtom(XAtom::openbox_show_root_menu) ||
+                 e->xclient.message_type ==
+                 xatom->getAtom(XAtom::openbox_show_workspace_menu)) {
+        // find the screen the mouse is on
+        int x, y;
+        ScreenList::iterator it, end = screenList.end();
+        for (it = screenList.begin(); it != end; ++it) {
+          Window w;
+          int i;
+          unsigned int m;
+          if (XQueryPointer(getXDisplay(), (*it)->getRootWindow(),
+                            &w, &w, &x, &y, &i, &i, &m))
+            break;
+        }
+        if (it != end) {
+          if (e->xclient.message_type ==
+              xatom->getAtom(XAtom::openbox_show_root_menu))
+            (*it)->showRootMenu(x, y);
+          else
+            (*it)->showWorkspaceMenu(x, y);
+        }
       }
     }
 
index 31a90233abf87de9def9fd10910732d201163878..8f48a7830db5db4ea953ef1d4e7bed4ee7d1a212 100644 (file)
@@ -242,6 +242,16 @@ void screen::handleKeypress(const XEvent &e) {
     execCommand(it->string());
     return;
 
+  case Action::showRootMenu:
+    _xatom->sendClientMessage(rootWindow(), XAtom::openbox_show_root_menu,
+                              None);
+    return;
+
+  case Action::showWorkspaceMenu:
+    _xatom->sendClientMessage(rootWindow(), XAtom::openbox_show_workspace_menu,
+                              None);
+    return;
+
   default:
     break;
   }
This page took 0.034644 seconds and 4 git commands to generate.