From e7d728a3270d56394849afa68f9261a15109573e Mon Sep 17 00:00:00 2001 From: "E. Almqvist" Date: Sat, 9 Jul 2022 12:14:06 +0200 Subject: [PATCH] Cleanup & xwrappers stuff --- src/config.h | 2 +- src/dwm.c | 9 ++++++- src/xwrappers.c | 70 +++++++++++++++++++++++++++++++++++++++++++++++++ src/xwrappers.h | 7 +++++ 4 files changed, 86 insertions(+), 2 deletions(-) create mode 100644 src/xwrappers.c create mode 100644 src/xwrappers.h diff --git a/src/config.h b/src/config.h index 19d87a4..cc8f9de 100644 --- a/src/config.h +++ b/src/config.h @@ -19,7 +19,7 @@ static const char *fonts[] = { "IBM Plex Mono:size=11" }; static const char dmenufont[] = "IBM Plex Mono:size=15"; static const char bg_alt_color[] = "#272a34"; -static const char bg_color[] = "#282c34"; +static const char bg_color[] = "#21242b"; static const char text_color[] = "#bbc2cf"; static const char selected_color[] = "#81a2be"; static const char border_color_sel[] = "#444953"; diff --git a/src/dwm.c b/src/dwm.c index 740a57c..b8defcd 100644 --- a/src/dwm.c +++ b/src/dwm.c @@ -46,6 +46,9 @@ #include "drw.h" #include "util.h" +/* XWrappers */ +#include "xwrappers.h" + /* macros */ #define BUTTONMASK (ButtonPressMask|ButtonReleaseMask) #define CLEANMASK(mask) (mask & ~(numlockmask|LockMask) & (ShiftMask|ControlMask|Mod1Mask|Mod2Mask|Mod3Mask|Mod4Mask|Mod5Mask)) @@ -2174,14 +2177,18 @@ showhide(Client *c) return; if (ISVISIBLE(c)) { /* show clients top down */ + window_map(dpy, c->win, 1); + /* XMoveWindow(dpy, c->win, c->x, c->y); if ((!c->mon->lt[c->mon->sellt]->arrange || c->isfloating) && !c->isfullscreen) resize(c, c->x, c->y, c->w, c->h, 0); + */ showhide(c->snext); } else { /* hide clients bottom up */ showhide(c->snext); - XMoveWindow(dpy, c->win, WIDTH(c) * -2, c->y); + window_unmap(dpy, c->win, root, 1); + //XMoveWindow(dpy, c->win, WIDTH(c) * -2, c->y); } } diff --git a/src/xwrappers.c b/src/xwrappers.c new file mode 100644 index 0000000..75b1979 --- /dev/null +++ b/src/xwrappers.c @@ -0,0 +1,70 @@ +#include +#include +#include + +static Atom atom[LastAtom]; +static int atoms_intialised = 0; +static int (*xerrorxlib)(Display *, XErrorEvent *); + +Atom * +get_atoms(Display *dpy) +{ + if (!atoms_intialised) { + atoms[WMProtocols] = XInternAtom(dpy, "WM_PROTOCOLS", False); + atoms[WMDelete] = XInternAtom(dpy, "WM_DELETE_WINDOW", False); + atoms[WMState] = XInternAtom(dpy, "WM_STATE", False); + atoms[WMTakeFocus] = XInternAtom(dpy, "WM_TAKE_FOCUS", False); + atoms[WMChangeState] = XInternAtom(dpy, "WM_CHANGE_STATE", False); + atoms[WMWindowRole] = XInternAtom(dpy, "WM_WINDOW_ROLE", False); + + atoms[NetActiveWindow] = XInternAtom(dpy, "_NET_ACTIVE_WINDOW", False); + atoms[NetSupported] = XInternAtom(dpy, "_NET_SUPPORTED", False); + atoms[NetSystemTray] = XInternAtom(dpy, "_NET_SYSTEM_TRAY_S0", False); + atoms[NetSystemTrayOP] = XInternAtom(dpy, "_NET_SYSTEM_TRAY_OPCODE", False); + atoms[NetSystemTrayOrientation] = XInternAtom(dpy, "_NET_SYSTEM_TRAY_ORIENTATION", False); + atoms[NetSystemTrayOrientationHorz] = XInternAtom(dpy, "_NET_SYSTEM_TRAY_ORIENTATION_HORZ", False); + atoms[NetWMName] = XInternAtom(dpy, "_NET_WM_NAME", False); + atoms[NetWMState] = XInternAtom(dpy, "_NET_WM_STATE", False); + atoms[NetWMCheck] = XInternAtom(dpy, "_NET_SUPPORTING_WM_CHECK", False); + atoms[NetWMFullscreen] = XInternAtom(dpy, "_NET_WM_STATE_FULLSCREEN", False); + atoms[NetWMWindowType] = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE", False); + atoms[NetWMWindowTypeDock] = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE_DOCK", False); + atoms[NetWMWindowTypeDialog] = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE_DIALOG", False); + atoms[NetWMWindowTypeDesktop] = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE_DESKTOP", False); + atoms[NetWMMaximizedVert] = XInternAtom(dpy, "_NET_WM_STATE_MAXIMIZED_VERT", False); + atoms[NetWMMaximizedHorz] = XInternAtom(dpy, "_NET_WM_STATE_MAXIMIZED_HORZ", False); + atoms[NetClientList] = XInternAtom(dpy, "_NET_CLIENT_LIST", False); + atoms[NetClientListStacking] = XInternAtom(dpy, "_NET_CLIENT_LIST_STACKING", False); + atoms[NetCurrentDesktop] = XInternAtom(dpy, "_NET_CURRENT_DESKTOP", False); + atoms[NetDesktopNames] = XInternAtom(dpy, "_NET_DESKTOP_NAMES", False); + atoms[NetDesktopViewport] = XInternAtom(dpy, "_NET_DESKTOP_VIEWPORT", False); + atoms[NetNumberOfDesktops] = XInternAtom(dpy, "_NET_NUMBER_OF_DESKTOPS", False); + atoms[NetWMActionClose] = XInternAtom(dpy, "_NET_WM_ACTION_CLOSE", False); + atoms[NetWMDemandsAttention] = XInternAtom(dpy, "_NET_WM_DEMANDS_ATTENTION", False); + atoms[NetWMDesktop] = XInternAtom(dpy, "_NET_WM_DESKTOP", False); + atoms[NetWMMoveResize] = XInternAtom(dpy, "_NET_WM_MOVE_RESIZE", False); + + atoms[Manager] = XInternAtom(dpy, "MANAGER", False); + atoms[Xembed] = XInternAtom(dpy, "_XEMBED", False); + atoms[XembedInfo] = XInternAtom(dpy, "_XEMBED_INFO", False); + + atoms[MWMClientTags] = XInternAtom(dpy, "_MWM_CLIENT_TAGS", False); + atoms[MWMCurrentTags] = XInternAtom(dpy, "_MWM_CURRENT_TAGS", False); + atoms[MWMClientMonitor] = XInternAtom(dpy, "_MWM_CLIENT_MONITOR", False); + atoms[MWMBorderWidth] = XInternAtom(dpy, "_MWM_BORDER_WIDTH", False); + atoms[SteamGame] = XInternAtom(dpy, "STEAM_GAME", False); + + atoms[KDENetWMWindowTypeOverride] = XInternAtom(dpy, "_KDE_NET_WM_WINDOW_TYPE_OVERRIDE", False); + atoms[Utf8] = XInternAtom(dpy, "UTF8_STRING", False); + atoms[Motif] = XInternAtom(dpy, "_MOTIF_NetLast, WM_HINTS", False); + + atoms_intialised = 1; + } + return atoms; +} + +void +window_set_state(Display *dpy, Window win, long state) { + long data[] = {state, None}; + +} diff --git a/src/xwrappers.h b/src/xwrappers.h new file mode 100644 index 0000000..62759a2 --- /dev/null +++ b/src/xwrappers.h @@ -0,0 +1,7 @@ +#include +#include +#include + +void window_set_state(Display*, Window, long); +void window_map(Display*, Window win, long state); +void window_umap(Display*, Window win, Window root, int);