Compare commits

...

7 Commits

Author SHA1 Message Date
37090bd2ba add raise on hover 2026-04-19 16:19:55 -04:00
ba8e24c95a add scalefactor to cwmrc 2026-04-19 16:19:55 -04:00
okan
d7120f4eaa cvsimport
* refs/heads/master:
  handle Meta release as a separate mod key.
  add window-snap-center function
2026-01-05 14:46:59 +00:00
okan
fe0b4b28bd handle Meta release as a separate mod key.
from Sven M. Hallberg
2026-01-05 14:46:59 +00:00
job
d59960199b add window-snap-center function
OK tb@ okan@
2025-08-20 23:44:06 +00:00
okan
172b4dd0f8 cvsimport
* refs/heads/master:
  Grab the pointer against the root window instead of the client we're attempting to move and/or resize; prevents XNextEvent() from blocking on a client that might have been moved to a Withdrawn state.
2024-04-10 19:38:22 +00:00
okan
2a2d268cb0 Grab the pointer against the root window instead of the client we're attempting
to move and/or resize; prevents XNextEvent() from blocking on a client that
might have been moved to a Withdrawn state.

behavior noticed and reported by zenitds at proton.me - thanks!
2024-04-10 19:38:22 +00:00
6 changed files with 84 additions and 9 deletions

View File

@@ -76,6 +76,7 @@ size_t strlcpy(char *, const char *, size_t);
#define CWM_LEFT 0x0004
#define CWM_RIGHT 0x0008
#define CWM_BIGAMOUNT 0x0010
#define CWM_CENTER 0x0020
#define CWM_UP_BIG (CWM_UP | CWM_BIGAMOUNT)
#define CWM_DOWN_BIG (CWM_DOWN | CWM_BIGAMOUNT)
#define CWM_LEFT_BIG (CWM_LEFT | CWM_BIGAMOUNT)
@@ -313,6 +314,9 @@ struct conf {
int nameqlen;
int bwidth;
int mamount;
int scalefactor;
int raiseonhover;
int raisedelay;
int snapdist;
int htile;
int vtile;

4
conf.c
View File

@@ -102,6 +102,7 @@ static const struct {
{ FUNC_CC(window-movetogroup-7, client_movetogroup, 7) },
{ FUNC_CC(window-movetogroup-8, client_movetogroup, 8) },
{ 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-down, client_snap, (CWM_DOWN)) },
{ FUNC_CC(window-snap-right, client_snap, (CWM_RIGHT)) },
@@ -288,6 +289,9 @@ conf_init(struct conf *c)
c->stickygroups = 0;
c->bwidth = 1;
c->mamount = 1;
c->scalefactor = 10;
c->raiseonhover = 1;
c->raisedelay = 250;
c->htile = 50;
c->vtile = 50;
c->snapdist = 0;

View File

@@ -401,6 +401,8 @@ pixels right.
Resize window 10 times
.Ar moveamount
pixels left.
.It window-snap-center
Snap window to center.
.It window-snap-up
Snap window to top edge.
.It window-snap-down

View File

@@ -57,7 +57,7 @@ kbfunc_cwm_status(void *ctx, struct cargs *cargs)
static void
kbfunc_amount(int flags, int amt, int *mx, int *my)
{
#define CWM_FACTOR 10
#define CWM_FACTOR Conf.scalefactor
if (flags & CWM_BIGAMOUNT)
amt *= CWM_FACTOR;
@@ -165,7 +165,7 @@ kbfunc_client_move_mb(void *ctx, struct cargs *cargs)
client_ptr_inbound(cc, 1);
if (XGrabPointer(X_Dpy, cc->win, False, MOUSEMASK,
if (XGrabPointer(X_Dpy, sc->rootwin, False, MOUSEMASK,
GrabModeAsync, GrabModeAsync, None, Conf.cursor[CF_MOVE],
CurrentTime) != GrabSuccess)
return;
@@ -254,7 +254,7 @@ kbfunc_client_resize_mb(void *ctx, struct cargs *cargs)
xu_ptr_set(cc->win, cc->geom.w, cc->geom.h);
if (XGrabPointer(X_Dpy, cc->win, False, MOUSEMASK,
if (XGrabPointer(X_Dpy, sc->rootwin, False, MOUSEMASK,
GrabModeAsync, GrabModeAsync, None, Conf.cursor[CF_RESIZE],
CurrentTime) != GrabSuccess)
return;
@@ -270,8 +270,8 @@ kbfunc_client_resize_mb(void *ctx, struct cargs *cargs)
continue;
ltime = ev.xmotion.time;
cc->geom.w = ev.xmotion.x;
cc->geom.h = ev.xmotion.y;
cc->geom.w = ev.xmotion.x - cc->geom.x - cc->bwidth;
cc->geom.h = ev.xmotion.y - cc->geom.y - cc->bwidth;
client_apply_sizehints(cc);
client_resize(cc, 1);
screen_prop_win_draw(sc,
@@ -323,6 +323,13 @@ kbfunc_client_snap(void *ctx, struct cargs *cargs)
(cc->bwidth * 2);
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_ptr_inbound(cc, 1);

24
parse.y
View File

@@ -71,9 +71,9 @@ typedef struct {
%}
%token BINDKEY UNBINDKEY BINDMOUSE UNBINDMOUSE
%token FONTNAME STICKY GAP
%token FONTNAME STICKY RAISEONHOVER RAISEONHOVERDELAY GAP
%token AUTOGROUP COMMAND IGNORE WM
%token YES NO BORDERWIDTH MOVEAMOUNT HTILE VTILE
%token YES NO BORDERWIDTH MOVEAMOUNT SCALEFACTOR HTILE VTILE
%token COLOR SNAPDIST
%token ACTIVEBORDER INACTIVEBORDER URGENCYBORDER
%token GROUPBORDER UNGROUPBORDER
@@ -128,6 +128,16 @@ main : FONTNAME STRING {
| STICKY yesno {
conf->stickygroups = $2;
}
| RAISEONHOVER yesno {
conf->raiseonhover = $2;
}
| RAISEONHOVERDELAY NUMBER {
if ($2 < 0 || $2 > INT_MAX) {
yyerror("invalid delay");
YYERROR;
}
conf->raisedelay = $2;
}
| BORDERWIDTH NUMBER {
if ($2 < 0 || $2 > INT_MAX) {
yyerror("invalid borderwidth");
@@ -156,6 +166,13 @@ main : FONTNAME STRING {
}
conf->mamount = $2;
}
| SCALEFACTOR NUMBER {
if ($2 < 0 || $2 > INT_MAX) {
yyerror("invalid scalefactor");
YYERROR;
}
conf->scalefactor = $2;
}
| SNAPDIST NUMBER {
if ($2 < 0 || $2 > INT_MAX) {
yyerror("invalid snapdist");
@@ -350,6 +367,9 @@ lookup(char *s)
{ "menufg", MENUFG},
{ "moveamount", MOVEAMOUNT},
{ "no", NO},
{ "raise-delay", RAISEONHOVERDELAY},
{ "raise-on-hover", RAISEONHOVER},
{ "scalefactor", SCALEFACTOR},
{ "selfont", FONTSELCOLOR},
{ "snapdist", SNAPDIST},
{ "sticky", STICKY},

View File

@@ -30,6 +30,7 @@
#include <err.h>
#include <errno.h>
#include <limits.h>
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -68,8 +69,11 @@ void (*xev_handlers[LASTEvent])(XEvent *) = {
[Expose] = xev_handle_expose,
};
static KeySym modkeys[] = { XK_Alt_L, XK_Alt_R, XK_Super_L, XK_Super_R,
XK_Control_L, XK_Control_R, XK_ISO_Level3_Shift };
static KeySym modkeys[] = { XK_Control_L, XK_Control_R,
XK_Alt_L, XK_Alt_R,
XK_Meta_L, XK_Meta_R,
XK_Super_L, XK_Super_R,
XK_ISO_Level3_Shift };
static void
xev_handle_maprequest(XEvent *ee)
@@ -219,6 +223,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
xev_handle_enternotify(XEvent *ee)
{
@@ -231,6 +260,15 @@ xev_handle_enternotify(XEvent *ee)
if ((cc = client_find(e->window)) != NULL)
client_set_active(cc);
if (Conf.raiseonhover) {
Window *w;
w = (Window*)malloc(sizeof(Window));
memcpy(w, &e->window, sizeof(Window));
pthread_t thread_id;
pthread_create(&thread_id, NULL, delay_raise, w);
}
}
static void