You are not logged in.

#1 2020-02-27 07:09:49

Portal
Member
Registered: 2019-03-11
Posts: 48

[SOLVED] TinyWM not working under Xephyr

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 -lX11

From 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

#2 2020-02-27 07:56:44

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,721

Re: [SOLVED] TinyWM not working under Xephyr

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?

Offline

#3 2020-02-27 14:55:19

Portal
Member
Registered: 2019-03-11
Posts: 48

Re: [SOLVED] TinyWM not working under Xephyr

seth wrote:

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

#4 2020-02-27 15:49:07

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,721

Re: [SOLVED] TinyWM not working under Xephyr

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)

Offline

#5 2020-03-03 03:38:12

Portal
Member
Registered: 2019-03-11
Posts: 48

Re: [SOLVED] TinyWM not working under Xephyr

seth wrote:

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 off

I 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

#6 2020-03-03 07:34:50

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,721

Re: [SOLVED] TinyWM not working under Xephyr

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

Offline

#7 2020-03-04 02:18:51

Portal
Member
Registered: 2019-03-11
Posts: 48

Re: [SOLVED] TinyWM not working under Xephyr

seth wrote:

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 YES

as 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 YES

which 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

#8 2020-03-04 03:05:48

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,517
Website

Re: [SOLVED] TinyWM not working under Xephyr

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.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#9 2020-03-04 03:10:07

Portal
Member
Registered: 2019-03-11
Posts: 48

Re: [SOLVED] TinyWM not working under Xephyr

Trilby wrote:
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

#10 2020-03-04 07:12:08

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,721

Re: [SOLVED] TinyWM not working under Xephyr

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

Offline

#11 2020-03-04 12:04:30

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,517
Website

Re: [SOLVED] TinyWM not working under Xephyr

Portal wrote:

The rest of tinywm's code is untouched.

And unexecuted.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#12 2020-03-05 04:47:55

Portal
Member
Registered: 2019-03-11
Posts: 48

Re: [SOLVED] TinyWM not working under Xephyr

seth wrote:

then contemplate about it for a while ;-)

Trilby wrote:

And unexecuted

Oh! The xev testing window now resizes and moves now (opened with

 DISPLAY=:1 xev

)! big_smile I reverted tinywm.c to its original code. However, if I do

DISPLAY=:1 chromium-browser

this new window still does not move/resize. Same for the terminal window opened with

DISPLAY=:1 xterm

Is this expected behavior? If so, why is this happening?

Last edited by Portal (2020-03-05 04:51:20)

Offline

#13 2020-03-05 06:47:32

Portal
Member
Registered: 2019-03-11
Posts: 48

Re: [SOLVED] TinyWM not working under Xephyr

Never Mind I did something stupid... everything is working now! Thanks for all your help.

Offline

Board footer

Powered by FluxBB