[
Thread Prev][
Thread Next] >
Date Index
>
Thread Index
[wmx] Patch: menu on right mouse button.
Sven Oliver Moll -
Tue Nov 18 19:20:14 2003
Hello Chris, hello list!
Here's a patch that implements a "window action" menu if pressed on the
border. You'll need to set the "options"-link to "right:menu" to use it.
Now, pressing right mouse button on the border activates a menu, that
lets you choose to (un)maximise the window (horizontal, vertical and both),
lower, hide (inconify) or kill (close) it.
Next thing I'll be hacking on will be Xinerama-support.
Greetings from Germany,
SvOlli
--
_______
( /\ | ...and there ain't a goddamned thing anyone can do about it,
__)v\/lli a.k.a. | You know why? Because we got the bombs, that's why. Two
Sven Oliver Moll | words: Nuclear fucking weapons, okay? -- Denis Leary
diff -burN wmx-6/Buttons.C wmx/Buttons.C
--- wmx-6/Buttons.C 2003-11-18 19:05:36.000000000 +0100
+++ wmx/Buttons.C 2003-11-18 19:06:01.000000000 +0100
@@ -35,6 +35,10 @@
}
}
}
+ else if (DynamicConfig::config.rightMenu())
+ {
+ if (e->window != e->root && c) TabMenu(this, (XEvent *)e);
+ }
return;
}
#endif
diff -burN wmx-6/Client.h wmx/Client.h
--- wmx-6/Client.h 2003-11-18 19:05:36.000000000 +0100
+++ wmx/Client.h 2003-11-18 19:06:01.000000000 +0100
@@ -85,6 +85,7 @@
void maximise(int);
void unmaximise(int);
Boolean isFullHeight() { return m_isFullHeight; }
+ Boolean isFullWidth() { return m_isFullWidth; }
void makeThisNormalHeight() { m_isFullHeight = False; }
void makeThisNormalWidth() { m_isFullWidth = False; }
diff -burN wmx-6/Config.C wmx/Config.C
--- wmx-6/Config.C 2003-11-18 19:05:36.000000000 +0100
+++ wmx/Config.C 2003-11-18 19:06:01.000000000 +0100
@@ -87,6 +87,7 @@
char DynamicConfig::rightCirculate() { return m_impl->rightBt & 1; }
char DynamicConfig::rightLower() { return m_impl->rightBt & 2; }
char DynamicConfig::rightToggleHeight() { return m_impl->rightBt & 4; }
+char DynamicConfig::rightMenu() { return m_impl->rightBt & 8; }
char *DynamicConfig::tabForeground() { return m_impl->tabfg; }
char *DynamicConfig::tabBackground() { return m_impl->tabbg; }
char *DynamicConfig::frameBackground() { return m_impl->framebg; }
@@ -150,6 +151,7 @@
else if (OPTION("circulate")) m_impl->rightBt = 1;
else if (OPTION("lower")) m_impl->rightBt = 2;
else if (OPTION("toggleheight")) m_impl->rightBt = 4;
+ else if (OPTION("menu")) m_impl->rightBt = 8;
if (OPTION("tabfg:")) strncpy(m_impl->tabfg, s, COLOR_LEN);
if (OPTION("tabbg:")) strncpy(m_impl->tabbg, s, COLOR_LEN);
diff -burN wmx-6/Config.h wmx/Config.h
--- wmx-6/Config.h 2003-11-18 19:05:36.000000000 +0100
+++ wmx/Config.h 2003-11-18 19:06:01.000000000 +0100
@@ -51,6 +51,7 @@
char rightCirculate();
char rightLower();
char rightToggleHeight();
+ char rightMenu();
char *tabForeground();
char *tabBackground();
char *frameBackground();
diff -burN wmx-6/Menu.C wmx/Menu.C
--- wmx-6/Menu.C 2003-11-18 19:05:36.000000000 +0100
+++ wmx/Menu.C 2003-11-18 19:06:01.000000000 +0100
@@ -884,6 +884,89 @@
// empty
}
+
+TabMenu::TabMenu(WindowManager *manager, XEvent *e)
+ : Menu(manager, e)
+{
+ enum {Vertical, Maximum, Horizontal};
+
+ XButtonEvent *ev = (XButtonEvent *)e;
+ char *entries[] =
+ { "(un)max height", "(un)max width" ,"(un)max both",
+ "lower", "hide", "kill", NULL };
+ ent = (char**)entries;
+
+ Client *c = m_windowManager->windowToClient(ev->window);
+ ev->x = ev->x_root; ev->y = ev->y_root;
+
+ int selection = getSelection();
+
+ switch(selection)
+ {
+ case 0:
+ if(c->isFullHeight())
+ {
+ c->unmaximise(Vertical);
+ }
+ else
+ {
+ c->maximise(Vertical);
+ }
+ break;
+ case 1:
+ if(c->isFullWidth())
+ {
+ c->unmaximise(Horizontal);
+ }
+ else
+ {
+ c->maximise(Horizontal);
+ }
+ break;
+ case 2:
+ if(c->isFullHeight() || c->isFullWidth())
+ {
+ c->unmaximise(Maximum);
+ c->unmaximise(Vertical);
+ c->unmaximise(Horizontal);
+ }
+ else
+ {
+ c->maximise(Maximum);
+ }
+ break;
+ case 3:
+ c->lower();
+ break;
+ case 4:
+ c->hide();
+ break;
+ case 5:
+ c->kill();
+ break;
+ }
+}
+
+TabMenu::~TabMenu()
+{
+}
+
+char **TabMenu::getItems(int *niR, int *nhR)
+{
+ char **c;
+ *niR = 0;
+ *nhR = 0;
+
+ for(c=ent; *c; c++)
+ {
+ (*niR)++;
+ }
+
+ *nhR = *niR - 1;
+ return ent;
+}
+
+
void ShowGeometry::update(int x, int y)
{
char string[20];
diff -burN wmx-6/Menu.h wmx/Menu.h
--- wmx-6/Menu.h 2003-11-18 19:05:36.000000000 +0100
+++ wmx/Menu.h 2003-11-18 19:06:01.000000000 +0100
@@ -103,6 +103,17 @@
#endif
};
+class TabMenu : public Menu
+{
+ public:
+ TabMenu(WindowManager *, XEvent *e);
+ virtual ~TabMenu();
+ private:
+ virtual char **getItems(int *, int *);
+ char **ent;
+};
+
+
class ShowGeometry : public Menu
{
public:
diff -burN wmx-6/configure.in wmx/configure.in
--- wmx-6/configure.in 2003-11-18 19:05:36.000000000 +0100
+++ wmx/configure.in 2003-11-18 19:06:01.000000000 +0100
@@ -8,6 +8,9 @@
AC_PATH_X
+dnl Command-line options
+AC_ARG_ENABLE(xpm,[ --disable-Xpm disable use of pixmaps])
+
dnl libX11 _is_ necessary
dnl and some systems do find it without any path.
@@ -28,7 +31,9 @@
AC_CHECK_LIB(Xext, XShapeQueryExtension)
dnl Xpm is not strictly necessary
-AC_CHECK_LIB(Xpm, XpmCreatePixmapFromData)
+if test x"$with_xpm" = "xyes" ; then
+ AC_CHECK_LIB(Xpm, XpmCreatePixmapFromData)
+fi
dnl We want to put wmx where twm lies.
AC_PREFIX_PROGRAM(twm)
Next: