From 8a48fff773dea20ab93ee8f22b281e852b51242e Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Thu, 22 Aug 2002 00:57:29 +0000 Subject: [PATCH] support for showing the root and workspace menu with epist --- src/Screen.cc | 82 +++++++++++++++++++++++++------------------- src/Screen.hh | 3 ++ src/XAtom.cc | 3 ++ src/XAtom.hh | 3 ++ src/blackbox.cc | 22 ++++++++++++ util/epist/screen.cc | 10 ++++++ 6 files changed, 87 insertions(+), 36 deletions(-) diff --git a/src/Screen.cc b/src/Screen.cc index 31811fe6..acde7736 100644 --- a/src/Screen.cc +++ b/src/Screen.cc @@ -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 diff --git a/src/Screen.hh b/src/Screen.hh index 4b454e02..6d12f320 100644 --- a/src/Screen.hh +++ b/src/Screen.hh @@ -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); diff --git a/src/XAtom.cc b/src/XAtom.cc index 15bbc262..e0fac57c 100644 --- a/src/XAtom.cc +++ b/src/XAtom.cc @@ -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"); diff --git a/src/XAtom.hh b/src/XAtom.hh index 2def1c6c..d92b01f0 100644 --- a/src/XAtom.hh +++ b/src/XAtom.hh @@ -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, diff --git a/src/blackbox.cc b/src/blackbox.cc index efb782a5..e8b8dcaa 100644 --- a/src/blackbox.cc +++ b/src/blackbox.cc @@ -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); + } } } diff --git a/util/epist/screen.cc b/util/epist/screen.cc index 31a90233..8f48a783 100644 --- a/util/epist/screen.cc +++ b/util/epist/screen.cc @@ -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; } -- 2.39.2