From: Dana Jansens Date: Tue, 26 Feb 2008 08:12:57 +0000 (-0500) Subject: Fixing bug from commit 041d17373e04 X-Git-Url: https://git.brokenzipper.com/gitweb?a=commitdiff_plain;h=1ef0d8eb53fcae52afbae74310fbef0cac729951;p=chaz%2Fopenbox Fixing bug from commit 041d17373e04 Pressing a button and leave/enter would cause the button to show hover mode, not pressed mode. Change the behaviour back to how it used to be for pressing (the button stays pressed when you move outside of its box) and make it work correctly, as commit 041d17373e04 also did for menus. Reverting this behaviour because it seems impossible to do the enter/leave stuff correctly for the close button on maximized windows. Leaving the titlebar contexts doesn't give us an Enter event to go along with it, so even if we check all motion events, the button will flash unpressed when leaving the topright contexts. --- diff --git a/openbox/event.c b/openbox/event.c index 28c13a2a..dca615df 100644 --- a/openbox/event.c +++ b/openbox/event.c @@ -872,7 +872,10 @@ static void event_handle_client(ObClient *client, XEvent *e) con = mouse_button_frame_context(con, e->xbutton.button, e->xbutton.state); - if (e->type == ButtonRelease && e->xbutton.button == pb) + /* button presses on CLIENT_CONTEXTs are not accompanied by a + release because they are Replayed to the client */ + if ((e->type == ButtonRelease || CLIENT_CONTEXT(con, client)) && + e->xbutton.button == pb) pb = 0, px = py = -1, pcon = OB_FRAME_CONTEXT_NONE; switch (con) { @@ -968,41 +971,48 @@ static void event_handle_client(ObClient *client, XEvent *e) case OB_FRAME_CONTEXT_TLCORNER: case OB_FRAME_CONTEXT_TRCORNER: /* we've left the button area inside the titlebar */ - if (client->frame->max_hover || client->frame->desk_hover || - client->frame->shade_hover || client->frame->iconify_hover || - client->frame->close_hover) - { - client->frame->max_hover = FALSE; - client->frame->desk_hover = FALSE; - client->frame->shade_hover = FALSE; - client->frame->iconify_hover = FALSE; - client->frame->close_hover = FALSE; - frame_adjust_state(client->frame); + client->frame->max_hover = FALSE; + client->frame->desk_hover = FALSE; + client->frame->shade_hover = FALSE; + client->frame->iconify_hover = FALSE; + client->frame->close_hover = FALSE; + if (e->xcrossing.mode == NotifyGrab) { + client->frame->max_press = FALSE; + client->frame->desk_press = FALSE; + client->frame->shade_press = FALSE; + client->frame->iconify_press = FALSE; + client->frame->close_press = FALSE; } + frame_adjust_state(client->frame); break; case OB_FRAME_CONTEXT_MAXIMIZE: client->frame->max_hover = FALSE; - client->frame->max_press = FALSE; + if (e->xcrossing.mode == NotifyGrab) + client->frame->max_press = FALSE; frame_adjust_state(client->frame); break; case OB_FRAME_CONTEXT_ALLDESKTOPS: client->frame->desk_hover = FALSE; - client->frame->desk_press = FALSE; + if (e->xcrossing.mode == NotifyGrab) + client->frame->desk_press = FALSE; frame_adjust_state(client->frame); break; case OB_FRAME_CONTEXT_SHADE: client->frame->shade_hover = FALSE; - client->frame->shade_press = FALSE; + if (e->xcrossing.mode == NotifyGrab) + client->frame->shade_press = FALSE; frame_adjust_state(client->frame); break; case OB_FRAME_CONTEXT_ICONIFY: client->frame->iconify_hover = FALSE; - client->frame->iconify_press = FALSE; + if (e->xcrossing.mode == NotifyGrab) + client->frame->iconify_press = FALSE; frame_adjust_state(client->frame); break; case OB_FRAME_CONTEXT_CLOSE: client->frame->close_hover = FALSE; - client->frame->close_press = FALSE; + if (e->xcrossing.mode == NotifyGrab) + client->frame->close_press = FALSE; frame_adjust_state(client->frame); break; case OB_FRAME_CONTEXT_FRAME: @@ -1041,27 +1051,32 @@ static void event_handle_client(ObClient *client, XEvent *e) switch (con) { case OB_FRAME_CONTEXT_MAXIMIZE: client->frame->max_hover = TRUE; - client->frame->max_press = (con == pcon); + if (e->xcrossing.mode == NotifyUngrab) + client->frame->max_press = (con == pcon); frame_adjust_state(client->frame); break; case OB_FRAME_CONTEXT_ALLDESKTOPS: client->frame->desk_hover = TRUE; - client->frame->desk_press = (con == pcon); + if (e->xcrossing.mode == NotifyUngrab) + client->frame->desk_press = (con == pcon); frame_adjust_state(client->frame); break; case OB_FRAME_CONTEXT_SHADE: client->frame->shade_hover = TRUE; - client->frame->shade_press = (con == pcon); + if (e->xcrossing.mode == NotifyUngrab) + client->frame->shade_press = (con == pcon); frame_adjust_state(client->frame); break; case OB_FRAME_CONTEXT_ICONIFY: client->frame->iconify_hover = TRUE; - client->frame->iconify_press = (con == pcon); + if (e->xcrossing.mode == NotifyUngrab) + client->frame->iconify_press = (con == pcon); frame_adjust_state(client->frame); break; case OB_FRAME_CONTEXT_CLOSE: client->frame->close_hover = TRUE; - client->frame->close_press = (con == pcon); + if (e->xcrossing.mode == NotifyUngrab) + client->frame->close_press = (con == pcon); frame_adjust_state(client->frame); break; case OB_FRAME_CONTEXT_FRAME: diff --git a/openbox/frame.h b/openbox/frame.h index 02be17a0..e1b787fe 100644 --- a/openbox/frame.h +++ b/openbox/frame.h @@ -56,6 +56,12 @@ typedef enum { OB_FRAME_NUM_CONTEXTS } ObFrameContext; +#define FRAME_CONTEXT(co, cl) ((cl && cl->type != OB_CLIENT_TYPE_DESKTOP) ? \ + co == OB_FRAME_CONTEXT_FRAME : FALSE) +#define CLIENT_CONTEXT(co, cl) ((cl && cl->type == OB_CLIENT_TYPE_DESKTOP) ? \ + co == OB_FRAME_CONTEXT_DESKTOP : \ + co == OB_FRAME_CONTEXT_CLIENT) + /*! The decorations the client window wants to be displayed on it */ typedef enum { OB_FRAME_DECOR_TITLEBAR = 1 << 0, /*!< Display a titlebar */ diff --git a/openbox/mouse.c b/openbox/mouse.c index 857f6d09..f63d2663 100644 --- a/openbox/mouse.c +++ b/openbox/mouse.c @@ -38,12 +38,6 @@ typedef struct { GSList *actions[OB_NUM_MOUSE_ACTIONS]; /* lists of Action pointers */ } ObMouseBinding; -#define FRAME_CONTEXT(co, cl) ((cl && cl->type != OB_CLIENT_TYPE_DESKTOP) ? \ - co == OB_FRAME_CONTEXT_FRAME : FALSE) -#define CLIENT_CONTEXT(co, cl) ((cl && cl->type == OB_CLIENT_TYPE_DESKTOP) ? \ - co == OB_FRAME_CONTEXT_DESKTOP : \ - co == OB_FRAME_CONTEXT_CLIENT) - /* Array of GSList*s of ObMouseBinding*s. */ static GSList *bound_contexts[OB_FRAME_NUM_CONTEXTS]; /* TRUE when we have a grab on the pointer and need to replay the pointer event