You are not logged in.
I am trying to get TinyWM (http://incise.org/tinywm.html) to work. I ran
Xephyr -ac -screen 1280x1024 -br -reset -terminate 2> /dev/null :1 &And then
DISPLAY=:1 ./tinywm &,where tinywm is compiled with
gcc tinywm.c -g -o tinywm -lX11From the new xsession, I opened chromium. I can't, however, move/resize the chromium window with Alt+Left/Right mouse button, as stated on its website. Am I doing something wrong?
Last edited by Portal (2020-03-05 06:47:55)
Offline
Alt+Left/Right mouse button is proably grabbed by the WM of your main X11 server, ie. you're moving/resizing the xephyr window instead?
Online
Alt+Left/Right mouse button is proably grabbed by the WM of your main X11 server, ie. you're moving/resizing the xephyr window instead?
I thought about that too. But Xephyr has this “Press Ctrl-Shift to grab the mouse and keys” I am assuming that this means handing control to the Xephyr Window (ie. my main WM no longer exerts an influence).
Offline
Tried. Numlock issue. TinyWM only grabs Mod1Mask, you also want Mod2Mask.
If you chose to disable numlock, you need to toggle it on the hosting X11 server as well as in the Xephyr window (eg. using "numlockx off") - this is a bit weird and confusing, but worked here. (You can use "xev -event mouse" to check the state, you want 0x8, not 0x18 - 0x10 is numlock)
Online
Tried. Numlock issue. TinyWM only grabs Mod1Mask, you also want Mod2Mask.
If you chose to disable numlock, you need to toggle it on the hosting X11 server as well as in the Xephyr window (eg. using "numlockx off") - this is a bit weird and confusing, but worked here. (You can use "xev -event mouse" to check the state, you want 0x8, not 0x18 - 0x10 is numlock)
Sorry for the late reply, but it still does not work.... I tried
DISPLAY=:1 numlockx offI even tried to set the mask to None, and move/resize simply with mouse buttons. When I hover over the window borders, a small X replaces the normal cursor design, I drag this X around to move/resize the window, right?
Offline
If you remove the mask, numlock still has to be effectively disabled (again: in the hosting X server as well, numlockx inside xephyr only won't cut it)
Did you ensure this using xev? In doubt post the output of "xev -event mouse" (and a mouseclick to record an event) inside the xephyr session (maybe there's yet another active modifier like caps or scroll lock)
Instead of removing the mask, try to add the Mod2Mask
XGrabKey(dpy, XKeysymToKeycode(dpy, XStringToKeysym("F1")), Mod1Mask, root,
True, GrabModeAsync, GrabModeAsync);
XGrabButton(dpy, 1, Mod1Mask, root, True, ButtonPressMask, GrabModeAsync,
GrabModeAsync, None, None);
XGrabButton(dpy, 3, Mod1Mask, root, True, ButtonPressMask, GrabModeAsync,
GrabModeAsync, None, None);
XGrabKey(dpy, XKeysymToKeycode(dpy, XStringToKeysym("F1")), Mod1Mask|Mod2Mask, root,
True, GrabModeAsync, GrabModeAsync);
XGrabButton(dpy, 1, Mod1Mask|Mod2Mask, root, True, ButtonPressMask, GrabModeAsync,
GrabModeAsync, None, None);
XGrabButton(dpy, 3, Mod1Mask|Mod2Mask, root, True, ButtonPressMask, GrabModeAsync,
GrabModeAsync, None, None);Online
If you remove the mask, numlock still has to be effectively disabled (again: in the hosting X server as well, numlockx inside xephyr only won't cut it)
Did you ensure this using xev? In doubt post the output of "xev -event mouse" (and a mouseclick to record an event) inside the xephyr session (maybe there's yet another active modifier like caps or scroll lock)Instead of removing the mask, try to add the Mod2Mask
XGrabKey(dpy, XKeysymToKeycode(dpy, XStringToKeysym("F1")), Mod1Mask, root, True, GrabModeAsync, GrabModeAsync); XGrabButton(dpy, 1, Mod1Mask, root, True, ButtonPressMask, GrabModeAsync, GrabModeAsync, None, None); XGrabButton(dpy, 3, Mod1Mask, root, True, ButtonPressMask, GrabModeAsync, GrabModeAsync, None, None); XGrabKey(dpy, XKeysymToKeycode(dpy, XStringToKeysym("F1")), Mod1Mask|Mod2Mask, root, True, GrabModeAsync, GrabModeAsync); XGrabButton(dpy, 1, Mod1Mask|Mod2Mask, root, True, ButtonPressMask, GrabModeAsync, GrabModeAsync, None, None); XGrabButton(dpy, 3, Mod1Mask|Mod2Mask, root, True, ButtonPressMask, GrabModeAsync, GrabModeAsync, None, None);
Hi, I disabled numlock. I tried xev with the alt-press. The output seems correct
ButtonPress event, serial 25, synthetic NO, window 0xe00001,
root 0x2a9, subw 0x0, time 116834570, (66,144), root:(68,146),
state 0x8, button 1 , same_screen YESas I attempt to drag the test window around with the alt-left holded, I get MotionNotify events,
MotionNotify event, ...
...
state 0x0, is_hint 0, same_screen YESwhich also seemed correct. As I release the press, I get a ButtonRelease and a LeaveNotify. Everything seems in order, but the window still won't move/resize... Does it have to do with how I opened chromium? I modified tinywm.c to open an xterm at startup. I opened chromium inside the xterm simply with
chromium-browser, but then again, the xev testing window and the xterm window are also not moving/resizing.
Last edited by Portal (2020-03-04 02:20:33)
Offline
I modified tinywm.c to open an xterm at startup.
And how did you do this? Show the code you are actually using.
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
Portal wrote:I modified tinywm.c to open an xterm at startup.
And how did you do this? Show the code you are actually using.
I included stdlib.h and did a system call. Not proud of my method here...but I think it did the job. The rest of tinywm's code is untouched.
/* TinyWM is written by Nick Welch <nick@incise.org> in 2005 & 2011.
*
* This software is in the public domain
* and is provided AS IS, with NO WARRANTY. */
#include <X11/Xlib.h>
#include <stdlib.h>
#define MAX(a, b) ((a) > (b) ? (a) : (b))
int main(void)
{
system("xterm");
Display * dpy;
XWindowAttributes attr;
XButtonEvent start;
XEvent ev;
if(!(dpy = XOpenDisplay(0x0))) return 1;
XGrabKey(dpy, XKeysymToKeycode(dpy, XStringToKeysym("F1")), Mod1Mask,
DefaultRootWindow(dpy), True, GrabModeAsync, GrabModeAsync);
XGrabButton(dpy, 1, Mod1Mask,DefaultRootWindow(dpy), True,
ButtonPressMask|ButtonReleaseMask|PointerMotionMask, GrabModeAsync, GrabModeAsync, None, None);
XGrabButton(dpy, 3, Mod1Mask,DefaultRootWindow(dpy), True,
ButtonPressMask|ButtonReleaseMask|PointerMotionMask, GrabModeAsync, GrabModeAsync, None, None);
start.subwindow = None;
for(;;)
{
XNextEvent(dpy, &ev);
if(ev.type == KeyPress && ev.xkey.subwindow != None)
XRaiseWindow(dpy, ev.xkey.subwindow);
else if(ev.type == ButtonPress && ev.xbutton.subwindow != None)
{
XGetWindowAttributes(dpy, ev.xbutton.subwindow, &attr);
start = ev.xbutton;
}
else if(ev.type == MotionNotify && start.subwindow != None)
{
int xdiff = ev.xbutton.x_root - start.x_root;
int ydiff = ev.xbutton.y_root - start.y_root;
XMoveResizeWindow(dpy, start.subwindow,
attr.x + (start.button==1 ? xdiff : 0),
attr.y + (start.button==1 ? ydiff : 0),
MAX(1, attr.width + (start.button==3 ? xdiff : 0)),
MAX(1, attr.height + (start.button==3 ? ydiff : 0)));
}
else if(ev.type == ButtonRelease)
start.subwindow = None;
}
}Offline
Compile and run
#include <stdlib.h>
#include <stdio.h>
int main(int argc, char **argv) {
printf("starting…\n");
system("xterm");
printf("started\n");
}then contemplate about it for a while ;-)
Online
The rest of tinywm's code is untouched.
And unexecuted.
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
then contemplate about it for a while ;-)
And unexecuted
Oh! The xev testing window now resizes and moves now (opened with
DISPLAY=:1 xev)!
I reverted tinywm.c to its original code. However, if I do
DISPLAY=:1 chromium-browserthis new window still does not move/resize. Same for the terminal window opened with
DISPLAY=:1 xtermIs this expected behavior? If so, why is this happening?
Last edited by Portal (2020-03-05 04:51:20)
Offline
Never Mind I did something stupid... everything is working now! Thanks for all your help.
Offline