From 742106511fbaca5ebef385a9c60c427e8dd7a6dd Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Mon, 28 Jul 2003 19:21:45 +0000 Subject: [PATCH] hover theme elements for window titlebar buttons --- openbox/event.c | 73 +++++++++++++++++++++++++++++++++---------- openbox/frame.c | 5 ++- openbox/frame.h | 5 +++ openbox/framerender.c | 40 ++++++++++++++++++------ 4 files changed, 96 insertions(+), 27 deletions(-) diff --git a/openbox/event.c b/openbox/event.c index a35c5258..e1ab8fef 100644 --- a/openbox/event.c +++ b/openbox/event.c @@ -658,36 +658,77 @@ static void event_handle_client(ObClient *client, XEvent *e) client_iconify(client, TRUE, TRUE); frame_adjust_focus(client->frame, FALSE); break; - case EnterNotify: + case LeaveNotify: + con = frame_context(client, e->xcrossing.window); switch (con) { case OB_FRAME_CONTEXT_MAXIMIZE: + client->frame->max_hover = FALSE; + frame_adjust_state(client->frame); + break; case OB_FRAME_CONTEXT_ALLDESKTOPS: + client->frame->desk_hover = FALSE; + frame_adjust_state(client->frame); + break; case OB_FRAME_CONTEXT_SHADE: + client->frame->shade_hover = FALSE; + frame_adjust_state(client->frame); + break; case OB_FRAME_CONTEXT_ICONIFY: + client->frame->iconify_hover = FALSE; + frame_adjust_state(client->frame); + break; case OB_FRAME_CONTEXT_CLOSE: - g_message("hi"); + client->frame->close_hover = FALSE; frame_adjust_state(client->frame); break; default: break; } - con = frame_context(client, e->xcrossing.subwindow); - if (client_normal(client)) { - if (ob_state() == OB_STATE_STARTING) { - /* move it to the top of the focus order */ - guint desktop = client->desktop; - if (desktop == DESKTOP_ALL) desktop = screen_desktop; - focus_order[desktop] = g_list_remove(focus_order[desktop], - client); - focus_order[desktop] = g_list_prepend(focus_order[desktop], - client); - } else if (config_focus_follow) { + break; + case EnterNotify: + con = frame_context(client, e->xcrossing.window); + switch (con) { + case OB_FRAME_CONTEXT_MAXIMIZE: + client->frame->max_hover = TRUE; + frame_adjust_state(client->frame); + break; + case OB_FRAME_CONTEXT_ALLDESKTOPS: + client->frame->desk_hover = TRUE; + frame_adjust_state(client->frame); + break; + case OB_FRAME_CONTEXT_SHADE: + client->frame->shade_hover = TRUE; + frame_adjust_state(client->frame); + break; + case OB_FRAME_CONTEXT_ICONIFY: + client->frame->iconify_hover = TRUE; + frame_adjust_state(client->frame); + break; + case OB_FRAME_CONTEXT_CLOSE: + client->frame->close_hover = TRUE; + frame_adjust_state(client->frame); + break; + case OB_FRAME_CONTEXT_FRAME: + if (client_normal(client)) { + if (ob_state() == OB_STATE_STARTING) { + /* move it to the top of the focus order */ + guint desktop = client->desktop; + if (desktop == DESKTOP_ALL) desktop = screen_desktop; + focus_order[desktop] = g_list_remove(focus_order[desktop], + client); + focus_order[desktop] = g_list_prepend(focus_order[desktop], + client); + } else if (config_focus_follow) { #ifdef DEBUG_FOCUS - ob_debug("EnterNotify on %lx, focusing window\n", - client->window); + ob_debug("EnterNotify on %lx, focusing window\n", + client->window); #endif - client_focus(client); + client_focus(client); + } } + break; + default: + break; } break; case ConfigureRequest: diff --git a/openbox/frame.c b/openbox/frame.c index 3e90c3e2..1c9913a1 100644 --- a/openbox/frame.c +++ b/openbox/frame.c @@ -9,7 +9,8 @@ #define FRAME_EVENTMASK (EnterWindowMask | LeaveWindowMask | \ ButtonPressMask | ButtonReleaseMask) #define ELEMENT_EVENTMASK (ButtonPressMask | ButtonReleaseMask | \ - ButtonMotionMask | ExposureMask) + ButtonMotionMask | ExposureMask | \ + EnterWindowMask | LeaveWindowMask) #define FRAME_HANDLE_Y(f) (f->innersize.top + f->client->area.height + \ f->cbwidth) @@ -106,6 +107,8 @@ ObFrame *frame_new() self->max_press = self->close_press = self->desk_press = self->iconify_press = self->shade_press = FALSE; + self->max_hover = self->close_hover = self->desk_hover = + self->iconify_hover = self->shade_hover = FALSE; return (ObFrame*)self; } diff --git a/openbox/frame.h b/openbox/frame.h index 0295a6be..0fd7aba3 100644 --- a/openbox/frame.h +++ b/openbox/frame.h @@ -95,6 +95,11 @@ struct _ObFrame gboolean desk_press; gboolean shade_press; gboolean iconify_press; + gboolean max_hover; + gboolean close_hover; + gboolean desk_hover; + gboolean shade_hover; + gboolean iconify_hover; gboolean focused; }; diff --git a/openbox/framerender.c b/openbox/framerender.c index 5f2f2594..d5269c00 100644 --- a/openbox/framerender.c +++ b/openbox/framerender.c @@ -38,12 +38,16 @@ void framerender_frame(ObFrame *self) ob_rr_theme->a_focused_pressed_set_max : (self->max_press ? ob_rr_theme->a_focused_pressed_max : - ob_rr_theme->a_focused_unpressed_max)) : + (self->max_hover ? + ob_rr_theme->a_hover_focused_max : + ob_rr_theme->a_focused_unpressed_max))) : (self->client->max_vert || self->client->max_horz ? ob_rr_theme->a_unfocused_pressed_set_max : (self->max_press ? ob_rr_theme->a_unfocused_pressed_max : - ob_rr_theme->a_unfocused_unpressed_max)))); + (self->max_hover ? + ob_rr_theme->a_hover_unfocused_max : + ob_rr_theme->a_unfocused_unpressed_max))))); n = self->a_icon; i = (!(self->decorations & OB_FRAME_DECOR_ICONIFY) ? (self->focused ? @@ -52,10 +56,14 @@ void framerender_frame(ObFrame *self) (self->focused ? (self->iconify_press ? ob_rr_theme->a_focused_pressed_iconify : - ob_rr_theme->a_focused_unpressed_iconify) : + (self->iconify_hover ? + ob_rr_theme->a_hover_focused_iconify : + ob_rr_theme->a_focused_unpressed_iconify)) : (self->iconify_press ? ob_rr_theme->a_unfocused_pressed_iconify : - ob_rr_theme->a_unfocused_unpressed_iconify))); + (self->iconify_hover ? + ob_rr_theme->a_hover_unfocused_iconify : + ob_rr_theme->a_unfocused_unpressed_iconify)))); d = (!(self->decorations & OB_FRAME_DECOR_ALLDESKTOPS) ? (self->focused ? ob_rr_theme->a_disabled_focused_desk : @@ -65,12 +73,16 @@ void framerender_frame(ObFrame *self) ob_rr_theme->a_focused_pressed_set_desk : (self->desk_press ? ob_rr_theme->a_focused_pressed_desk : - ob_rr_theme->a_focused_unpressed_desk)) : + (self->desk_hover ? + ob_rr_theme->a_hover_focused_desk : + ob_rr_theme->a_focused_unpressed_desk))) : (self->client->desktop == DESKTOP_ALL ? ob_rr_theme->a_unfocused_pressed_set_desk : (self->desk_press ? ob_rr_theme->a_unfocused_pressed_desk : - ob_rr_theme->a_unfocused_unpressed_desk)))); + (self->desk_hover ? + ob_rr_theme->a_hover_unfocused_desk : + ob_rr_theme->a_unfocused_unpressed_desk))))); s = (!(self->decorations & OB_FRAME_DECOR_SHADE) ? (self->focused ? ob_rr_theme->a_disabled_focused_shade : @@ -80,12 +92,16 @@ void framerender_frame(ObFrame *self) ob_rr_theme->a_focused_pressed_set_shade : (self->shade_press ? ob_rr_theme->a_focused_pressed_shade : - ob_rr_theme->a_focused_unpressed_shade)) : + (self->shade_hover ? + ob_rr_theme->a_hover_focused_shade : + ob_rr_theme->a_focused_unpressed_shade))) : (self->client->shaded ? ob_rr_theme->a_unfocused_pressed_set_shade : (self->shade_press ? ob_rr_theme->a_unfocused_pressed_shade : - ob_rr_theme->a_unfocused_unpressed_shade)))); + (self->shade_hover ? + ob_rr_theme->a_hover_unfocused_shade : + ob_rr_theme->a_unfocused_unpressed_shade))))); c = (!(self->decorations & OB_FRAME_DECOR_CLOSE) ? (self->focused ? ob_rr_theme->a_disabled_focused_close : @@ -93,10 +109,14 @@ void framerender_frame(ObFrame *self) (self->focused ? (self->close_press ? ob_rr_theme->a_focused_pressed_close : - ob_rr_theme->a_focused_unpressed_close) : + (self->close_hover ? + ob_rr_theme->a_hover_focused_close : + ob_rr_theme->a_focused_unpressed_close)) : (self->close_press ? ob_rr_theme->a_unfocused_pressed_close : - ob_rr_theme->a_unfocused_unpressed_close))); + (self->close_hover ? + ob_rr_theme->a_hover_unfocused_close : + ob_rr_theme->a_unfocused_unpressed_close)))); RrPaint(t, self->title, self->width, ob_rr_theme->title_height); -- 2.45.2