dwm-defaulttransparency-r1521.diff - sites - public wiki contents of suckless.org
 (HTM) git clone git://git.suckless.org/sites
 (DIR) Log
 (DIR) Files
 (DIR) Refs
       ---
       dwm-defaulttransparency-r1521.diff (3238B)
       ---
            1 diff -r 53d98940cb04 config.def.h
            2 --- a/config.def.h        Fri Jun 04 11:41:16 2010 +0100
            3 +++ b/config.def.h        Sun Jun 06 22:48:32 2010 +0200
            4 @@ -12,14 +12,16 @@
            5  static const unsigned int snap      = 32;       /* snap pixel */
            6  static const Bool showbar           = True;     /* False means no bar */
            7  static const Bool topbar            = True;     /* False means bottom bar */
            8 +static const double defaultopacity  = 0.75;
            9 @@ -52,6 +54,9 @@
           10          /* modifier                     key        function        argument */
           11          { MODKEY,                       XK_p,      spawn,          {.v = dmenucmd } },
           12          { MODKEY|ShiftMask,             XK_Return, spawn,          {.v = termcmd } },
           13 +        { MODKEY|ShiftMask,                XK_s,           spawn,           SHCMD("transset-df -a --dec .1") },
           14 +        { MODKEY|ShiftMask,                XK_d,           spawn,           SHCMD("transset-df -a --inc .1") },
           15 +        { MODKEY|ShiftMask,                XK_f,           spawn,           SHCMD("transset-df -a .75") },
           16          { MODKEY,                       XK_b,      togglebar,      {0} },
           17          { MODKEY,                       XK_j,      focusstack,     {.i = +1 } },
           18          { MODKEY,                       XK_k,      focusstack,     {.i = -1 } },
           19 diff -r 53d98940cb04 dwm.c
           20 --- a/dwm.c        Fri Jun 04 11:41:16 2010 +0100
           21 +++ b/dwm.c        Sun Jun 06 22:48:32 2010 +0200
           22 @@ -58,7 +58,7 @@
           23  enum { CurNormal, CurResize, CurMove, CurLast };        /* cursor */
           24  enum { ColBorder, ColFG, ColBG, ColLast };              /* color */
           25  enum { NetSupported, NetWMName, NetWMState,
           26 -       NetWMFullscreen, NetLast };                      /* EWMH atoms */
           27 +       NetWMFullscreen, NetLast, NetWMWindowsOpacity }; /* EWMH atoms */
           28  enum { WMProtocols, WMDelete, WMState, WMLast };        /* default atoms */
           29  enum { ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle,
           30         ClkClientWin, ClkRootWin, ClkLast };             /* clicks */
           31 @@ -179,6 +179,7 @@
           32  static void drawtext(const char *text, unsigned long col[ColLast], Bool invert);
           33  static void enternotify(XEvent *e);
           34  static void expose(XEvent *e);
           35 +static void opacity(Client *c, double opacity);
           36  static void focus(Client *c);
           37  static void focusin(XEvent *e);
           38  static void focusmon(const Arg *arg);
           39 @@ -816,6 +817,18 @@
           40  }
           41  
           42  void
           43 +opacity(Client *c, double opacity)
           44 +{
           45 +        if(opacity >= 0 && opacity <= 1) {
           46 +                unsigned long real_opacity[] = { opacity * 0xffffffff };
           47 +                XChangeProperty(dpy, c->win, netatom[NetWMWindowsOpacity], XA_CARDINAL,
           48 +                                32, PropModeReplace, (unsigned char *)real_opacity,
           49 +                                1);
           50 +        } else
           51 +                XDeleteProperty(dpy, c->win, netatom[NetWMWindowsOpacity]);
           52 +}
           53 +
           54 +void
           55  focus(Client *c) {
           56          if(!c || !ISVISIBLE(c))
           57                  for(c = selmon->stack; c && !ISVISIBLE(c); c = c->snext);
           58 @@ -1104,6 +1117,7 @@
           59          *c = cz;
           60          c->win = w;
           61          updatetitle(c);
           62 +        opacity(c, defaultopacity);
           63          if(XGetTransientForHint(dpy, w, &trans))
           64                  t = wintoclient(trans);
           65          if(t) {
           66 @@ -1539,6 +1553,7 @@
           67          netatom[NetWMName] = XInternAtom(dpy, "_NET_WM_NAME", False);
           68          netatom[NetWMState] = XInternAtom(dpy, "_NET_WM_STATE", False);
           69          netatom[NetWMFullscreen] = XInternAtom(dpy, "_NET_WM_STATE_FULLSCREEN", False);
           70 +        netatom[NetWMWindowsOpacity] = XInternAtom(dpy, "_NET_WM_WINDOW_OPACITY", False);
           71          /* init cursors */
           72          cursor[CurNormal] = XCreateFontCursor(dpy, XC_left_ptr);
           73          cursor[CurResize] = XCreateFontCursor(dpy, XC_sizing);