Add client dragndrop in tag with mouse with mouse_move function
This commit is contained in:
@@ -11,7 +11,7 @@
|
|||||||
#define BARWIN_MASK \
|
#define BARWIN_MASK \
|
||||||
(SubstructureRedirectMask | SubstructureNotifyMask \
|
(SubstructureRedirectMask | SubstructureNotifyMask \
|
||||||
| ButtonMask | MouseMask | ExposureMask | VisibilityChangeMask \
|
| ButtonMask | MouseMask | ExposureMask | VisibilityChangeMask \
|
||||||
| StructureNotifyMask | SubstructureRedirectMask)
|
| StructureNotifyMask)
|
||||||
|
|
||||||
#define BARWIN_ENTERMASK (EnterWindowMask | LeaveWindowMask | FocusChangeMask)
|
#define BARWIN_ENTERMASK (EnterWindowMask | LeaveWindowMask | FocusChangeMask)
|
||||||
#define BARWIN_WINCW (CWOverrideRedirect | CWBackPixmap | CWEventMask)
|
#define BARWIN_WINCW (CWOverrideRedirect | CWBackPixmap | CWEventMask)
|
||||||
|
|||||||
@@ -73,6 +73,7 @@ static const struct { char *name; void (*func)(Uicb cmd); } uicb_list[] =
|
|||||||
/* Mouse */
|
/* Mouse */
|
||||||
{ "mouse_resize", uicb_mouse_resize },
|
{ "mouse_resize", uicb_mouse_resize },
|
||||||
{ "mouse_move", uicb_mouse_move },
|
{ "mouse_move", uicb_mouse_move },
|
||||||
|
{ "mouse_swap", uicb_mouse_move },
|
||||||
{ "mouse_tab", uicb_mouse_tab },
|
{ "mouse_tab", uicb_mouse_tab },
|
||||||
|
|
||||||
{ NULL, NULL }
|
{ NULL, NULL }
|
||||||
|
|||||||
@@ -91,5 +91,4 @@ infobar_gb_name(const char *name)
|
|||||||
return SLIST_FIRST(&s->infobars);
|
return SLIST_FIRST(&s->infobars);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif /* INFOBAR_H */
|
#endif /* INFOBAR_H */
|
||||||
|
|||||||
70
src/mouse.c
70
src/mouse.c
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
#include "wmfs.h"
|
#include "wmfs.h"
|
||||||
#include "mouse.h"
|
#include "mouse.h"
|
||||||
|
#include "barwin.h"
|
||||||
#include "client.h"
|
#include "client.h"
|
||||||
#include "draw.h"
|
#include "draw.h"
|
||||||
|
|
||||||
@@ -68,17 +69,35 @@ mouse_resize(struct client *c)
|
|||||||
XUngrabServer(W->dpy);
|
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);
|
#define _REV_SBORDER(c) draw_reversed_rect(W->root, &(c)->geo);
|
||||||
void
|
void
|
||||||
mouse_move(struct client *c, bool type)
|
mouse_move(struct client *c, bool type)
|
||||||
{
|
{
|
||||||
struct client *c2 = NULL, *last = c;
|
struct client *c2 = NULL, *last = c;
|
||||||
|
struct tag *t;
|
||||||
XEvent ev;
|
XEvent ev;
|
||||||
Window w;
|
Window w;
|
||||||
int d, u;
|
int d, u;
|
||||||
|
|
||||||
XGrabServer(W->dpy);
|
|
||||||
|
|
||||||
if(c->flags & CLIENT_TABBED && !(c->flags & CLIENT_TABMASTER))
|
if(c->flags & CLIENT_TABBED && !(c->flags & CLIENT_TABMASTER))
|
||||||
c = c->tabmaster;
|
c = c->tabmaster;
|
||||||
|
|
||||||
@@ -97,28 +116,36 @@ mouse_move(struct client *c, bool type)
|
|||||||
if(!(c2 = client_gb_frame(w)))
|
if(!(c2 = client_gb_frame(w)))
|
||||||
c2 = client_gb_titlebar(w);
|
c2 = client_gb_titlebar(w);
|
||||||
|
|
||||||
if(c2 && c2 != last)
|
if(c2)
|
||||||
{
|
{
|
||||||
_REV_SBORDER(last);
|
if(c2 != last)
|
||||||
_REV_SBORDER(c2);
|
{
|
||||||
last = c2;
|
_REV_SBORDER(last);
|
||||||
|
_REV_SBORDER(c2);
|
||||||
|
last = c2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
t = mouse_drag_tag(c, w);
|
||||||
|
|
||||||
XSync(W->dpy, false);
|
XSync(W->dpy, false);
|
||||||
|
|
||||||
} while(ev.type != ButtonRelease);
|
} while(ev.type != ButtonRelease);
|
||||||
|
|
||||||
if(c2 && c2 != c)
|
if(c2)
|
||||||
{
|
{
|
||||||
_REV_SBORDER(c2);
|
if(c2 != c)
|
||||||
|
{
|
||||||
|
_REV_SBORDER(c2);
|
||||||
|
|
||||||
if(type)
|
if(type)
|
||||||
client_swap2(c, c2);
|
client_swap2(c, c2);
|
||||||
else
|
else
|
||||||
_client_tab(c, c2);
|
_client_tab(c, c2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
else if(t)
|
||||||
XUngrabServer(W->dpy);
|
tag_client(t, c);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -126,9 +153,8 @@ uicb_mouse_resize(Uicb cmd)
|
|||||||
{
|
{
|
||||||
(void)cmd;
|
(void)cmd;
|
||||||
|
|
||||||
if(mouse_check_client(W->client))
|
if(W->client && mouse_check_client(W->client))
|
||||||
if(W->client)
|
mouse_resize(W->client);
|
||||||
mouse_resize(W->client);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -136,9 +162,8 @@ uicb_mouse_move(Uicb cmd)
|
|||||||
{
|
{
|
||||||
(void)cmd;
|
(void)cmd;
|
||||||
|
|
||||||
if(mouse_check_client(W->client))
|
if(W->client && mouse_check_client(W->client))
|
||||||
if(W->client)
|
mouse_move(W->client, true);
|
||||||
mouse_move(W->client, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -146,7 +171,6 @@ uicb_mouse_tab(Uicb cmd)
|
|||||||
{
|
{
|
||||||
(void)cmd;
|
(void)cmd;
|
||||||
|
|
||||||
if(mouse_check_client(W->client))
|
if(W->client && mouse_check_client(W->client))
|
||||||
if(W->client)
|
mouse_move(W->client, false);
|
||||||
mouse_move(W->client, false);
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user