localize button click routines

Keep state local into click_*() for routines relating to button clicks
than in global variables around frame.c and main.c
This commit is contained in:
Lucas de Sena
2026-02-21 03:27:29 +00:00
parent 0c75c83e3b
commit 9354a98208
5 changed files with 147 additions and 120 deletions

View File

@@ -418,3 +418,38 @@ Scrn *getscreenbyroot(Window w)
{
return getscreenbyrootext(w, 0);
}
void click_screendepth(Scrn *s, Time time)
{
extern void redrawmenubar(Scrn *, Window);
extern void get_drag_event(XEvent *event);
extern Scrn *mbdclick;
int status;
XSync(dpy, False);
status = XGrabPointer(dpy, s->menubardepth, True, ButtonPressMask|ButtonReleaseMask,
GrabModeAsync, GrabModeAsync, False, None, time);
if (status != AlreadyGrabbed && status != GrabSuccess)
return;
mbdclick = s;
redrawmenubar(s, s->menubardepth);
for (;;) {
XEvent event;
get_drag_event(&event);
if (event.type == ButtonRelease || event.type == ButtonPress) {
mbdclick = NULL;
redrawmenubar(s, s->menubardepth);
XUngrabPointer(dpy, event.xbutton.time);
if (event.type == ButtonPress)
return;
if (event.xbutton.x < 0 || event.xbutton.y < 0)
return; /* pointer to left/top of button */
if (event.xbutton.x >= 23 || event.xbutton.y >= s->bh)
return; /* pointer to right/bottom of button */
if(event.xbutton.window == s->menubardepth)
screentoback();
return;
}
}
}