wm

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

commit 9a8688a5dd2ade4c559555e913c32553bf63fc1c
parent 1fbbf1502c48eefbedb42d4fc941cfb2ff7eabba
Author: Pablo Cárdenas <pablo.cardenas@imca.edu.pe>
Date:   Mon, 30 Dec 2024 05:17:24 -0500

Removed _NET_SUPPORTED

Diffstat:
Mpwm.c | 58+++++++++++-----------------------------------------------
1 file changed, 11 insertions(+), 47 deletions(-)

diff --git a/pwm.c b/pwm.c @@ -64,41 +64,18 @@ int main(void) XGrabButton(dpy, 1, Mod4Mask, root, True, ButtonPressMask | ButtonReleaseMask | PointerMotionMask, GrabModeAsync, GrabModeAsync, None, None); XGrabButton(dpy, 3, Mod4Mask, root, True, ButtonPressMask | ButtonReleaseMask | PointerMotionMask, GrabModeAsync, GrabModeAsync, None, None); + + // https://specifications.freedesktop.org/wm-spec/1.3/ar01s03.html#id-1.4.12 Window wmcheckwin = XCreateSimpleWindow(dpy, root, 0, 0, 1, 1, 0, 0, 0); printf("wmcheckwin = %lx\n", wmcheckwin); + XChangeProperty(dpy, wmcheckwin, XInternAtom(dpy, "_NET_SUPPORTING_WM_CHECK", False), XA_WINDOW, 32, PropModeReplace, (unsigned char *)&wmcheckwin, 1); + XChangeProperty(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); - Atom NetWMCheck = XInternAtom(dpy, "_NET_SUPPORTING_WM_CHECK", False); - Atom utf8string = XInternAtom(dpy, "UTF8_STRING", False); - Atom NetWMName = XInternAtom(dpy, "_NET_WM_NAME", False); - - /* This sets the _NET_SUPPORTING_WM_CHECK property on the supporting window referring to - * its own window ID. */ - XChangeProperty(dpy, wmcheckwin, NetWMCheck, XA_WINDOW, 32, PropModeReplace, (unsigned char *)&wmcheckwin, 1); - - /* This sets the _NET_WM_NAME property on the supporting window with the name of the window - * manager. */ - XChangeProperty(dpy, wmcheckwin, NetWMName, utf8string, 8, PropModeReplace, (unsigned char *)"pwm", 3); - - /* This sets the _NET_SUPPORTING_WM_CHECK on the root window referring to the supporting - * window's window ID. */ - XChangeProperty(dpy, root, NetWMCheck, XA_WINDOW, 32, PropModeReplace, (unsigned char *)&wmcheckwin, 1); - - /* This represents the various extended window manager hint atoms that pwm supports. */ - Atom netatom[9] = { - XInternAtom(dpy, "_NET_SUPPORTED", False), - XInternAtom(dpy, "_NET_WM_NAME", False), - XInternAtom(dpy, "_NET_WM_STATE", False), - XInternAtom(dpy, "_NET_SUPPORTING_WM_CHECK", False), - XInternAtom(dpy, "_NET_WM_STATE_FULLSCREEN", False), - XInternAtom(dpy, "_NET_WM_WINDOW_TYPE", False), - XInternAtom(dpy, "_NET_WM_WINDOW_TYPE_DIALOG", False), - }; - XChangeProperty(dpy, root, netatom[0], XA_ATOM, 32, PropModeReplace, (unsigned char *)netatom, sizeof(netatom) / sizeof(Atom)); /////////////////////////// // Scan existing windows // /////////////////////////// - { Window d1, d2; Window *wins; @@ -233,30 +210,12 @@ int main(void) XSetInputFocus(dpy, windows[current_index], RevertToParent, CurrentTime); XRaiseWindow(dpy, windows[current_index]); XSetWindowBorder(dpy, windows[current_index], 0xAAAAAA); - XClientMessageEvent send_ev = { - .type = ClientMessage, - .window = windows[current_index], - .message_type = XInternAtom(dpy, "WM_PROTOCOLS", False), - .format = 32, - .data.l[0] = XInternAtom(dpy, "WM_TAKE_FOCUS", False), - .data.l[1] = CurrentTime, - }; - XSendEvent(dpy, windows[current_index], False, NoEventMask, (XEvent *)&send_ev); } else if (ev.xkey.keycode == XKeysymToKeycode(dpy, XStringToKeysym("k"))) { XSetWindowBorder(dpy, windows[current_index], BORDER_COLOR); current_index = (current_index + 1) % num_windows; XSetInputFocus(dpy, windows[current_index], RevertToParent, CurrentTime); XRaiseWindow(dpy, windows[current_index]); XSetWindowBorder(dpy, windows[current_index], 0xAAAAAA); - XClientMessageEvent send_ev = { - .type = ClientMessage, - .window = windows[current_index], - .message_type = XInternAtom(dpy, "WM_PROTOCOLS", False), - .format = 32, - .data.l[0] = XInternAtom(dpy, "WM_TAKE_FOCUS", False), - .data.l[1] = CurrentTime, - }; - XSendEvent(dpy, windows[current_index], False, NoEventMask, (XEvent *)&send_ev); } else if (ev.xkey.keycode == XKeysymToKeycode(dpy, XStringToKeysym("q"))) { // TODO: Only send event If the window supports (XGetWMProtocols) Atom *protocols; @@ -311,7 +270,12 @@ int main(void) fprintf(stderr, "%d: ButtonRelease\n", ev.type); break; case PropertyNotify: - fprintf(stderr, "%d: PropertyNotify : ev.xproperty.atom = %ld: %s\n", ev.type, ev.xproperty.atom, XGetAtomName(dpy, ev.xproperty.atom)); + fprintf(stderr, + "%d: PropertyNotify : ev.xproperty.atom = %ld: %s : ev.xproperty.state = %d", + ev.type, + ev.xproperty.atom, + XGetAtomName(dpy, ev.xproperty.atom), + ev.xproperty.state); break; default: fprintf(stderr, "ev.type = %2d ", ev.type);