mirror of
https://github.com/amiwm/amiwm.git
synced 2026-04-14 11:04:18 +00:00
localize menu routines
Keep state loal into drag_menu() in menu.c, rather than in global variables around menu.c and main.c
This commit is contained in:
35
main.c
35
main.c
@@ -73,7 +73,6 @@ typedef struct _DragIcon {
|
||||
|
||||
Display *dpy = NULL;
|
||||
Client *activeclient=NULL;
|
||||
Scrn *menuactive=NULL;
|
||||
Bool shape_extn=False;
|
||||
char *x_server=NULL;
|
||||
char *free_screentitle=NULL;
|
||||
@@ -105,12 +104,10 @@ extern void click_close(Client *c, Time time);
|
||||
extern void click_iconify(Client *c, Time time);
|
||||
extern void click_zoom(Client *c, Time time);
|
||||
extern void click_depth(Client *c, Time time);
|
||||
extern void menu_on(void);
|
||||
extern void menu_off(void);
|
||||
extern void drag_menu(Scrn *s);
|
||||
extern void menubar_enter(Window);
|
||||
extern void menubar_leave(Window);
|
||||
extern void *getitembyhotkey(KeySym);
|
||||
extern void menuaction(void *);
|
||||
extern Scrn *getscreenbyroot(Window);
|
||||
extern void assimilate(Window, int, int);
|
||||
extern void deselect_all_icons(Scrn *);
|
||||
@@ -379,7 +376,8 @@ static Bool grab_for_motion(Window w, Window confine, Cursor curs, Time time, in
|
||||
|
||||
void get_drag_event(XEvent *event)
|
||||
{
|
||||
static const unsigned int DRAG_MASK = ButtonPressMask|ButtonReleaseMask|Button1MotionMask;
|
||||
static const unsigned int DRAG_MASK =
|
||||
ButtonPressMask|ButtonReleaseMask|PointerMotionMask|EnterWindowMask|LeaveWindowMask;
|
||||
|
||||
for (;;) {
|
||||
fd_set rfds = master_fd_set;
|
||||
@@ -1184,8 +1182,6 @@ int main(int argc, char *argv[])
|
||||
XGrabButton(dpy, Button1, AnyModifier, c->parent, True,
|
||||
ButtonPressMask, GrabModeSync, GrabModeAsync,
|
||||
None, wm_curs);
|
||||
if(!menuactive)
|
||||
setfocus(None);
|
||||
}
|
||||
if(c && (event.xunmap.window==c->window)) {
|
||||
if((!c->reparenting) && c->parent != c->scr->root) {
|
||||
@@ -1361,10 +1357,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
break;
|
||||
case EnterNotify:
|
||||
if(menuactive) {
|
||||
scr=menuactive;
|
||||
menubar_enter(event.xcrossing.window);
|
||||
} else if(c) {
|
||||
if(c) {
|
||||
if((!c->active) && (c->state==NormalState) &&
|
||||
prefs.focus!=FOC_CLICKTOTYPE) {
|
||||
if(activeclient) {
|
||||
@@ -1383,15 +1376,10 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
break;
|
||||
case LeaveNotify:
|
||||
if(menuactive) {
|
||||
scr=menuactive;
|
||||
menubar_leave(event.xcrossing.window);
|
||||
} else if(c) {
|
||||
if(c) {
|
||||
if(c->active && event.xcrossing.window==c->parent &&
|
||||
event.xcrossing.detail!=NotifyInferior &&
|
||||
prefs.focus == FOC_FOLLOWMOUSE) {
|
||||
if(!menuactive)
|
||||
setfocus(None);
|
||||
c->active=False;
|
||||
activeclient = NULL;
|
||||
instcmap(None);
|
||||
@@ -1403,7 +1391,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
break;
|
||||
case ButtonPress:
|
||||
if(event.xbutton.button==Button1 && !menuactive) {
|
||||
if(event.xbutton.button==Button1) {
|
||||
if(c) {
|
||||
if((!c->active) && prefs.focus==FOC_CLICKTOTYPE &&
|
||||
(c->state==NormalState)) {
|
||||
@@ -1473,22 +1461,17 @@ int main(int argc, char *argv[])
|
||||
event.xbutton.x, event.xbutton.y);
|
||||
} else ;
|
||||
} else if(event.xbutton.button==3) {
|
||||
if(scr&&!menuactive) {
|
||||
menu_on();
|
||||
menuactive=scr;
|
||||
if(c == NULL && scr != NULL) {
|
||||
drag_menu(scr);
|
||||
}
|
||||
}
|
||||
if(prefs.focus == FOC_CLICKTOTYPE && !menuactive) {
|
||||
if(prefs.focus == FOC_CLICKTOTYPE) {
|
||||
XSync(dpy,0);
|
||||
XAllowEvents(dpy,ReplayPointer,CurrentTime);
|
||||
XSync(dpy,0);
|
||||
}
|
||||
break;
|
||||
case ButtonRelease:
|
||||
if(event.xbutton.button==Button3 && (scr=menuactive)) {
|
||||
menu_off();
|
||||
menuactive=NULL;
|
||||
}
|
||||
break;
|
||||
case MotionNotify:
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user