Compare commits
2 Commits
linux
...
22cd0f5f43
| Author | SHA1 | Date | |
|---|---|---|---|
| 22cd0f5f43 | |||
| ca083f97bd |
3
calmwm.c
3
calmwm.c
@@ -116,8 +116,7 @@ main(int argc, char **argv)
|
|||||||
pfd[0].events = POLLIN;
|
pfd[0].events = POLLIN;
|
||||||
while (cwm_status == CWM_RUNNING) {
|
while (cwm_status == CWM_RUNNING) {
|
||||||
xev_process();
|
xev_process();
|
||||||
xev_handle_timeout();
|
if (poll(pfd, 1, -1) == -1) {
|
||||||
if (poll(pfd, 1, xev_pending_timeout()) == -1) {
|
|
||||||
if (errno != EINTR)
|
if (errno != EINTR)
|
||||||
warn("poll");
|
warn("poll");
|
||||||
}
|
}
|
||||||
|
|||||||
4
calmwm.h
4
calmwm.h
@@ -76,7 +76,6 @@ size_t strlcpy(char *, const char *, size_t);
|
|||||||
#define CWM_LEFT 0x0004
|
#define CWM_LEFT 0x0004
|
||||||
#define CWM_RIGHT 0x0008
|
#define CWM_RIGHT 0x0008
|
||||||
#define CWM_BIGAMOUNT 0x0010
|
#define CWM_BIGAMOUNT 0x0010
|
||||||
#define CWM_CENTER 0x0020
|
|
||||||
#define CWM_UP_BIG (CWM_UP | CWM_BIGAMOUNT)
|
#define CWM_UP_BIG (CWM_UP | CWM_BIGAMOUNT)
|
||||||
#define CWM_DOWN_BIG (CWM_DOWN | CWM_BIGAMOUNT)
|
#define CWM_DOWN_BIG (CWM_DOWN | CWM_BIGAMOUNT)
|
||||||
#define CWM_LEFT_BIG (CWM_LEFT | CWM_BIGAMOUNT)
|
#define CWM_LEFT_BIG (CWM_LEFT | CWM_BIGAMOUNT)
|
||||||
@@ -519,7 +518,6 @@ void screen_updatestackingorder(struct screen_ctx *);
|
|||||||
void kbfunc_cwm_status(void *, struct cargs *);
|
void kbfunc_cwm_status(void *, struct cargs *);
|
||||||
void kbfunc_ptrmove(void *, struct cargs *);
|
void kbfunc_ptrmove(void *, struct cargs *);
|
||||||
void kbfunc_client_snap(void *, struct cargs *);
|
void kbfunc_client_snap(void *, struct cargs *);
|
||||||
void kbfunc_client_snaptohalf(void *, struct cargs *);
|
|
||||||
void kbfunc_client_move(void *, struct cargs *);
|
void kbfunc_client_move(void *, struct cargs *);
|
||||||
void kbfunc_client_resize(void *, struct cargs *);
|
void kbfunc_client_resize(void *, struct cargs *);
|
||||||
void kbfunc_client_close(void *, struct cargs *);
|
void kbfunc_client_close(void *, struct cargs *);
|
||||||
@@ -586,8 +584,6 @@ void conf_screen(struct screen_ctx *);
|
|||||||
void conf_group(struct screen_ctx *);
|
void conf_group(struct screen_ctx *);
|
||||||
|
|
||||||
void xev_process(void);
|
void xev_process(void);
|
||||||
int xev_pending_timeout(void);
|
|
||||||
void xev_handle_timeout(void);
|
|
||||||
|
|
||||||
int xu_get_prop(Window, Atom, Atom, long, unsigned char **);
|
int xu_get_prop(Window, Atom, Atom, long, unsigned char **);
|
||||||
int xu_get_strprop(Window, Atom, char **);
|
int xu_get_strprop(Window, Atom, char **);
|
||||||
|
|||||||
2
client.c
2
client.c
@@ -79,8 +79,6 @@ client_init(Window win, struct screen_ctx *sc)
|
|||||||
cc->geom.y = wattr.y;
|
cc->geom.y = wattr.y;
|
||||||
cc->geom.w = wattr.width;
|
cc->geom.w = wattr.width;
|
||||||
cc->geom.h = wattr.height;
|
cc->geom.h = wattr.height;
|
||||||
cc->savegeom = cc->geom;
|
|
||||||
cc->fullgeom = cc->geom;
|
|
||||||
cc->colormap = wattr.colormap;
|
cc->colormap = wattr.colormap;
|
||||||
cc->obwidth = wattr.border_width;
|
cc->obwidth = wattr.border_width;
|
||||||
cc->bwidth = Conf.bwidth;
|
cc->bwidth = Conf.bwidth;
|
||||||
|
|||||||
5
conf.c
5
conf.c
@@ -102,15 +102,10 @@ static const struct {
|
|||||||
{ FUNC_CC(window-movetogroup-7, client_movetogroup, 7) },
|
{ FUNC_CC(window-movetogroup-7, client_movetogroup, 7) },
|
||||||
{ FUNC_CC(window-movetogroup-8, client_movetogroup, 8) },
|
{ FUNC_CC(window-movetogroup-8, client_movetogroup, 8) },
|
||||||
{ FUNC_CC(window-movetogroup-9, client_movetogroup, 9) },
|
{ FUNC_CC(window-movetogroup-9, client_movetogroup, 9) },
|
||||||
{ FUNC_CC(window-snap-center, client_snap, (CWM_CENTER)) },
|
|
||||||
{ FUNC_CC(window-snap-up, client_snap, (CWM_UP)) },
|
{ FUNC_CC(window-snap-up, client_snap, (CWM_UP)) },
|
||||||
{ FUNC_CC(window-snap-down, client_snap, (CWM_DOWN)) },
|
{ FUNC_CC(window-snap-down, client_snap, (CWM_DOWN)) },
|
||||||
{ FUNC_CC(window-snap-right, client_snap, (CWM_RIGHT)) },
|
{ FUNC_CC(window-snap-right, client_snap, (CWM_RIGHT)) },
|
||||||
{ FUNC_CC(window-snap-left, client_snap, (CWM_LEFT)) },
|
{ FUNC_CC(window-snap-left, client_snap, (CWM_LEFT)) },
|
||||||
{ FUNC_CC(window-snap-up-half, client_snaptohalf, (CWM_UP)) },
|
|
||||||
{ FUNC_CC(window-snap-down-half, client_snaptohalf, (CWM_DOWN)) },
|
|
||||||
{ FUNC_CC(window-snap-right-half, client_snaptohalf, (CWM_RIGHT)) },
|
|
||||||
{ FUNC_CC(window-snap-left-half, client_snaptohalf, (CWM_LEFT)) },
|
|
||||||
{ FUNC_CC(window-snap-up-right, client_snap, (CWM_UP_RIGHT)) },
|
{ FUNC_CC(window-snap-up-right, client_snap, (CWM_UP_RIGHT)) },
|
||||||
{ FUNC_CC(window-snap-up-left, client_snap, (CWM_UP_LEFT)) },
|
{ FUNC_CC(window-snap-up-left, client_snap, (CWM_UP_LEFT)) },
|
||||||
{ FUNC_CC(window-snap-down-right, client_snap, (CWM_DOWN_RIGHT)) },
|
{ FUNC_CC(window-snap-down-right, client_snap, (CWM_DOWN_RIGHT)) },
|
||||||
|
|||||||
10
cwmrc.5
10
cwmrc.5
@@ -401,8 +401,6 @@ pixels right.
|
|||||||
Resize window 10 times
|
Resize window 10 times
|
||||||
.Ar moveamount
|
.Ar moveamount
|
||||||
pixels left.
|
pixels left.
|
||||||
.It window-snap-center
|
|
||||||
Snap window to center.
|
|
||||||
.It window-snap-up
|
.It window-snap-up
|
||||||
Snap window to top edge.
|
Snap window to top edge.
|
||||||
.It window-snap-down
|
.It window-snap-down
|
||||||
@@ -411,14 +409,6 @@ Snap window to bottom edge.
|
|||||||
Snap window to right edge.
|
Snap window to right edge.
|
||||||
.It window-snap-left
|
.It window-snap-left
|
||||||
Snap window to left edge.
|
Snap window to left edge.
|
||||||
.It window-snap-up-half
|
|
||||||
Snap and resize window to the top half of the screen.
|
|
||||||
.It window-snap-down-half
|
|
||||||
Snap and resize window to the bottom half of the screen.
|
|
||||||
.It window-snap-right-half
|
|
||||||
Snap and resize window to the right half of the screen.
|
|
||||||
.It window-snap-left-half
|
|
||||||
Snap and resize window to the left half of the screen.
|
|
||||||
.It window-snap-up-right
|
.It window-snap-up-right
|
||||||
Snap window to top-right corner.
|
Snap window to top-right corner.
|
||||||
.It window-snap-up-left
|
.It window-snap-up-left
|
||||||
|
|||||||
97
kbfunc.c
97
kbfunc.c
@@ -47,7 +47,6 @@ static void kbfunc_client_move_kb(void *, struct cargs *);
|
|||||||
static void kbfunc_client_move_mb(void *, struct cargs *);
|
static void kbfunc_client_move_mb(void *, struct cargs *);
|
||||||
static void kbfunc_client_resize_kb(void *, struct cargs *);
|
static void kbfunc_client_resize_kb(void *, struct cargs *);
|
||||||
static void kbfunc_client_resize_mb(void *, struct cargs *);
|
static void kbfunc_client_resize_mb(void *, struct cargs *);
|
||||||
static Bool kbfunc_discard_configurerequest(Display *, XEvent *, XPointer);
|
|
||||||
|
|
||||||
void
|
void
|
||||||
kbfunc_cwm_status(void *ctx, struct cargs *cargs)
|
kbfunc_cwm_status(void *ctx, struct cargs *cargs)
|
||||||
@@ -55,17 +54,6 @@ kbfunc_cwm_status(void *ctx, struct cargs *cargs)
|
|||||||
cwm_status = cargs->flag;
|
cwm_status = cargs->flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Bool
|
|
||||||
kbfunc_discard_configurerequest(Display *dpy, XEvent *ev, XPointer arg)
|
|
||||||
{
|
|
||||||
Window *win = (Window *)arg;
|
|
||||||
|
|
||||||
(void)dpy;
|
|
||||||
|
|
||||||
return (ev->type == ConfigureRequest &&
|
|
||||||
ev->xconfigurerequest.window == *win);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
kbfunc_amount(int flags, int amt, int *mx, int *my)
|
kbfunc_amount(int flags, int amt, int *mx, int *my)
|
||||||
{
|
{
|
||||||
@@ -177,7 +165,7 @@ kbfunc_client_move_mb(void *ctx, struct cargs *cargs)
|
|||||||
|
|
||||||
client_ptr_inbound(cc, 1);
|
client_ptr_inbound(cc, 1);
|
||||||
|
|
||||||
if (XGrabPointer(X_Dpy, sc->rootwin, False, MOUSEMASK,
|
if (XGrabPointer(X_Dpy, cc->win, False, MOUSEMASK,
|
||||||
GrabModeAsync, GrabModeAsync, None, Conf.cursor[CF_MOVE],
|
GrabModeAsync, GrabModeAsync, None, Conf.cursor[CF_MOVE],
|
||||||
CurrentTime) != GrabSuccess)
|
CurrentTime) != GrabSuccess)
|
||||||
return;
|
return;
|
||||||
@@ -254,7 +242,6 @@ kbfunc_client_resize_mb(void *ctx, struct cargs *cargs)
|
|||||||
{
|
{
|
||||||
struct client_ctx *cc = ctx;
|
struct client_ctx *cc = ctx;
|
||||||
XEvent ev;
|
XEvent ev;
|
||||||
XEvent cev;
|
|
||||||
Time ltime = 0;
|
Time ltime = 0;
|
||||||
struct screen_ctx *sc = cc->sc;
|
struct screen_ctx *sc = cc->sc;
|
||||||
int resize = 1;
|
int resize = 1;
|
||||||
@@ -267,7 +254,7 @@ kbfunc_client_resize_mb(void *ctx, struct cargs *cargs)
|
|||||||
|
|
||||||
xu_ptr_set(cc->win, cc->geom.w, cc->geom.h);
|
xu_ptr_set(cc->win, cc->geom.w, cc->geom.h);
|
||||||
|
|
||||||
if (XGrabPointer(X_Dpy, sc->rootwin, False, MOUSEMASK,
|
if (XGrabPointer(X_Dpy, cc->win, False, MOUSEMASK,
|
||||||
GrabModeAsync, GrabModeAsync, None, Conf.cursor[CF_RESIZE],
|
GrabModeAsync, GrabModeAsync, None, Conf.cursor[CF_RESIZE],
|
||||||
CurrentTime) != GrabSuccess)
|
CurrentTime) != GrabSuccess)
|
||||||
return;
|
return;
|
||||||
@@ -283,8 +270,8 @@ kbfunc_client_resize_mb(void *ctx, struct cargs *cargs)
|
|||||||
continue;
|
continue;
|
||||||
ltime = ev.xmotion.time;
|
ltime = ev.xmotion.time;
|
||||||
|
|
||||||
cc->geom.w = ev.xmotion.x - cc->geom.x - cc->bwidth;
|
cc->geom.w = ev.xmotion.x;
|
||||||
cc->geom.h = ev.xmotion.y - cc->geom.y - cc->bwidth;
|
cc->geom.h = ev.xmotion.y;
|
||||||
client_apply_sizehints(cc);
|
client_apply_sizehints(cc);
|
||||||
client_resize(cc, 1);
|
client_resize(cc, 1);
|
||||||
screen_prop_win_draw(sc,
|
screen_prop_win_draw(sc,
|
||||||
@@ -295,19 +282,8 @@ kbfunc_client_resize_mb(void *ctx, struct cargs *cargs)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ltime) {
|
if (ltime)
|
||||||
/*
|
|
||||||
* A newly mapped client can queue a ConfigureRequest while the
|
|
||||||
* resize loop is consuming only mouse events. Drop those stale
|
|
||||||
* requests so the final drag geometry is not immediately
|
|
||||||
* overwritten when the main event loop resumes.
|
|
||||||
*/
|
|
||||||
while (XCheckIfEvent(X_Dpy, &cev,
|
|
||||||
kbfunc_discard_configurerequest,
|
|
||||||
(XPointer)&cc->win))
|
|
||||||
;
|
|
||||||
client_resize(cc, 1);
|
client_resize(cc, 1);
|
||||||
}
|
|
||||||
screen_prop_win_destroy(sc);
|
screen_prop_win_destroy(sc);
|
||||||
XUngrabPointer(X_Dpy, CurrentTime);
|
XUngrabPointer(X_Dpy, CurrentTime);
|
||||||
|
|
||||||
@@ -347,74 +323,11 @@ kbfunc_client_snap(void *ctx, struct cargs *cargs)
|
|||||||
(cc->bwidth * 2);
|
(cc->bwidth * 2);
|
||||||
flags &= ~CWM_DOWN;
|
flags &= ~CWM_DOWN;
|
||||||
}
|
}
|
||||||
if (flags & CWM_CENTER) {
|
|
||||||
cc->geom.x = area.x +
|
|
||||||
(area.w - cc->geom.w - cc->bwidth) / 2;
|
|
||||||
cc->geom.y = area.y +
|
|
||||||
(area.h - cc->geom.h - cc->bwidth) / 2;
|
|
||||||
flags &= ~CWM_CENTER;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
client_move(cc);
|
client_move(cc);
|
||||||
client_ptr_inbound(cc, 1);
|
client_ptr_inbound(cc, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
kbfunc_client_snaptohalf(void *ctx, struct cargs *cargs)
|
|
||||||
{
|
|
||||||
struct client_ctx *cc = ctx;
|
|
||||||
struct screen_ctx *sc = cc->sc;
|
|
||||||
struct geom area;
|
|
||||||
int halfw, halfh;
|
|
||||||
|
|
||||||
if (cc->flags & CLIENT_FREEZE)
|
|
||||||
return;
|
|
||||||
|
|
||||||
area = screen_area(sc,
|
|
||||||
cc->geom.x + cc->geom.w / 2,
|
|
||||||
cc->geom.y + cc->geom.h / 2, 1);
|
|
||||||
halfw = area.w / 2;
|
|
||||||
halfh = area.h / 2;
|
|
||||||
|
|
||||||
switch (cargs->flag) {
|
|
||||||
case CWM_UP:
|
|
||||||
cc->geom.x = area.x;
|
|
||||||
cc->geom.y = area.y;
|
|
||||||
cc->geom.w = area.w - (cc->bwidth * 2);
|
|
||||||
cc->geom.h = halfh - (cc->bwidth * 2);
|
|
||||||
client_apply_sizehints(cc);
|
|
||||||
break;
|
|
||||||
case CWM_DOWN:
|
|
||||||
cc->geom.x = area.x;
|
|
||||||
cc->geom.w = area.w - (cc->bwidth * 2);
|
|
||||||
cc->geom.h = area.h - halfh - (cc->bwidth * 2);
|
|
||||||
client_apply_sizehints(cc);
|
|
||||||
cc->geom.y = area.y + area.h - cc->geom.h -
|
|
||||||
(cc->bwidth * 2);
|
|
||||||
break;
|
|
||||||
case CWM_LEFT:
|
|
||||||
cc->geom.x = area.x;
|
|
||||||
cc->geom.y = area.y;
|
|
||||||
cc->geom.w = halfw - (cc->bwidth * 2);
|
|
||||||
cc->geom.h = area.h - (cc->bwidth * 2);
|
|
||||||
client_apply_sizehints(cc);
|
|
||||||
break;
|
|
||||||
case CWM_RIGHT:
|
|
||||||
cc->geom.y = area.y;
|
|
||||||
cc->geom.w = area.w - halfw - (cc->bwidth * 2);
|
|
||||||
cc->geom.h = area.h - (cc->bwidth * 2);
|
|
||||||
client_apply_sizehints(cc);
|
|
||||||
cc->geom.x = area.x + area.w - cc->geom.w -
|
|
||||||
(cc->bwidth * 2);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
client_resize(cc, 1);
|
|
||||||
client_ptr_inbound(cc, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
kbfunc_client_close(void *ctx, struct cargs *cargs)
|
kbfunc_client_close(void *ctx, struct cargs *cargs)
|
||||||
{
|
{
|
||||||
|
|||||||
136
xevents.c
136
xevents.c
@@ -30,10 +30,11 @@
|
|||||||
#include <err.h>
|
#include <err.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
#include <pthread.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <time.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "calmwm.h"
|
#include "calmwm.h"
|
||||||
|
|
||||||
@@ -51,12 +52,6 @@ static void xev_handle_clientmessage(XEvent *);
|
|||||||
static void xev_handle_randr(XEvent *);
|
static void xev_handle_randr(XEvent *);
|
||||||
static void xev_handle_mappingnotify(XEvent *);
|
static void xev_handle_mappingnotify(XEvent *);
|
||||||
static void xev_handle_expose(XEvent *);
|
static void xev_handle_expose(XEvent *);
|
||||||
static void xev_cancel_hover_raise(void);
|
|
||||||
static void xev_schedule_hover_raise(Window);
|
|
||||||
static long long xev_now_ms(void);
|
|
||||||
|
|
||||||
static Window hover_raise_win = None;
|
|
||||||
static long long hover_raise_at = -1;
|
|
||||||
|
|
||||||
void (*xev_handlers[LASTEvent])(XEvent *) = {
|
void (*xev_handlers[LASTEvent])(XEvent *) = {
|
||||||
[MapRequest] = xev_handle_maprequest,
|
[MapRequest] = xev_handle_maprequest,
|
||||||
@@ -74,84 +69,8 @@ void (*xev_handlers[LASTEvent])(XEvent *) = {
|
|||||||
[Expose] = xev_handle_expose,
|
[Expose] = xev_handle_expose,
|
||||||
};
|
};
|
||||||
|
|
||||||
static KeySym modkeys[] = { XK_Control_L, XK_Control_R,
|
static KeySym modkeys[] = { XK_Alt_L, XK_Alt_R, XK_Super_L, XK_Super_R,
|
||||||
XK_Alt_L, XK_Alt_R,
|
XK_Control_L, XK_Control_R, XK_ISO_Level3_Shift };
|
||||||
XK_Meta_L, XK_Meta_R,
|
|
||||||
XK_Super_L, XK_Super_R,
|
|
||||||
XK_ISO_Level3_Shift };
|
|
||||||
|
|
||||||
static long long
|
|
||||||
xev_now_ms(void)
|
|
||||||
{
|
|
||||||
struct timespec ts;
|
|
||||||
|
|
||||||
clock_gettime(CLOCK_MONOTONIC, &ts);
|
|
||||||
return ((long long)ts.tv_sec * 1000LL + ts.tv_nsec / 1000000LL);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
xev_cancel_hover_raise(void)
|
|
||||||
{
|
|
||||||
hover_raise_win = None;
|
|
||||||
hover_raise_at = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
xev_schedule_hover_raise(Window win)
|
|
||||||
{
|
|
||||||
if (!Conf.raiseonhover || Conf.raisedelay < 0) {
|
|
||||||
xev_cancel_hover_raise();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
hover_raise_win = win;
|
|
||||||
hover_raise_at = xev_now_ms() + Conf.raisedelay;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
xev_pending_timeout(void)
|
|
||||||
{
|
|
||||||
long long now, remaining;
|
|
||||||
|
|
||||||
if (hover_raise_win == None)
|
|
||||||
return (-1);
|
|
||||||
|
|
||||||
now = xev_now_ms();
|
|
||||||
remaining = hover_raise_at - now;
|
|
||||||
if (remaining <= 0)
|
|
||||||
return (0);
|
|
||||||
if (remaining > INT_MAX)
|
|
||||||
return (INT_MAX);
|
|
||||||
return ((int)remaining);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
xev_handle_timeout(void)
|
|
||||||
{
|
|
||||||
struct client_ctx *cc;
|
|
||||||
Window win;
|
|
||||||
Window rwin, cwin;
|
|
||||||
int rx, ry, wx, wy;
|
|
||||||
unsigned int mask;
|
|
||||||
|
|
||||||
if (hover_raise_win == None || xev_now_ms() < hover_raise_at)
|
|
||||||
return;
|
|
||||||
|
|
||||||
win = hover_raise_win;
|
|
||||||
xev_cancel_hover_raise();
|
|
||||||
|
|
||||||
if ((cc = client_find(win)) == NULL || !(cc->flags & CLIENT_ACTIVE))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!XQueryPointer(X_Dpy, cc->sc->rootwin, &rwin, &cwin,
|
|
||||||
&rx, &ry, &wx, &wy, &mask))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (cwin == cc->win) {
|
|
||||||
client_raise(cc);
|
|
||||||
XFlush(X_Dpy);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
xev_handle_maprequest(XEvent *ee)
|
xev_handle_maprequest(XEvent *ee)
|
||||||
@@ -301,6 +220,31 @@ xev_handle_propertynotify(XEvent *ee)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void*
|
||||||
|
delay_raise(void* data)
|
||||||
|
{
|
||||||
|
struct client_ctx *cc;
|
||||||
|
Window *w = (Window*)data;
|
||||||
|
|
||||||
|
int delay = Conf.raisedelay * 1000;
|
||||||
|
usleep(delay);
|
||||||
|
if ((cc = client_find(*w)) != NULL) {
|
||||||
|
if (cc->flags & CLIENT_ACTIVE) {
|
||||||
|
client_raise(cc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
free(w);
|
||||||
|
|
||||||
|
XEvent e;
|
||||||
|
|
||||||
|
XNextEvent(X_Dpy, &e);
|
||||||
|
if ((e.type - Conf.xrandr_event_base) == RRScreenChangeNotify)
|
||||||
|
xev_handle_randr(&e);
|
||||||
|
else if ((e.type < LASTEvent) && (xev_handlers[e.type] != NULL))
|
||||||
|
(*xev_handlers[e.type])(&e);
|
||||||
|
pthread_exit(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
xev_handle_enternotify(XEvent *ee)
|
xev_handle_enternotify(XEvent *ee)
|
||||||
{
|
{
|
||||||
@@ -314,20 +258,14 @@ xev_handle_enternotify(XEvent *ee)
|
|||||||
if ((cc = client_find(e->window)) != NULL)
|
if ((cc = client_find(e->window)) != NULL)
|
||||||
client_set_active(cc);
|
client_set_active(cc);
|
||||||
|
|
||||||
if (!Conf.raiseonhover)
|
if (Conf.raiseonhover) {
|
||||||
return;
|
Window *w;
|
||||||
|
w = (Window*)malloc(sizeof(Window));
|
||||||
|
memcpy(w, &e->window, sizeof(Window));
|
||||||
|
|
||||||
if (e->mode != NotifyNormal || e->detail == NotifyInferior)
|
pthread_t thread_id;
|
||||||
return;
|
pthread_create(&thread_id, NULL, delay_raise, w);
|
||||||
|
|
||||||
if (e->state & (Button1Mask | Button2Mask | Button3Mask |
|
|
||||||
Button4Mask | Button5Mask)) {
|
|
||||||
xev_cancel_hover_raise();
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cc != NULL)
|
|
||||||
xev_schedule_hover_raise(cc->win);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -344,8 +282,6 @@ xev_handle_buttonpress(XEvent *ee)
|
|||||||
if ((sc = screen_find(e->root)) == NULL)
|
if ((sc = screen_find(e->root)) == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
xev_cancel_hover_raise();
|
|
||||||
|
|
||||||
e->state &= ~IGNOREMODMASK;
|
e->state &= ~IGNOREMODMASK;
|
||||||
|
|
||||||
TAILQ_FOREACH(mb, &Conf.mousebindq, entry) {
|
TAILQ_FOREACH(mb, &Conf.mousebindq, entry) {
|
||||||
@@ -588,7 +524,5 @@ xev_process(void)
|
|||||||
xev_handle_randr(&e);
|
xev_handle_randr(&e);
|
||||||
else if ((e.type < LASTEvent) && (xev_handlers[e.type] != NULL))
|
else if ((e.type < LASTEvent) && (xev_handlers[e.type] != NULL))
|
||||||
(*xev_handlers[e.type])(&e);
|
(*xev_handlers[e.type])(&e);
|
||||||
xev_handle_timeout();
|
|
||||||
}
|
}
|
||||||
xev_handle_timeout();
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user