support for showing the root and workspace menu with epist
This commit is contained in:
parent
f44e3ed9a7
commit
8a48fff773
6 changed files with 87 additions and 36 deletions
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue