| @@ -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); |
| @@ -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); |