From 993b40826214fd0d92cab28a71cce88945e4b221 Mon Sep 17 00:00:00 2001 From: Martin Duquesnoy Date: Sat, 15 Jan 2011 20:55:13 +0100 Subject: [PATCH] Apply Almito's patchs for xcompmgr opacity support (#70), skype focus bug (#66) and fix for #68 & #69 --- src/client.c | 43 +++++++++++++++++++++++++++++++++---------- src/config.c | 7 +++++++ src/event.c | 6 +----- src/ewmh.c | 3 ++- src/layout.c | 1 - src/structs.h | 2 ++ src/wmfs.h | 1 + wmfsrc | 1 + 8 files changed, 47 insertions(+), 17 deletions(-) diff --git a/src/client.c b/src/client.c index 2a75679..e05ecc0 100644 --- a/src/client.c +++ b/src/client.c @@ -370,6 +370,9 @@ client_focus(Client *c) if(sel->flags & AboveFlag) sel->flags &= ~AboveFlag; + XChangeProperty(dpy,sel->frame,net_atom[net_wm_window_opacity],XA_CARDINAL, + 32,PropModeReplace,(uchar *)&conf.opacity,1); + frame_update(sel); mouse_grabbuttons(sel, !conf.focus_pclick); @@ -390,6 +393,9 @@ client_focus(Client *c) if(TBARH - BORDH && c->titlebar->stipple) c->titlebar->stipple_color = conf.titlebar.stipple.colors.focus; + + XDeleteProperty(dpy,c->frame,net_atom[net_wm_window_opacity]); + frame_update(c); mouse_grabbuttons(c, True); @@ -407,11 +413,7 @@ client_focus(Client *c) client_above(sel); if(c->flags & UrgentFlag) - { - c->flags &= ~UrgentFlag; - tags[c->screen][c->tag].urgent = False; - infobar_draw_taglist(c->screen); - } + client_urgent(c, False); XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime); @@ -428,6 +430,22 @@ client_focus(Client *c) return; } +/** Set urgency flag of the client + * \param c Client pointer + * \param u Bool +*/ +void +client_urgent(Client *c, Bool u) +{ + if(u) + c->flags |= UrgentFlag; + else + c->flags &= ~UrgentFlag; + + tags[c->screen][c->tag].urgent = u; + infobar_draw_taglist(c->screen); +} + /* The following functions have the same point : * find a client member with a Window {{{ */ @@ -761,7 +779,6 @@ client_manage(Window w, XWindowAttributes *wa, Bool ar) client_update_attributes(c); client_map(c); ewmh_manage_window_type(c); - client_focus(c); if(ar) arrange(c->screen, True); @@ -769,6 +786,11 @@ client_manage(Window w, XWindowAttributes *wa, Bool ar) if(!conf.client.set_new_win_master) layout_set_client_master(c); + if(c->tag == (uint)seltag[selscreen]) + { + client_focus(c); + } + return c; } @@ -1067,10 +1089,11 @@ client_set_rules(Client *c) if(c->tag != (uint)seltag[selscreen]) { tags[c->screen][c->tag].request_update = True; - client_focus(NULL); } - - tags[c->screen][c->tag].layout.func(c->screen); + else + { + tags[c->screen][c->tag].layout.func(c->screen); + } /* Deprecated but still in use */ applied_tag_rule = True; @@ -1246,7 +1269,7 @@ client_unmanage(Client *c) client_focus(NULL); if(c->flags & UrgentFlag) - tags[c->screen][c->tag].urgent = False; + client_urgent(c, False); client_detach(c); XUngrabButton(dpy, AnyButton, AnyModifier, c->win); diff --git a/src/config.c b/src/config.c index b329346..ce87837 100644 --- a/src/config.c +++ b/src/config.c @@ -148,6 +148,7 @@ static void conf_misc_section(void) { int pad = 12; + uint opacity = 255; struct conf_sec *sec; sec = fetch_section_first(NULL, "misc"); @@ -162,6 +163,12 @@ conf_misc_section(void) conf.autostart_path = fetch_opt_first(sec, "", "autostart_path").str; conf.autostart_command = fetch_opt_first(sec, "", "autostart_command").str; pad = fetch_opt_first(sec, "12", "pad").num; + opacity = fetch_opt_first(sec, "255", "opacity").num; + + if(opacity > 255) + opacity = 255; + + conf.opacity = opacity << 24; if(pad > 24 || pad < 1) { diff --git a/src/event.c b/src/event.c index c391521..29ce6f9 100644 --- a/src/event.c +++ b/src/event.c @@ -577,11 +577,7 @@ propertynotify(XPropertyEvent *ev) case XA_WM_HINTS: if((h = XGetWMHints(dpy, c->win)) && (h->flags & XUrgencyHint) && c != sel) { - c->flags |= UrgentFlag; - - tags[c->screen][c->tag].urgent = True; - infobar_draw_taglist(c->screen); - + client_urgent(c, True); XFree(h); } break; diff --git a/src/ewmh.c b/src/ewmh.c index 7fe04d8..e9f6787 100644 --- a/src/ewmh.c +++ b/src/ewmh.c @@ -69,6 +69,7 @@ ewmh_init_hints(void) net_atom[net_wm_icon_name] = ATOM("_NET_WM_ICON_NAME"); net_atom[net_wm_window_type] = ATOM("_NET_WM_WINDOW_TYPE"); net_atom[net_supporting_wm_check] = ATOM("_NET_SUPPORTING_WM_CHECK"); + net_atom[net_wm_window_opacity] = ATOM("_NET_WM_WINDOW_OPACITY"); net_atom[net_wm_window_type_normal] = ATOM("_NET_WM_WINDOW_TYPE_NORMAL"); net_atom[net_wm_window_type_dock] = ATOM("_NET_WM_WINDOW_TYPE_DOCK"); net_atom[net_wm_window_type_splash] = ATOM("_NET_WM_WINDOW_TYPE_SPLASH"); @@ -370,7 +371,7 @@ ewmh_manage_net_wm_state(long data_l[], Client *c) else if(data_l[1] == (long)net_atom[net_wm_state_demands_attention]) { if(data_l[0] == _NET_WM_STATE_ADD) - client_focus(c); + client_urgent(c, True); if(data_l[0] == _NET_WM_STATE_REMOVE) if(c == sel) client_focus(NULL); diff --git a/src/layout.c b/src/layout.c index f9703b6..debbfc5 100644 --- a/src/layout.c +++ b/src/layout.c @@ -849,7 +849,6 @@ layout_set_client_master(Client *c) client_detach(c); client_attach(c); - client_focus(c); tags[selscreen][seltag[selscreen]].layout.func(selscreen); diff --git a/src/structs.h b/src/structs.h index 004d86d..0cfebc1 100644 --- a/src/structs.h +++ b/src/structs.h @@ -115,6 +115,7 @@ enum net_wm_pid, net_showing_desktop, net_supporting_wm_check, + net_wm_window_opacity, net_wm_window_type_normal, net_wm_window_type_dock, net_wm_window_type_splash, @@ -375,6 +376,7 @@ typedef struct /* Misc option */ char *font; + uint opacity; Bool raisefocus; Bool raiseswitch; Bool focus_fmouse; diff --git a/src/wmfs.h b/src/wmfs.h index 844935a..108eacc 100644 --- a/src/wmfs.h +++ b/src/wmfs.h @@ -190,6 +190,7 @@ void client_unmanage(Client *c); void client_unmap(Client *c); void client_set_rules(Client *c); void client_update_attributes(Client *c); +void client_urgent(Client *c, Bool u); void uicb_client_raise(uicb_t); void uicb_client_next(uicb_t); void uicb_client_prev(uicb_t); diff --git a/wmfsrc b/wmfsrc index cb2cf53..581e494 100644 --- a/wmfsrc +++ b/wmfsrc @@ -10,6 +10,7 @@ font = "dejavu-10" raisefocus = false focus_follow_mouse = true + opacity = 255 # focus_pointer_click: click on unfocused client area: # true -- default, set focus # false -- click go to client; including dockapps