Re: [dev] dwm-5.8.1 / dmenu-4.1.1

From: Kris Maglione <maglione.k_AT_gmail.com>
Date: Sat, 29 May 2010 13:18:24 -0400

On Sat, May 29, 2010 at 01:12:15PM +0100, Anselm R Garbe wrote:
>Hi there,
>
>I created two bugfix releases:
>
> http://dl.suckless.org/dwm/dwm-5.8.1.tar.gz
> http://dl.suckless.org/tools/dmenu-4.1.1.tar.gz
>
>The dwm release reverts the EWMH fullscreen support. Apparently it
>only made chromium to accept F11 requests, but broke mplayer and
>didn't really fix the flash fullscreen issue, which is still
>unresolved. I don't really mind to live with the flash breakage for
>this bugfix release since I recommend to drop flash anyways in favor
>for HTML5 video.

The problem is that once you set the _NET_WM_FULLSCREEN atom in
_NET_SUPPORTS, apps expect you to set their size to fullscreen
when they ask for it. As for the flash bug, well, that's an easy
fix. See patch below.

The getfullscreen bit is probably not necessary in most cases.
The rest of the clientmessage function is a hack, because I
don't know the dwm sourcecode well enough to do it properly.
It's just to show what's required.

# HG changeset patch
# User Kris Maglione <maglione.k_AT_gmail.com>
# Date 1275153171 14400
# Node ID 15b1bd9e262c5f90b35eef1fdccc88917c6b3aa9
# Parent 2a8d8d41e50b852764464ff818b8d37a67e7109f
Proper EWMH fullscreen support. Fix flash fullscreen.

diff --git a/dwm.c b/dwm.c
--- a/dwm.c
+++ b/dwm.c
@@ -183,8 +183,10 @@ static void focusin(XEvent *e);
  static void focusmon(const Arg *arg);
  static void focusstack(const Arg *arg);
  static unsigned long getcolor(const char *colstr);
+static Bool getfullscreen(Window w);
  static Bool getrootptr(int *x, int *y);
  static long getstate(Window w);
+static long getstateproperty(Atom prop, long len, char **p);
  static Bool gettextprop(Window w, Atom atom, char *text, unsigned int size);
  static void grabbuttons(Client *c, Bool focused);
  static void grabkeys(void);
@@ -222,7 +224,7 @@ static void togglebar(const Arg *arg);
  static void togglefloating(const Arg *arg);
  static void toggletag(const Arg *arg);
  static void toggleview(const Arg *arg);
-static void unfocus(Client *c);
+static void unfocus(Client *c, Bool setfocus);
  static void unmanage(Client *c, Bool destroyed);
  static void unmapnotify(XEvent *e);
  static Bool updategeom(void);
@@ -426,7 +428,7 @@ buttonpress(XEvent *e) {
          click = ClkRootWin;
          /* focus monitor if necessary */
          if((m = wintomon(ev->window)) && m != selmon) {
- unfocus(selmon->sel);
+ unfocus(selmon->sel, True);
                  selmon = m;
                  focus(NULL);
          }
@@ -795,7 +797,7 @@ enternotify(XEvent *e) {
          if((ev->mode != NotifyNormal || ev->detail == NotifyInferior) && ev->window != root)
                  return;
          if((m = wintomon(ev->window)) && m != selmon) {
- unfocus(selmon->sel);
+ unfocus(selmon->sel, True);
                  selmon = m;
          }
          if((c = wintoclient(ev->window)))
@@ -817,8 +819,8 @@ void
  focus(Client *c) {
          if(!c || !ISVISIBLE(c))
                  for(c = selmon->stack; c && !ISVISIBLE(c); c = c->snext);
- if(selmon->sel)
- unfocus(selmon->sel);
+ if(selmon->sel && selmon->sel != c)
+ unfocus(selmon->sel, False);
          if(c) {
                  if(c->mon != selmon)
                          selmon = c->mon;
@@ -852,7 +854,7 @@ focusmon(const Arg *arg) {
                  return;
          if((m = dirtomon(arg->i)) == selmon)
                  return;
- unfocus(selmon->sel);
+ unfocus(selmon->sel, True);
          selmon = m;
          focus(NULL);
  }
@@ -894,6 +896,20 @@ getcolor(const char *colstr) {
  }
  
  Bool
+getfullscreen(Window w) {
+ char *p;
+ long i, n;
+ Bool result;
+
+ n = getstateproperty(netatom[NetWMFullscreen], 16, &p);
+ for(i = 0; i < n; i++)
+ if(p[i] == netatom[NetWMFullscreen])
+ result = True;
+ XFree(p);
+ return result;
+}
+
+Bool
  getrootptr(int *x, int *y) {
          int di;
          unsigned int dui;
@@ -904,22 +920,27 @@ getrootptr(int *x, int *y) {
  
  long
  getstate(Window w) {
- int format, status;
- long result = -1;
- unsigned char *p = NULL;
- unsigned long n, extra;
- Atom real;
+ char *p;
+ long n, result = -1;
  
- status = XGetWindowProperty(dpy, w, wmatom[WMState], 0L, 2L, False, wmatom[WMState],
- &real, &format, &n, &extra, (unsigned char **)&p);
- if(status != Success)
- return -1;
+ n = getstateproperty(wmatom[WMState], 2, &p);
          if(n != 0)
                  result = *p;
          XFree(p);
          return result;
  }
  
+long
+getstateproperty(Window w, Atom prop, long len, char **p) {
+ int format, status;
+ unsigned long n, extra;
+ Atom real;
+
+ status = XGetWindowProperty(dpy, w, prop, 0L, 2L, False, prop,
+ &real, &format, &n, &extra, (unsigned char **)p);
+ return status == Success ? n : 0;
+}
+
  Bool
  gettextprop(Window w, Atom atom, char *text, unsigned int size) {
          char **list = NULL;
@@ -1118,9 +1139,12 @@ manage(Window w, XWindowAttributes *wa)
          c->w = wa->width;
          c->h = wa->height;
          c->oldbw = wa->border_width;
- if(c->w == c->mon->mw && c->h == c->mon->mh) {
+ if((c->w == c->mon->mw && c->h == c->mon->mh) || getfullscreen(w)) {
+ c->isfloating = 1;
                  c->x = c->mon->mx;
                  c->y = c->mon->my;
+ c->w = c->mon->mw;
+ c->h = c->mon->mh;
                  c->bw = 0;
          }
          else {
@@ -1297,14 +1321,21 @@ propertynotify(XEvent *e) {
  void
  clientmessage(XEvent *e) {
          XClientMessageEvent *cme = &e->xclient;
+ Client *c;
  
- if(cme->message_type == netatom[NetWMState] && cme->data.l[1] == netatom[NetWMFullscreen]) {
- if(cme->data.l[0])
- XChangeProperty(dpy, cme->window, netatom[NetWMState], XA_ATOM, 32,
- PropModeReplace, (unsigned char*)&netatom[NetWMFullscreen], 1);
- else
- XChangeProperty(dpy, cme->window, netatom[NetWMState], XA_ATOM, 32,
- PropModeReplace, (unsigned char*)0, 0);
+ if((c = wintoclient(cme->window))) {
+ if(cme->message_type == netatom[NetWMState] && cme->data.l[1] == netatom[NetWMFullscreen]) {
+ if(cme->data.l[0]) {
+ XChangeProperty(dpy, cme->window, netatom[NetWMState], XA_ATOM, 32,
+ PropModeReplace, (unsigned char*)&netatom[NetWMFullscreen], 1);
+ resize(c, c->mon->mx, c->mon->my, c->mon->mw, c->mon->mh, False);
+ XMoveResizeWindow(dpy, c->win, c->mon->mx, c->mon->my, c->mon->mw, c->mon->mh);
+ XRaiseWindow(dpy, c->win);
+ }
+ else
+ XChangeProperty(dpy, cme->window, netatom[NetWMState], XA_ATOM, 32,
+ PropModeReplace, (unsigned char*)0, 0);
+ }
          }
  }
  
@@ -1406,7 +1437,7 @@ restack(Monitor *m) {
  void
  run(void) {
          XEvent ev;
- static const char *evname[LASTEvent] = {
+ static const char *evname[LASTEvent] __attribute_used__ = {
                  [ButtonPress] = "buttonpress",
                  [ClientMessage] = "clientmessage",
                  [ConfigureRequest] = "configurerequest",
@@ -1459,7 +1490,7 @@ void
  sendmon(Client *c, Monitor *m) {
          if(c->mon == m)
                  return;
- unfocus(c);
+ unfocus(c, True);
          detach(c);
          detachstack(c);
          c->mon = m;
@@ -1696,12 +1727,13 @@ toggleview(const Arg *arg) {
  }
  
  void
-unfocus(Client *c) {
+unfocus(Client *c, Bool setfocus) {
          if(!c)
                  return;
          grabbuttons(c, False);
          XSetWindowBorder(dpy, c->win, dc.norm[ColBorder]);
- XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
+ if(setfocus)
+ XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
  }
  
  void

-- 
Kris Maglione
Beware of "the real world".  A speaker's appeal to it is always an
invitation not to challenge his tacit assumptions.
	--Edsger W. Dijkstra
Received on Sat May 29 2010 - 17:18:24 UTC

This archive was generated by hypermail 2.2.0 : Sat May 29 2010 - 17:24:02 UTC