aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorallusive-dev <[email protected]>2023-11-08 09:50:17 +1100
committerallusive-dev <[email protected]>2023-11-08 09:50:17 +1100
commita1f306539842b104abe23e9654d32308de2dcded (patch)
tree39309626992e42a085b0601fdbc514efbec688d0 /src
parentUpdate README.md (diff)
downloadcompfy-a1f306539842b104abe23e9654d32308de2dcded.tar.xz
compfy-a1f306539842b104abe23e9654d32308de2dcded.zip
Window Manager support is now applied automatically without using 'wm-support'
Diffstat (limited to 'src')
-rw-r--r--src/atom.h3
-rw-r--r--src/config_libconfig.c3
-rw-r--r--src/options.c3
-rw-r--r--src/picom.c20
-rw-r--r--src/win.c13
-rw-r--r--src/wm_check.c22
-rw-r--r--src/wm_check.h6
7 files changed, 62 insertions, 8 deletions
diff --git a/src/atom.h b/src/atom.h
index baf3360..6f4eae6 100644
--- a/src/atom.h
+++ b/src/atom.h
@@ -23,8 +23,7 @@
WM_CLIENT_MACHINE, \
_NET_ACTIVE_WINDOW, \
_COMPTON_SHADOW, \
- _NET_WM_WINDOW_TYPE, \
- _NET_CURRENT_DESKTOP
+ _NET_WM_WINDOW_TYPE
#define ATOM_LIST2 \
_NET_WM_WINDOW_TYPE_DESKTOP, \
diff --git a/src/config_libconfig.c b/src/config_libconfig.c
index 1b81a50..9b537b9 100644
--- a/src/config_libconfig.c
+++ b/src/config_libconfig.c
@@ -601,7 +601,8 @@ char *parse_config_libconfig(options_t *opt, const char *config_file, bool *shad
log_fatal("Invalid window manager name passed %s", sval);
goto err;
}
- opt->support_for_wm = wm;
+ log_warn("wm-support is deprecated. Your window manager will now be detected and have patches applied automatically");
+ opt->support_for_wm = WM_SUPPORT_NONE;
}
// --opacity-rule
parse_cfg_condlst_opct(opt, &cfg, "opacity-rule");
diff --git a/src/options.c b/src/options.c
index c98a77e..e2fcd42 100644
--- a/src/options.c
+++ b/src/options.c
@@ -805,7 +805,8 @@ bool get_cfg(options_t *opt, int argc, char *const *argv, bool shadow_enable,
if (wm >= WM_SUPPORT_INVALID) {
log_warn("Invalid window manager %s, ignoring.", optarg);
} else {
- opt->support_for_wm = wm;
+ log_warn("wm-support is deprecated. Your window manager will now be detected and have patches applied automatically");
+ opt->support_for_wm = WM_SUPPORT_NONE;
}
break;
}
diff --git a/src/picom.c b/src/picom.c
index c8dea67..7c350b9 100644
--- a/src/picom.c
+++ b/src/picom.c
@@ -17,6 +17,7 @@
#include <fcntl.h>
#include <inttypes.h>
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <xcb/composite.h>
@@ -62,6 +63,8 @@
#include "options.h"
#include "uthash_extra.h"
+#include "wm_check.c"
+
/// Get session_t pointer from a pointer to a member of session_t
#define session_ptr(ptr, member) \
({ \
@@ -835,9 +838,11 @@ paint_preprocess(session_t *ps, bool *fade_running, bool *animation_running) {
if (size_changed) {
win_on_win_size_change(ps, w);
- if (ps->o.support_for_wm == WM_SUPPORT_AWESOME) {
+ const char *wm = checkWindowManager();
+
+ if (strcmp(wm, "awesome") == 0) {
win_update_bounding_shape(ps, w);
- } else if (ps->o.support_for_wm == WM_SUPPORT_HERB) {
+ } else if (strcmp(wm, "herb") == 0) {
win_update_bounding_shape(ps, w);
} else {
pixman_region32_clear(&w->bounding_shape);
@@ -846,6 +851,17 @@ paint_preprocess(session_t *ps, bool *fade_running, bool *animation_running) {
(uint)w->widthb, (uint)w->heightb);
}
+ // if (ps->o.support_for_wm == WM_SUPPORT_AWESOME) {
+ // win_update_bounding_shape(ps, w);
+ // } else if (ps->o.support_for_wm == WM_SUPPORT_HERB) {
+ // win_update_bounding_shape(ps, w);
+ // } else {
+ // pixman_region32_clear(&w->bounding_shape);
+ // pixman_region32_fini(&w->bounding_shape);
+ // pixman_region32_init_rect(&w->bounding_shape, 0, 0,
+ // (uint)w->widthb, (uint)w->heightb);
+ // }
+
if (w->state != WSTATE_DESTROYING)
win_clear_flags(w, WIN_FLAGS_PIXMAP_STALE);
diff --git a/src/win.c b/src/win.c
index 1392020..b82e522 100644
--- a/src/win.c
+++ b/src/win.c
@@ -34,6 +34,8 @@
#include "utils.h"
#include "x.h"
+#include "wm_check.h"
+
#ifdef CONFIG_DBUS
#include "dbus.h"
#endif
@@ -1126,13 +1128,16 @@ double win_calc_opacity_target(session_t *ps, const struct managed_win *w) {
return 0;
}
+
+ const char *wm = checkWindowManager();
+
// Try obeying opacity property and window type opacity firstly
if (w->has_opacity_prop) {
opacity = ((double)w->opacity_prop) / OPAQUE;
} else if (w->opacity_is_set && !ps->o.inactive_opacity_override) {
opacity = w->opacity_set;
} else if (w->opacity_is_set && ps->o.inactive_opacity_override) {
- if (ps->o.support_for_wm == WM_SUPPORT_DWM) {
+ if (strcmp(wm, "dwm") == 0) {
if (win_is_focused_raw(ps, w)) {
if (c2_match(ps, w, ps->o.active_opacity_blacklist, NULL)) {
opacity = 1.0;
@@ -1210,7 +1215,10 @@ bool win_should_dim(session_t *ps, const struct managed_win *w) {
return false;
}
- if (ps->o.support_for_wm == WM_SUPPORT_DWM) {
+ const char *wm = checkWindowManager();
+
+ if (strcmp(wm, "dwm") == 0) {
+ // printf("DWM True\n");
if (ps->o.inactive_dim > 0 && !win_is_focused_raw(ps, w)) {
if (c2_match(ps, w, ps->o.inactive_opacity_blacklist, NULL)) {
return false;
@@ -1221,6 +1229,7 @@ bool win_should_dim(session_t *ps, const struct managed_win *w) {
return false;
}
} else {
+ // printf("DWM False\n");
if (ps->o.inactive_dim > 0 && !win_is_focused_raw(ps, w)) {
if (c2_match(ps, w, ps->o.inactive_opacity_blacklist, NULL)) {
return false;
diff --git a/src/wm_check.c b/src/wm_check.c
new file mode 100644
index 0000000..5e153f8
--- /dev/null
+++ b/src/wm_check.c
@@ -0,0 +1,22 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+const char *checkWindowManager() {
+ char *desktopSession = getenv("DESKTOP_SESSION");
+ if (desktopSession == NULL) {
+ return "Not Found";
+ } else {
+ if (strstr(desktopSession, "xmonad") != NULL) {
+ return "xmonad";
+ } else if (strstr(desktopSession, "herb") != NULL) {
+ return "herb";
+ } else if (strstr(desktopSession, "awesome") != NULL) {
+ return "awesome";
+ } else if (strstr(desktopSession, "dwm") != NULL) {
+ return "dwm";
+ } else {
+ return desktopSession;
+ }
+ }
+} \ No newline at end of file
diff --git a/src/wm_check.h b/src/wm_check.h
new file mode 100644
index 0000000..0b95d4d
--- /dev/null
+++ b/src/wm_check.h
@@ -0,0 +1,6 @@
+#ifndef WINDOW_MANAGER_CHECKER_H
+#define WINDOW_MANAGER_CHECKER_H
+
+const char *checkWindowManager();
+
+#endif \ No newline at end of file