|
| 1 | +#define _GNU_SOURCE |
| 2 | +#include <X11/Xatom.h> |
| 3 | +#include <X11/Xlib.h> |
| 4 | +#include <X11/Xutil.h> |
| 5 | +#include <dlfcn.h> |
| 6 | +#include <stdio.h> |
| 7 | +#include <string.h> |
| 8 | + |
| 9 | +Status XIconifyWindow(Display* display, Window w, int screen_number) { |
| 10 | + return 1; |
| 11 | +} |
| 12 | + |
| 13 | +Status XSendEvent(Display* display, Window w, Bool propagate, long event_mask, |
| 14 | + XEvent* event_send) { |
| 15 | + static Status (*orig_XSendEvent)(Display*, Window, Bool, long, XEvent*) = |
| 16 | + NULL; |
| 17 | + if (!orig_XSendEvent) orig_XSendEvent = dlsym(RTLD_NEXT, "XSendEvent"); |
| 18 | + |
| 19 | + if (event_send->type == ClientMessage) { |
| 20 | + Atom msg_type = event_send->xclient.message_type; |
| 21 | + Atom wm_state = XInternAtom(display, "_NET_WM_STATE", False); |
| 22 | + |
| 23 | + if (msg_type == wm_state) { |
| 24 | + long action = event_send->xclient.data.l[0]; |
| 25 | + Atom prop = (Atom)event_send->xclient.data.l[1]; |
| 26 | + Atom hidden = XInternAtom(display, "_NET_WM_STATE_HIDDEN", False); |
| 27 | + |
| 28 | + if (prop == hidden) { |
| 29 | + return 1; |
| 30 | + } |
| 31 | + } |
| 32 | + } |
| 33 | + return orig_XSendEvent(display, w, propagate, event_mask, event_send); |
| 34 | +} |
| 35 | + |
| 36 | +int XChangeProperty(Display* display, Window w, Atom property, Atom type, |
| 37 | + int format, int mode, const unsigned char* data, |
| 38 | + int nelements) { |
| 39 | + static int (*orig_XChangeProperty)(Display*, Window, Atom, Atom, int, int, |
| 40 | + const unsigned char*, int) = NULL; |
| 41 | + if (!orig_XChangeProperty) |
| 42 | + orig_XChangeProperty = dlsym(RTLD_NEXT, "XChangeProperty"); |
| 43 | + |
| 44 | + Atom wm_hints = XInternAtom(display, "WM_HINTS", False); |
| 45 | + if (property == wm_hints && data) { |
| 46 | + XWMHints* hints = (XWMHints*)data; |
| 47 | + if (hints->flags & StateHint && hints->initial_state == IconicState) { |
| 48 | + hints->initial_state = NormalState; |
| 49 | + } |
| 50 | + } |
| 51 | + return orig_XChangeProperty(display, w, property, type, format, mode, data, |
| 52 | + nelements); |
| 53 | +} |
0 commit comments