From 0f3bc2ed0d0f593116bd3242738d892881744743 Mon Sep 17 00:00:00 2001 From: Martin Duquesnoy Date: Sun, 29 Jan 2012 01:35:41 +0100 Subject: [PATCH] Allow client move among screens in free mode --- src/client.c | 33 +++++++++++++++++++++++++++++---- src/draw.h | 13 ------------- src/mouse.c | 8 ++++++++ src/tag.c | 1 - src/wmfs.h | 1 + 5 files changed, 38 insertions(+), 18 deletions(-) diff --git a/src/client.c b/src/client.c index 1ba5143..03500cf 100644 --- a/src/client.c +++ b/src/client.c @@ -1086,6 +1086,32 @@ client_moveresize(struct client *c, struct geo *g) c->wgeo.y = c->tbarw; c->geo.w = c->rgeo.w = c->wgeo.w + c->border + c->border; c->geo.h = c->rgeo.h = c->wgeo.h + c->tbarw + c->border; + + c->rgeo.x += c->screen->ugeo.x; + c->rgeo.y += c->screen->ugeo.y; + + if(!INAREA(c->rgeo.x, c->rgeo.y, c->screen->ugeo)) + { + /* New screen (moved by mouse) */ + if(c->flags & CLIENT_MOUSE) + { + c->flags |= CLIENT_IGNORE_LAYOUT; + c->screen = screen_gb_geo(c->rgeo.x, c->rgeo.y); + tag_client(c->screen->seltag, c); + + c->geo.x = c->rgeo.x - c->screen->ugeo.x; + c->geo.y = c->rgeo.y - c->screen->ugeo.y; + + } + /* Out of the screen case */ + else + { + c->geo.x = (c->screen->ugeo.w >> 1) - (c->geo.w >> 1); + c->geo.y = (c->screen->ugeo.h >> 1) - (c->geo.h >> 1); + c->rgeo.x = c->screen->ugeo.x + c->geo.x; + c->rgeo.y = c->screen->ugeo.y + c->geo.y; + } + } } /* Adjust window regarding required size for frame (tiling) */ else @@ -1094,11 +1120,10 @@ client_moveresize(struct client *c, struct geo *g) if(!(c->flags & CLIENT_DID_WINSIZE)) client_winsize(c, g); - } - /* Real geo regarding full root size */ - c->rgeo.x += c->screen->ugeo.x; - c->rgeo.y += c->screen->ugeo.y; + c->rgeo.x += c->screen->ugeo.x; + c->rgeo.y += c->screen->ugeo.y; + } XMoveResizeWindow(W->dpy, c->frame, c->rgeo.x, c->rgeo.y, diff --git a/src/draw.h b/src/draw.h index dafa6d6..e6fb6d2 100644 --- a/src/draw.h +++ b/src/draw.h @@ -83,19 +83,6 @@ draw_reversed_rect(Drawable dr, struct client *c, bool t) g->h - (i << 1)); } -static inline void -draw_reversed_cross(Drawable dr, struct geo *g) -{ - int x = g->x + W->screen->ugeo.x; - int y = g->y + W->screen->ugeo.y; - - XDrawLine(W->dpy, dr, W->rgc, - x, y, x + g->w, y + g->h); - - XDrawLine(W->dpy, dr, W->rgc, - x + g->w, y, x, y + g->h); -} - static inline unsigned short draw_textw(struct theme *t, const char *str) { diff --git a/src/mouse.c b/src/mouse.c index dc3a50d..d4f3282 100644 --- a/src/mouse.c +++ b/src/mouse.c @@ -42,6 +42,8 @@ mouse_resize(struct client *c) ix = ox; iy = oy; + c->flags |= CLIENT_MOUSE; + do { XMaskEvent(W->dpy, MouseMask | SubstructureRedirectMask, &ev); @@ -110,6 +112,8 @@ mouse_resize(struct client *c) layout_save_set(c->tag); } + c->flags &= ~CLIENT_MOUSE; + XUngrabServer(W->dpy); } @@ -152,6 +156,8 @@ mouse_move(struct client *c, void (*func)(struct client*, struct client*)) _REV_SBORDER(c); + c->flags |= CLIENT_MOUSE; + do { XMaskEvent(W->dpy, MouseMask | SubstructureRedirectMask, &ev); @@ -205,6 +211,8 @@ mouse_move(struct client *c, void (*func)(struct client*, struct client*)) if(!func) client_moveresize(c, &c->geo); } + + c->flags &= ~CLIENT_MOUSE; } void diff --git a/src/tag.c b/src/tag.c index 3541e9d..4fd04c3 100644 --- a/src/tag.c +++ b/src/tag.c @@ -118,7 +118,6 @@ tag_client(struct tag *t, struct client *c) if(t != c->screen->seltag || c->flags & CLIENT_TABBED) client_unmap(c); - } void diff --git a/src/wmfs.h b/src/wmfs.h index 98a5b1b..bda56d9 100644 --- a/src/wmfs.h +++ b/src/wmfs.h @@ -198,6 +198,7 @@ struct client #define CLIENT_FULLSCREEN 0x800 #define CLIENT_FREE 0x1000 #define CLIENT_TILED 0x2000 +#define CLIENT_MOUSE 0x4000 Flags flags; Window win, frame, tmp; SLIST_ENTRY(client) next; /* Global list */