You are not logged in.
I have this idea of modding TinyWM's source code, but my programming skills in C/Python are next to zilch, and don't bother asking me anything about Xlib. However, the source code seems simple enough to vaguely understand what's going on, but at this point I'm completely stumped. I was messing with the key/button events but never come up with any usable results. I always end up with the mouse not responding to anything other than the functions of the running program (e. g. Xterm, Opera, etc. ). I did a little research on Xlib but I just can't seem to make things work properly. See, what I'm trying to accomplish is to control the windows with the mouse alone, by using a combination of mouse buttons 1-3. For example, buttons 1+3 cycles through and raises windows, 1+2 resizes=move, 2+3resize. Or better, invoke actions depending where in the window you click, for example click within x pixels behind window edge with button1 to move, double click after x pixels of border to resize, doubleclick within XxY pixels of top left corner with to minimize, top right corner to close. Is it even possible to trigger an action based on in which order the buttons are pressed (e.g. pressing button1 first and button2 second moves windows while pressing button2 before button1 resizes windows?)
This is where I'm at right now:
/* TinyWM is written by Nick Welch <mack@incise.org>, 2005.
*
* This software is in the public domain
* and is provided AS IS, with NO WARRANTY. */
#include <X11/Xlib.h>
#define MAX(a, b) ((a) > (b) ? (a) : (b))
int main()
{
Display * dpy;
Window root;
XWindowAttributes attr;
XButtonEvent start;
XEvent ev;
if(!(dpy = XOpenDisplay(0x0))) return 1;
root = DefaultRootWindow(dpy);
XGrabButton(dpy, 1, Button3, root, True, ButtonPressMask, GrabModeAsync,
GrabModeAsync, None, None);
XGrabButton(dpy, 1, Button2, root, True, ButtonPressMask, GrabModeAsync,
GrabModeAsync, None, None);
XGrabButton(dpy, 2, Button3, root, True, ButtonPressMask, GrabModeAsync,
GrabModeAsync, None, None);
for(;;)
{
XNextEvent(dpy, &ev);
if(ev.type == ButtonPress && ev.xbutton.subwindow != None)
XRaiseWindow(dpy, ev.xbutton.subwindow);
else if(ev.type == ButtonPress && ev.xbutton.subwindow != None)
{
XGrabPointer(dpy, ev.xbutton.subwindow, True,
PointerMotionMask|ButtonReleaseMask, GrabModeAsync,
GrabModeAsync, None, None, CurrentTime);
XGetWindowAttributes(dpy, ev.xbutton.subwindow, &attr);
start = ev.xbutton;
}
else if(ev.type == MotionNotify)
{
int xdiff, ydiff;
while(XCheckTypedEvent(dpy, MotionNotify, &ev));
xdiff = ev.xbutton.x_root - start.x_root;
ydiff = ev.xbutton.y_root - start.y_root;
XMoveResizeWindow(dpy, ev.xmotion.window,
attr.x + (start.button==2 ? xdiff : 0),
attr.y + (start.button==2 ? 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)
XUngrabPointer(dpy, CurrentTime);
}
}As you can tell, I replaced the parts for F1 and Mod1Mask with the mouse buttons I like to use, and assigned the appropriate mouse buttons to the move/resize routines. Unfortunately, that doesn't seem to work. By the way, replacing Mod1Mask with say Button1Mask causes X to crash. Could someone please help me out or at least point me to the right direction?
PS: Just in case the question comes up - I am aware that there are window managers out there that are and work much better than TinyWM, and this is an idea and project that I've been obsessing over for some time now and will continue to do so until I succeed, no matter what. Also it's simplicity and small footprint greatly appeal to me.
UPDATE: I modified the post do correct a mistake and be more clear about what I want to accomplish (added another possible option)
Last edited by bloodyhell (2016-11-21 19:50:32)
Offline