Compile X Window Manager
Samms
matesax at gmail.com
Wed May 22 12:07:15 PDT 2013
Oh - no! :) Compilation is OK - but Manager not work. It is only
overwrite od TinyWM:
import std.c.linux.X11.Xlib;
import std.c.linux.X11.X;
/* gdc ./main.d /usr/include/d2/4.6/std/c/linux/X11/Xlib.d -o
refuja -lX11 */
int main()
{
Display *dpy;
XWindowAttributes attr;
XButtonEvent start;
XEvent ev;
dpy = XOpenDisplay(cast(char*)0);
if(!dpy)
return 1;
XGrabKey(dpy, XKeysymToKeycode(dpy,
XStringToKeysym(cast(char*)"F1")), KeyMask.Mod1Mask,
DefaultRootWindow(dpy), cast(Bool)true, GrabMode.GrabModeAsync,
GrabMode.GrabModeAsync);
XGrabButton(dpy, 1, KeyMask.Mod1Mask, DefaultRootWindow(dpy),
cast(Bool)true,
EventMask.ButtonPressMask|EventMask.ButtonReleaseMask|EventMask.PointerMotionMask,
GrabMode.GrabModeAsync, GrabMode.GrabModeAsync, None, None);
XGrabButton(dpy, 3, KeyMask.Mod1Mask, DefaultRootWindow(dpy),
cast(Bool)true,
EventMask.ButtonPressMask|EventMask.ButtonReleaseMask|EventMask.PointerMotionMask,
GrabMode.GrabModeAsync, GrabMode.GrabModeAsync, None, None);
start.subwindow = None;
while(true)
{
XNextEvent(dpy, &ev);
if(ev.type == EventType.KeyPress && ev.xkey.subwindow != None)
XRaiseWindow(dpy, ev.xkey.subwindow);
else if(ev.type == EventType.ButtonPress &&
ev.xbutton.subwindow != None)
{
XGetWindowAttributes(dpy, ev.xbutton.subwindow, &attr);
start = ev.xbutton;
}
else if(ev.type == EventType.MotionNotify && start.subwindow !=
None)
{
int xdiff = ev.xbutton.x_root - start.x_root,
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 == EventType.ButtonRelease)
start.subwindow = None;
}
}
int Max(int a, int b)
{
return (a > b ? a : b);
}
What is the problem?
Thank you.
More information about the D.gnu
mailing list