summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcos <cos>2023-11-07 12:30:51 +0100
committercos <cos>2023-11-07 12:31:29 +0100
commitce338a2c041c2237a42fefacb14b094194f6a86e (patch)
treec2369f94c560a32c9e745718c9c2c9b7bb30dc2e
parente4b558fa9e063be7e1a48d4d90d3f69f4ad3df71 (diff)
downloadmcwm-topic/obey_move.zip
Obey external window moves with option (-m)topic/obey_move
-rw-r--r--Makefile2
-rw-r--r--config.h8
-rw-r--r--mcwm.c53
3 files changed, 36 insertions, 27 deletions
diff --git a/Makefile b/Makefile
index ce0d71d..1bcb4d5 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-VERSION=20180725
+VERSION=20231107
DIST=mcwm-$(VERSION)
SRC=mcwm.c list.c config.h events.h list.h hidden.c
DISTFILES=LICENSE Makefile NEWS README TODO WISHLIST mcwm.man hidden.man scripts $(SRC)
diff --git a/config.h b/config.h
index 0129989..4e79b73 100644
--- a/config.h
+++ b/config.h
@@ -35,10 +35,16 @@
/*
* Do we allow windows to be iconified? Set to true if you want this
* behaviour to be default. Can also be set by calling mcwm with -i.
- */
+ */
#define ALLOWICONS false
/*
+ * Do we allow windows to be moved from outside of mcwm? Set to true if you
+ * want this behaviour to be default. Can also be set by calling mcwm with -m.
+ */
+#define ALLOWMOVE false
+
+/*
* Start these programs when pressing MOUSEMODKEY and mouse buttons on
* root window.
*/
diff --git a/mcwm.c b/mcwm.c
index 4cd773f..98b3963 100644
--- a/mcwm.c
+++ b/mcwm.c
@@ -285,6 +285,7 @@ struct conf
uint32_t unfocuscol; /* Unfocused border colour. */
uint32_t fixedcol; /* Fixed windows border colour. */
bool allowicons; /* Allow windows to be unmapped. */
+ bool allowmove; /* Obey move requests. */
} conf;
xcb_atom_t atom_desktop; /*
@@ -3440,37 +3441,34 @@ void configurerequest(xcb_configure_request_event_t *e)
mon_height = client->monitor->height;
}
-#if 0
- /*
- * We ignore moves the user haven't initiated, that is do
- * nothing on XCB_CONFIG_WINDOW_X and XCB_CONFIG_WINDOW_Y
- * ConfigureRequests.
- *
- * Code here if we ever change our minds or if you, dear user,
- * wants this functionality.
- */
+ if (conf.allowmove) {
+ /*
+ * Only act on move request the user haven't initiated, in case
+ * explicitly opted in. I.e. do nothing on XCB_CONFIG_WINDOW_X and
+ * XCB_CONFIG_WINDOW_Y ConfigureRequests by default.
+ */
- if (e->value_mask & XCB_CONFIG_WINDOW_X)
- {
- /* Don't move window if maximized. Don't move off the screen. */
- if (!client->maxed && e->x > 0)
+ if (e->value_mask & XCB_CONFIG_WINDOW_X)
{
- client->x = e->x;
+ /* Don't move window if maximized. Don't move off the screen. */
+ if (!client->maxed && e->x >= 0)
+ {
+ client->x = e->x;
+ }
}
- }
- if (e->value_mask & XCB_CONFIG_WINDOW_Y)
- {
- /*
- * Don't move window if maximized. Don't move off the
- * screen.
- */
- if (!client->maxed && !client->vertmaxed && e->y > 0)
+ if (e->value_mask & XCB_CONFIG_WINDOW_Y)
{
- client->y = e->y;
+ /*
+ * Don't move window if maximized. Don't move off the
+ * screen.
+ */
+ if (!client->maxed && !client->vertmaxed && e->y >= 0)
+ {
+ client->y = e->y;
+ }
}
}
-#endif
if (e->value_mask & XCB_CONFIG_WINDOW_WIDTH)
{
@@ -4345,13 +4343,14 @@ int main(int argc, char **argv)
conf.snapmargin = SNAPMARGIN;
conf.terminal = TERMINAL;
conf.allowicons = ALLOWICONS;
+ conf.allowmove = ALLOWMOVE;
focuscol = FOCUSCOL;
unfocuscol = UNFOCUSCOL;
fixedcol = FIXEDCOL;
while (1)
{
- ch = getopt(argc, argv, "b:s:it:f:u:x:");
+ ch = getopt(argc, argv, "b:s:imt:f:u:x:");
if (-1 == ch)
{
@@ -4375,6 +4374,10 @@ int main(int argc, char **argv)
conf.allowicons = true;
break;
+ case 'm':
+ conf.allowmove = true;
+ break;
+
case 't':
conf.terminal = optarg;
break;