wm

My window manager
git clone git://pcardenasb.com/wm
Log | Files | Refs

commit b0ea927005cc78b3161f011ad19d2e67abf5f5f9
parent c4f29d7e5b714b388dab0e437f9ddddcc86c7f80
Author: Pablo Cárdenas <pablo.cardenas@imca.edu.pe>
Date:   Wed,  1 Jan 2025 03:59:07 -0500

added Win-m

Diffstat:
Mpwm.c | 133+++++++++++++++++++++++++++++++++++++++++--------------------------------------
1 file changed, 69 insertions(+), 64 deletions(-)

diff --git a/pwm.c b/pwm.c @@ -60,6 +60,7 @@ int main(void) XGrabKey(dpy, XKeysymToKeycode(dpy, XStringToKeysym("k")), Mod4Mask, root, True, GrabModeAsync, GrabModeAsync); XGrabKey(dpy, XKeysymToKeycode(dpy, XStringToKeysym("c")), Mod4Mask, root, True, GrabModeAsync, GrabModeAsync); XGrabKey(dpy, XKeysymToKeycode(dpy, XStringToKeysym("q")), Mod4Mask, root, True, GrabModeAsync, GrabModeAsync); + XGrabKey(dpy, XKeysymToKeycode(dpy, XStringToKeysym("m")), Mod4Mask, root, True, GrabModeAsync, GrabModeAsync); XGrabKey(dpy, XKeysymToKeycode(dpy, XStringToKeysym("space")), Mod4Mask, root, True, GrabModeAsync, GrabModeAsync); XGrabKey(dpy, XKeysymToKeycode(dpy, XStringToKeysym("Return")), Mod4Mask, root, True, GrabModeAsync, GrabModeAsync); XGrabButton(dpy, 1, Mod4Mask, root, True, ButtonPressMask | ButtonReleaseMask | PointerMotionMask, GrabModeAsync, GrabModeAsync, None, None); @@ -169,33 +170,6 @@ int main(void) case KeyPress: fprintf(stderr, "%d: XKeyEvent KeyPress %d\n", ev.type, ev.xkey.keycode); - for (int i = 0; i < num_windows; i++) { - XWindowAttributes attr; - char *window_name = NULL; - XClassHint class_hint; - Window d1; - - int status = XGetTransientForHint(dpy, windows[i], &d1); - XGetWindowAttributes(dpy, windows[i], &attr); - XFetchName(dpy, windows[i], &window_name); - XGetClassHint(dpy, windows[i], &class_hint); - - fprintf(stderr, - "%lu: %s - %s - %s - %d - (%d, %d, %d, %d) - %d(%lu)\n", - windows[i], - window_name, - class_hint.res_class, - class_hint.res_name, - attr.map_state, - attr.x, - attr.y, - attr.width, - attr.height, - status, - d1); - fprintf(stderr, "override_redirect = %d\n", attr.override_redirect); - } - if (ev.xkey.keycode == XKeysymToKeycode(dpy, XStringToKeysym("space"))) { char *const cmd_argv[] = {"dmenu_run", NULL}; spawn(cmd_argv, dpy); @@ -224,6 +198,35 @@ int main(void) dpy, wmcheckwin, XInternAtom(dpy, "_NET_WM_NAME", False), XInternAtom(dpy, "UTF8_STRING", False), 8, PropModeReplace, (unsigned char *)"pwm", 3); XChangeProperty(dpy, root, XInternAtom(dpy, "_NET_SUPPORTING_WM_CHECK", False), XA_WINDOW, 32, PropModeReplace, (unsigned char *)&wmcheckwin, 1); } + } else if (ev.xkey.keycode == XKeysymToKeycode(dpy, XStringToKeysym("m"))) { + for (int i = 0; i < num_windows; i++) { + XWindowAttributes attr; + char *window_name = NULL; + XClassHint class_hint; + Window d1; + + int status = XGetTransientForHint(dpy, windows[i], &d1); + XGetWindowAttributes(dpy, windows[i], &attr); + XFetchName(dpy, windows[i], &window_name); + XGetClassHint(dpy, windows[i], &class_hint); + + fprintf(stderr, + "%lu: %s - %s - %s - %d - (%d, %d, %d, %d) - " + "%d(%lu)\n", + windows[i], + window_name, + class_hint.res_class, + class_hint.res_name, + attr.map_state, + attr.x, + attr.y, + attr.width, + attr.height, + status, + d1); + fprintf(stderr, "override_redirect = %d\n", attr.override_redirect); + } + } else if (ev.xkey.keycode == XKeysymToKeycode(dpy, XStringToKeysym("q"))) { // TODO: Only send event If the window supports (XGetWMProtocols) Atom *protocols; @@ -232,7 +235,7 @@ int main(void) if (XGetWMProtocols(dpy, windows[current_index], &protocols, &n)) { while (!exists && n--) { printf("protocols[%d] = %s\n", n, XGetAtomName(dpy, protocols[n])); - exists = protocols[n] == XInternAtom(dpy, "WM_DELETE_WINDOW", False); + exists = XInternAtom(dpy, "WM_DELETE_WINDOW", False) == protocols[n]; } XFree(protocols); } @@ -279,7 +282,7 @@ int main(void) break; case PropertyNotify: fprintf(stderr, - "%d: PropertyNotify : ev.xproperty.atom = %ld: %s : ev.xproperty.state = %d", + "%d: PropertyNotify : ev.xproperty.atom = %ld: %s : ev.xproperty.state = %d\n", ev.type, ev.xproperty.atom, XGetAtomName(dpy, ev.xproperty.atom), @@ -288,41 +291,43 @@ int main(void) default: fprintf(stderr, "ev.type = %2d ", ev.type); char events[LASTEvent + 1][19] = { - [2] = "KeyPress", - [3] = "KeyRelease", - [4] = "ButtonPress", - [5] = "ButtonRelease", - [6] = "MotionNotify", - [7] = "EnterNotify", - [8] = "LeaveNotify", - [9] = "FocusIn", - [10] = "FocusOut", - [11] = "KeymapNotify", - [12] = "Expose", - [13] = "GraphicsExpose", - [14] = "NoExpose", - [15] = "VisibilityNotify", - [16] = "CreateNotify", - [17] = "DestroyNotify", - [18] = "UnmapNotify", - [19] = "MapNotify", - [20] = "MapRequest", - [21] = "ReparentNotify", - [22] = "ConfigureNotify", - [23] = "ConfigureRequest", - [24] = "GravityNotify", - [25] = "ResizeRequest", - [26] = "CirculateNotify", - [27] = "CirculateRequest", - [28] = "PropertyNotify", - [29] = "SelectionClear", - [30] = "SelectionRequest", - [31] = "SelectionNotify", - [32] = "ColormapNotify", - [33] = "ClientMessage", - [34] = "MappingNotify", - [35] = "GenericEvent", - [36] = "LASTEvent", + "", + "", + "KeyPress", + "KeyRelease", + "ButtonPress", + "ButtonRelease", + "MotionNotify", + "EnterNotify", + "LeaveNotify", + "FocusIn", + "FocusOut", + "KeymapNotify", + "Expose", + "GraphicsExpose", + "NoExpose", + "VisibilityNotify", + "CreateNotify", + "DestroyNotify", + "UnmapNotify", + "MapNotify", + "MapRequest", + "ReparentNotify", + "ConfigureNotify", + "ConfigureRequest", + "GravityNotify", + "ResizeRequest", + "CirculateNotify", + "CirculateRequest", + "PropertyNotify", + "SelectionClear", + "SelectionRequest", + "SelectionNotify", + "ColormapNotify", + "ClientMessage", + "MappingNotify", + "GenericEvent", + "LASTEvent", }; fprintf(stderr, "= %s\n", events[ev.type]); }