PDA

View Full Version : intro to window manager programming?



hessiess
October 13th, 2008, 09:43 AM
I've been thinking about writing a 'blender-like' tiling window manager for a few months. i have a resalable understanding of C++, however I don't know how X window managers, or the xlib/XCB API's work. so as of yet, ive been unable to understand the source code of the WM's ive looked at (DWM). are there any 'intro to WM programming' tutorials.

thanks.

hessiess
October 13th, 2008, 05:48 PM
bump?

LaRoza
October 13th, 2008, 05:52 PM
http://freshmeat.net/projects/tinywm/

TinyWM is the smallest in code that I know of, it would be a good start.

hessiess
October 13th, 2008, 06:11 PM
thanks laroza, il take a look at that and see if it makes sense :)

hessiess
October 14th, 2008, 08:38 PM
So, ive hit anouther brick wall. Im trying to experement with the tinywm source code, but I cannot run the window manager, as Awesome is already running. is it possable to create a window within the current window manager, that is running a differnt window manager, amd can have apps opened within it?

shutting down one WM, and starting anotuher one is anoying, espetily if I made a bug, and it crasshes, leaving me with no WM, and thus have to restart X.

doorman
October 14th, 2008, 10:18 PM
you could set up a testing virtual machine and restart X there every time

stroyan
October 14th, 2008, 11:13 PM
You can use the Xnest command from the xnest package to run an X server
as a client to another X server. You probably want to unset XAUTHORITY
so your clients don't need an xauth entry for the new X server. Or you
could use xauth to set a cookie for the other X server.


unset XAUTHORITY; Xnest :3 & sleep 2; DISPLAY=:3 xterm


There is also a mechanism to run Xorg on multiple virtual terminals
using the vtXX option to select which virtual terminal to use.
Then the different X servers can be selected with <ctrl><alt>,FN>.
But that doesn't seem as nice as simultaneously seeing both the xnest
window and a debugger in the original X server.

hessiess
October 15th, 2008, 12:52 AM
You can use the Xnest command from the xnest package to run an X server
as a client to another X server. You probably want to unset XAUTHORITY
so your clients don't need an xauth entry for the new X server. Or you
could use xauth to set a cookie for the other X server.


unset XAUTHORITY; Xnest :3 & sleep 2; DISPLAY=:3 xterm


There is also a mechanism to run Xorg on multiple virtual terminals
using the vtXX option to select which virtual terminal to use.
Then the different X servers can be selected with <ctrl><alt>,FN>.
But that doesn't seem as nice as simultaneously seeing both the xnest
window and a debugger in the original X server.

Thanks, il try that :)

Ive got some problem with Xlib events, what im trying to do is edit tinywm to alow you to move windows around with 'h,j,k,l':


/*create key binding*/
KeyCode KEY_H;
KEY_H = XKeysymToKeycode(dpy, XStringToKeysym("H"));

XGrabKey(dpy, KEY_H, Mod1Mask, root,
True, GrabModeAsync, GrabModeAsync);

for(;;)
{
/* loop through events*/
XNextEvent(dpy, &ev);

/* move window with H key*/
if(ev.type == KeyPress)
{
if(ev.xkey.subwindow == KEY_H)
{
XGetWindowAttributes(dpy, ev.xbutton.subwindow, &attr);
XMoveWindow(dpy, ev.xmotion.window, attr.x + 20, attr.height);
printf("aaa");
}

}
what that should do is move a window if the 'h' key is pressed, but nothing happens.

stroyan
October 15th, 2008, 03:26 AM
Your XGrabKey call is passing Mod1Mask which would require <alt>h.
Perhaps you want AnyModifier there.

You are comparing ev.xkey.subwindow instead of ev.xkey.keycode.

You are using ev.xbutton.subwindow and ev.xmotion.window for a
key event. You should only use the union member name that matches
the type of the event.