add raise on hover

This commit is contained in:
2024-12-22 17:28:57 -05:00
parent ca083f97bd
commit 22cd0f5f43
4 changed files with 52 additions and 1 deletions

View File

@@ -314,6 +314,8 @@ struct conf {
int bwidth;
int mamount;
int scalefactor;
int raiseonhover;
int raisedelay;
int snapdist;
int htile;
int vtile;

2
conf.c
View File

@@ -289,6 +289,8 @@ conf_init(struct conf *c)
c->bwidth = 1;
c->mamount = 1;
c->scalefactor = 10;
c->raiseonhover = 1;
c->raisedelay = 250;
c->htile = 50;
c->vtile = 50;
c->snapdist = 0;

14
parse.y
View File

@@ -71,7 +71,7 @@ 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 SCALEFACTOR HTILE VTILE
%token COLOR SNAPDIST
@@ -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");
@@ -357,6 +367,8 @@ lookup(char *s)
{ "menufg", MENUFG},
{ "moveamount", MOVEAMOUNT},
{ "no", NO},
{ "raise-delay", RAISEONHOVERDELAY},
{ "raise-on-hover", RAISEONHOVER},
{ "scalefactor", SCALEFACTOR},
{ "selfont", FONTSELCOLOR},
{ "snapdist", SNAPDIST},

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