Compare commits

..

2 Commits

Author SHA1 Message Date
22cd0f5f43 add raise on hover 2024-12-22 17:29:48 -05:00
ca083f97bd add scalefactor to cwmrc 2024-12-22 17:02:42 -05:00
5 changed files with 64 additions and 3 deletions

View File

@@ -313,6 +313,9 @@ struct conf {
int nameqlen;
int bwidth;
int mamount;
int scalefactor;
int raiseonhover;
int raisedelay;
int snapdist;
int htile;
int vtile;

3
conf.c
View File

@@ -288,6 +288,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

@@ -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;

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>
@@ -219,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
xev_handle_enternotify(XEvent *ee)
{
@@ -231,6 +257,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