Add client dragndrop in tag with mouse with mouse_move function

This commit is contained in:
Martin Duquesnoy 2012-01-14 01:46:38 +01:00
parent 38f122abbb
commit 0f185a8121
5 changed files with 50 additions and 25 deletions

View File

@ -11,7 +11,7 @@
#define BARWIN_MASK \
(SubstructureRedirectMask | SubstructureNotifyMask \
| ButtonMask | MouseMask | ExposureMask | VisibilityChangeMask \
| StructureNotifyMask | SubstructureRedirectMask)
| StructureNotifyMask)
#define BARWIN_ENTERMASK (EnterWindowMask | LeaveWindowMask | FocusChangeMask)
#define BARWIN_WINCW (CWOverrideRedirect | CWBackPixmap | CWEventMask)

View File

@ -73,6 +73,7 @@ static const struct { char *name; void (*func)(Uicb cmd); } uicb_list[] =
/* Mouse */
{ "mouse_resize", uicb_mouse_resize },
{ "mouse_move", uicb_mouse_move },
{ "mouse_swap", uicb_mouse_move },
{ "mouse_tab", uicb_mouse_tab },
{ NULL, NULL }

View File

@ -91,5 +91,4 @@ infobar_gb_name(const char *name)
return SLIST_FIRST(&s->infobars);
}
#endif /* INFOBAR_H */

View File

@ -5,6 +5,7 @@
#include "wmfs.h"
#include "mouse.h"
#include "barwin.h"
#include "client.h"
#include "draw.h"
@ -68,17 +69,35 @@ mouse_resize(struct client *c)
XUngrabServer(W->dpy);
}
static struct tag*
mouse_drag_tag(struct client *c, Window w)
{
struct barwin *b;
struct tag *t;
Window rw;
int d, u;
XQueryPointer(W->dpy, w, &rw, &rw, &d, &d, &d, &d, (uint *)&u);
SLIST_FOREACH(b, &W->h.barwin, next)
if(b->win == rw
&& (t = (struct tag*)b->ptr)
&& t != c->tag)
return t;
return NULL;
}
#define _REV_SBORDER(c) draw_reversed_rect(W->root, &(c)->geo);
void
mouse_move(struct client *c, bool type)
{
struct client *c2 = NULL, *last = c;
struct tag *t;
XEvent ev;
Window w;
int d, u;
XGrabServer(W->dpy);
if(c->flags & CLIENT_TABBED && !(c->flags & CLIENT_TABMASTER))
c = c->tabmaster;
@ -97,28 +116,36 @@ mouse_move(struct client *c, bool type)
if(!(c2 = client_gb_frame(w)))
c2 = client_gb_titlebar(w);
if(c2 && c2 != last)
if(c2)
{
_REV_SBORDER(last);
_REV_SBORDER(c2);
last = c2;
if(c2 != last)
{
_REV_SBORDER(last);
_REV_SBORDER(c2);
last = c2;
}
}
else
t = mouse_drag_tag(c, w);
XSync(W->dpy, false);
} while(ev.type != ButtonRelease);
if(c2 && c2 != c)
if(c2)
{
_REV_SBORDER(c2);
if(c2 != c)
{
_REV_SBORDER(c2);
if(type)
client_swap2(c, c2);
else
_client_tab(c, c2);
if(type)
client_swap2(c, c2);
else
_client_tab(c, c2);
}
}
XUngrabServer(W->dpy);
else if(t)
tag_client(t, c);
}
void
@ -126,9 +153,8 @@ uicb_mouse_resize(Uicb cmd)
{
(void)cmd;
if(mouse_check_client(W->client))
if(W->client)
mouse_resize(W->client);
if(W->client && mouse_check_client(W->client))
mouse_resize(W->client);
}
void
@ -136,9 +162,8 @@ uicb_mouse_move(Uicb cmd)
{
(void)cmd;
if(mouse_check_client(W->client))
if(W->client)
mouse_move(W->client, true);
if(W->client && mouse_check_client(W->client))
mouse_move(W->client, true);
}
void
@ -146,7 +171,6 @@ uicb_mouse_tab(Uicb cmd)
{
(void)cmd;
if(mouse_check_client(W->client))
if(W->client)
mouse_move(W->client, false);
if(W->client && mouse_check_client(W->client))
mouse_move(W->client, false);
}

View File

@ -84,6 +84,7 @@ tag_client(struct tag *t, struct client *c)
c->prevtag = c->tag;
c->tag = t;
c->screen = t->screen;
client_update_props(c, CPROP_LOC);