9vx/X11: F11 for fullscreen - vx32 - Local 9vx git repository for patches.
Log
Files
Refs
---
commit 052400b03c4d726a251413634b55fceb0d8b25db
parent bd3ce27341ac2e22020c9ed1620fa02e45b167c4
Author: Russ Cox 
Date:   Mon, 30 Jun 2008 13:31:03 -0400

9vx/X11: F11 for fullscreen

Diffstat:
  src/9vx/x11/x11-inc.h               |       2 ++
  src/9vx/x11/x11-init.c              |      17 ++++++++++++++---
  src/9vx/x11/x11-kernel.c            |      35 ++++++++++++++++++++++++++++++-

3 files changed, 50 insertions(+), 4 deletions(-)
---
diff --git a/src/9vx/x11/x11-inc.h b/src/9vx/x11/x11-inc.h
@@ -95,6 +95,8 @@ struct Xprivate {
         Atom                takefocus;
         Atom                losefocus;
         Atom                wmprotos;
+        Atom                wmstate;
+        Atom                wmfullscreen;
         uint                putsnarf;
         uint                assertsnarf;
         int                destroyed;
diff --git a/src/9vx/x11/x11-init.c b/src/9vx/x11/x11-init.c
@@ -254,7 +254,6 @@ _xattach(char *label, char *winsize)
                 havemin = 0;
         }
         screenrect = Rect(0, 0, WidthOfScreen(xscreen), HeightOfScreen(xscreen));
-        windowrect = r;
         mouserect = Rect(0, 0, Dx(r), Dy(r));
 
         memset(&attr, 0, sizeof attr);
@@ -369,6 +368,8 @@ _xattach(char *label, char *winsize)
         _x.takefocus = XInternAtom(_x.display, "WM_TAKE_FOCUS", False);
         _x.losefocus = XInternAtom(_x.display, "_9WM_LOSE_FOCUS", False);
         _x.wmprotos = XInternAtom(_x.display, "WM_PROTOCOLS", False);
+        _x.wmstate = XInternAtom(_x.display, "_NET_WM_STATE", False);
+        _x.wmfullscreen = XInternAtom(_x.display, "_NET_WM_STATE_FULLSCREEN", False);
 
         atoms[0] = _x.takefocus;
         atoms[1] = _x.losefocus;
@@ -385,8 +386,8 @@ _xattach(char *label, char *winsize)
                 fprint(2, "XGetWindowAttributes failed\n");
         else if(wattr.width && wattr.height){
                 if(wattr.width != Dx(r) || wattr.height != Dy(r)){
-                        r.max.x = wattr.width;
-                        r.max.y = wattr.height;
+                        r.max.x = r.min.x + wattr.width;
+                        r.max.y = r.min.y + wattr.height;
                 }
         }else
                 fprint(2, "XGetWindowAttributes: bad attrs\n");
@@ -400,6 +401,16 @@ _xattach(char *label, char *winsize)
         _x.screenimage = _xallocmemimage(r, _x.chan, _x.screenpm);
 
         /*
+         * Figure out physical window location.
+         */
+        int rx, ry;
+        XWindow w;
+        if(XTranslateCoordinates(_x.display, _x.drawable,
+                        DefaultRootWindow(_x.display), 0, 0, &rx, &ry, &w))
+                r = Rect(rx, ry, Dx(r), Dy(r));
+        windowrect = r;
+
+        /*
          * Allocate some useful graphics contexts for the future.
          */
         _x.gcfill        = xgc(_x.screenpm, FillSolid, -1);
diff --git a/src/9vx/x11/x11-kernel.c b/src/9vx/x11/x11-kernel.c
@@ -86,7 +86,40 @@ runxevent(XEvent *xev)
                 XLookupString((XKeyEvent*)xev, NULL, 0, &k, NULL);
                 if(k == XK_F11){
                         fullscreen = !fullscreen;
-                //TODO        _xmovewindow(fullscreen ? screenrect : windowrect);
+                        if(1){
+                                /* The old way: send a move request */
+                                XWindowChanges e;
+                                int mask;
+                                Rectangle r;
+                                
+                                memset(&e, 0, sizeof e);
+                                mask = CWX|CWY|CWWidth|CWHeight;
+                                if(fullscreen)
+                                        r = screenrect;
+                                else
+                                        r = windowrect;
+                                e.x = r.min.x;
+                                e.y = r.min.y;
+                                e.width = Dx(r);
+                                e.height = Dy(r);
+                                XConfigureWindow(_x.kmcon, _x.drawable, mask, &e);
+                                XFlush(_x.kmcon);
+                        }else{
+                                /* The "right" way, but not supported by rio. */
+                                XClientMessageEvent e;
+
+                                memset(&e, 0, sizeof e);
+                                e.type = ClientMessage;
+                                e.send_event = True;
+                                e.window = _x.drawable;
+                                e.message_type = _x.wmstate;
+                                e.format = 32;
+                                e.data.l[0] = fullscreen;        // 0 off, 1 on, 2 is toggle
+                                e.data.l[1] = _x.wmfullscreen;
+                                e.data.l[2] = 0;
+                                XSendEvent(_x.kmcon, DefaultRootWindow(_x.kmcon), False,
+                                        SubstructureRedirectMask|SubstructureNotifyMask, (XEvent*)&e);
+                        }
                         return;
                 }
                 _xtoplan9kbd(xev);