diff options
Diffstat (limited to 'src/sxwm.c')
| -rw-r--r-- | src/sxwm.c | 64 |
1 files changed, 44 insertions, 20 deletions
@@ -104,6 +104,7 @@ void update_struts(void); void update_workarea(void); void warp_cursor(Client *c); Bool window_should_float(Window w); +Bool window_should_start_fullscreen(Window w); int xerr(Display *dpy, XErrorEvent *ee); void xev_case(XEvent *xev); #include "config.h" @@ -112,7 +113,6 @@ Atom atom_net_active_window; Atom atom_net_current_desktop; Atom atom_net_supported; Atom atom_net_wm_state; -Atom atom_net_wm_state_fullscreen; Atom atom_wm_window_type; Atom atom_net_wm_window_type_dock; Atom atom_net_workarea; @@ -854,19 +854,6 @@ void hdl_client_msg(XEvent *xev) change_workspace(ws); return; } - if (xev->xclient.message_type == atom_net_wm_state) { - long action = xev->xclient.data.l[0]; - Atom target = xev->xclient.data.l[1]; - if (target == atom_net_wm_state_fullscreen) { - if (action == 1 || action == 2) { - toggle_fullscreen(); - } - else if (action == 0 && focused && focused->fullscreen) { - toggle_fullscreen(); - } - } - return; - } } void hdl_config_ntf(XEvent *xev) @@ -1190,6 +1177,11 @@ void hdl_map_req(XEvent *xev) c->floating = True; } + if (window_should_start_fullscreen(w)) { + c->fullscreen = True; + c->floating = False; + } + /* center floating windows & set border */ if (c->floating && !c->fullscreen) { int w_ = MAX(c->w, 64), h_ = MAX(c->h, 64); @@ -1281,6 +1273,11 @@ void hdl_map_req(XEvent *xev) XMapWindow(dpy, w); c->mapped = True; + if (c->fullscreen) { + int m = c->mon; + XSetWindowBorderWidth(dpy, w, 0); + XMoveResizeWindow(dpy, w, mons[m].x, mons[m].y, mons[m].w, mons[m].h); + } set_frame_extents(w); if (user_config.new_win_focus) { @@ -1540,6 +1537,7 @@ void init_defaults(void) default_config.can_be_swallowed[i] = NULL; default_config.can_swallow[i] = NULL; default_config.open_in_workspace[i] = NULL; + default_config.start_fullscreen[i] = NULL; } default_config.motion_throttle = 60; @@ -1730,9 +1728,8 @@ long parse_col(const char *hex) return WhitePixel(dpy, DefaultScreen(dpy)); } - /* return col.pixel |= 0xff << 24; */ - /* This is a fix for picom making the borders transparent. DANGEROUS */ - return col.pixel; + /* possibly unsafe BUT i dont think it can cause any problems */ + return col.pixel |= 0xff << 24; } void quit(void) @@ -1798,6 +1795,13 @@ void reload_config(void) free(user_config.open_in_workspace[i]); user_config.open_in_workspace[i] = NULL; } + if (user_config.start_fullscreen[i]) { + if (user_config.start_fullscreen[i][0]) { + free(user_config.start_fullscreen[i][0]); + } + free(user_config.start_fullscreen[i]); + user_config.start_fullscreen[i] = NULL; + } } /* free should_float arrays */ @@ -2062,9 +2066,7 @@ void setup_atoms(void) atom_net_wm_window_type_dock = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE_DOCK", False); atom_net_workarea = XInternAtom(dpy, "_NET_WORKAREA", False); atom_net_wm_state = XInternAtom(dpy, "_NET_WM_STATE", False); - atom_net_wm_state_fullscreen = XInternAtom(dpy, "_NET_WM_STATE_FULLSCREEN", False); atom_net_wm_state = XInternAtom(dpy, "_NET_WM_STATE", False); - atom_net_wm_state_fullscreen = XInternAtom(dpy, "_NET_WM_STATE_FULLSCREEN", False); atom_wm_delete = XInternAtom(dpy, "WM_DELETE_WINDOW", False); atom_net_supporting_wm_check = XInternAtom(dpy, "_NET_SUPPORTING_WM_CHECK", False); atom_net_wm_name = XInternAtom(dpy, "_NET_WM_NAME", False); @@ -2078,7 +2080,6 @@ void setup_atoms(void) atom_net_active_window, atom_net_supported, atom_net_wm_state, - atom_net_wm_state_fullscreen, atom_wm_window_type, atom_net_wm_window_type_dock, atom_net_workarea, @@ -2711,6 +2712,29 @@ void warp_cursor(Client *c) XSync(dpy, False); } +Bool window_should_start_fullscreen(Window w) +{ + XClassHint ch; + if (XGetClassHint(dpy, w, &ch)) { + for (int i = 0; i < 256; i++) { + if (!user_config.start_fullscreen[i] || !user_config.start_fullscreen[i][0]) { + break; + } + + if ((ch.res_class && !strcmp(ch.res_class, user_config.start_fullscreen[i][0])) || + (ch.res_name && !strcmp(ch.res_name, user_config.start_fullscreen[i][0]))) { + XFree(ch.res_class); + XFree(ch.res_name); + return True; + } + } + XFree(ch.res_class); + XFree(ch.res_name); + } + + return False; +} + int xerr(Display *dpy, XErrorEvent *ee) { /* ignore noise & non fatal errors */ |
