mirror of
https://github.com/iritmaximus/dwl.git
synced 2026-10-12 19:13:43 +03:00
removed bar-systray patch, moving to somebar
This commit is contained in:
@@ -7,14 +7,14 @@ include config.mk
|
||||
DWLCPPFLAGS = -I. -DWLR_USE_UNSTABLE -D_POSIX_C_SOURCE=200809L \
|
||||
-DVERSION=\"$(VERSION)\" $(XWAYLAND)
|
||||
DWLDEVCFLAGS = -g -pedantic -Wall -Wextra -Wdeclaration-after-statement \
|
||||
-Wno-unused-parameter -Wshadow -Wunused-macros \
|
||||
-Wno-unused-parameter -Wshadow -Wunused-macros -Werror=strict-prototypes \
|
||||
-Werror=implicit -Werror=return-type -Werror=incompatible-pointer-types \
|
||||
-Wfloat-conversion
|
||||
|
||||
# CFLAGS / LDFLAGS
|
||||
PKGS = wlroots-0.18 wayland-server xkbcommon libinput pixman-1 fcft $(XLIBS) gtk4 gtk4-layer-shell-0
|
||||
DWLCFLAGS = `$(PKG_CONFIG) --cflags $(PKGS)` $(DWLCPPFLAGS) $(DWLDEVCFLAGS) $(CFLAGS) -Iinclude
|
||||
LDLIBS = `$(PKG_CONFIG) --libs $(PKGS)` -lm $(LIBS) -Llib -lstatusnotifier-systray-gtk4
|
||||
PKGS = wlroots-0.18 wayland-server xkbcommon libinput pixman-1 fcft $(XLIBS)
|
||||
DWLCFLAGS = `$(PKG_CONFIG) --cflags $(PKGS)` $(DWLCPPFLAGS) $(DWLDEVCFLAGS) $(CFLAGS)
|
||||
LDLIBS = `$(PKG_CONFIG) --libs $(PKGS)` -lm $(LIBS)
|
||||
|
||||
all: dwl
|
||||
dwl: dwl.o util.o dwl-ipc-unstable-v2-protocol.o
|
||||
|
||||
+2
-2
@@ -12,8 +12,6 @@ static const int showbar = 1; /* 0 means no bar */
|
||||
static const int topbar = 1; /* 0 means bottom bar */
|
||||
static const char *fonts[] = {"monospace:size=10"};
|
||||
static const float rootcolor[] = COLOR(0x000000ff);
|
||||
static const int trayspacing = 4; /* Spacing between icons in system tray */
|
||||
static const int traymargins = 4; /* System tray inner margins */
|
||||
/* This conforms to the xdg-protocol. Set the alpha to zero to restore the old behavior */
|
||||
static const float fullscreen_bg[] = {0.1f, 0.1f, 0.1f, 1.0f}; /* You can also use glsl colors */
|
||||
static uint32_t colors[][3] = {
|
||||
@@ -141,6 +139,8 @@ static const Key keys[] = {
|
||||
{ MODKEY, XKB_KEY_b, togglebar, {0} },
|
||||
{ MODKEY, XKB_KEY_j, focusstack, {.i = +1} },
|
||||
{ MODKEY, XKB_KEY_k, focusstack, {.i = -1} },
|
||||
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_J, movestack, {.i = +1} },
|
||||
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_K, movestack, {.i = -1} },
|
||||
{ MODKEY, XKB_KEY_i, incnmaster, {.i = +1} },
|
||||
{ MODKEY, XKB_KEY_d, incnmaster, {.i = -1} },
|
||||
{ MODKEY, XKB_KEY_h, setmfact, {.f = -0.05f} },
|
||||
|
||||
@@ -73,22 +73,9 @@
|
||||
#include "util.h"
|
||||
#include "drwl.h"
|
||||
|
||||
#include <snsystray.h>
|
||||
#include <gdk/gdk.h>
|
||||
#include <gio/gio.h>
|
||||
#include <glib-object.h>
|
||||
#include <glib.h>
|
||||
#include <gtk/gtk.h>
|
||||
#include <gtk4-layer-shell.h>
|
||||
#include <pthread.h>
|
||||
|
||||
/* macros */
|
||||
#ifndef MAX
|
||||
#define MAX(A, B) ((A) > (B) ? (A) : (B))
|
||||
#endif /* MAX */
|
||||
#ifndef MIN
|
||||
#define MIN(A, B) ((A) < (B) ? (A) : (B))
|
||||
#endif /* MIN */
|
||||
#define CLEANMASK(mask) (mask & ~WLR_MODIFIER_CAPS)
|
||||
#define VISIBLEON(C, M) ((M) && (C)->mon == (M) && (((C)->tags & (M)->tagset[(M)->seltags]) || C->issticky))
|
||||
#define LENGTH(X) (sizeof X / sizeof X[0])
|
||||
@@ -353,15 +340,6 @@ static void focusstack(const Arg *arg);
|
||||
static Client *focustop(Monitor *m);
|
||||
static void fullscreennotify(struct wl_listener *listener, void *data);
|
||||
static void gpureset(struct wl_listener *listener, void *data);
|
||||
static void gtkactivate(GtkApplication *app, void *data);
|
||||
static void gtkclosewindows(void *data, void *udata);
|
||||
static void gtkhandletogglebarmsg(void *data);
|
||||
static void gtkhandlewidthnotify(SnSystray *systray, GParamSpec *pspec, void *data);
|
||||
static void* gtkinit(void *data);
|
||||
static void gtkspawnstray(Monitor *m, GtkApplication *app);
|
||||
static void gtkterminate(void *data);
|
||||
static void gtktoggletray(void *data, void *udata);
|
||||
static GdkMonitor* gtkwlrtogdkmon(Monitor *wlrmon);
|
||||
static void handlesig(int signo);
|
||||
static void incnmaster(const Arg *arg);
|
||||
static void inputdevice(struct wl_listener *listener, void *data);
|
||||
@@ -374,6 +352,7 @@ static void locksession(struct wl_listener *listener, void *data);
|
||||
static void mapnotify(struct wl_listener *listener, void *data);
|
||||
static void maximizenotify(struct wl_listener *listener, void *data);
|
||||
static void monocle(Monitor *m);
|
||||
static void movestack(const Arg *arg);
|
||||
static void motionabsolute(struct wl_listener *listener, void *data);
|
||||
static void motionnotify(uint32_t time, struct wlr_input_device *device, double sx,
|
||||
double sy, double sx_unaccel, double sy_unaccel);
|
||||
@@ -420,7 +399,7 @@ static void unlocksession(struct wl_listener *listener, void *data);
|
||||
static void unmaplayersurfacenotify(struct wl_listener *listener, void *data);
|
||||
static void unmapnotify(struct wl_listener *listener, void *data);
|
||||
static void updatemons(struct wl_listener *listener, void *data);
|
||||
static void updatebar(Monitor *m, int traywidth);
|
||||
static void updatebar(Monitor *m);
|
||||
static void updatetitle(struct wl_listener *listener, void *data);
|
||||
static void urgent(struct wl_listener *listener, void *data);
|
||||
static void view(const Arg *arg);
|
||||
@@ -438,8 +417,6 @@ static void swallow(Client *c, Client *w);
|
||||
/* variables */
|
||||
static const char broken[] = "broken";
|
||||
static pid_t child_pid = -1;
|
||||
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
static pthread_t gtkthread; /* Gtk functions are only allowed to be called from this thread */
|
||||
static int locked;
|
||||
static void *exclusive_focus;
|
||||
static struct wl_display *dpy;
|
||||
@@ -1272,7 +1249,7 @@ createmon(struct wl_listener *listener, void *data)
|
||||
|
||||
m->scene_buffer = wlr_scene_buffer_create(layers[LyrBottom], NULL);
|
||||
m->scene_buffer->point_accepts_input = baracceptsinput;
|
||||
updatebar(m, 0);
|
||||
updatebar(m);
|
||||
|
||||
wl_list_insert(&mons, &m->link);
|
||||
drawbars();
|
||||
@@ -1652,8 +1629,6 @@ drawbar(Monitor *m)
|
||||
if (!(buf = bufmon(m)))
|
||||
return;
|
||||
|
||||
pthread_mutex_lock(&mutex);
|
||||
|
||||
/* draw status first so it can be overdrawn by tags later */
|
||||
if (m == selmon) { /* status is only drawn on selected monitor */
|
||||
drwl_setscheme(m->drw, colors[SchemeNorm]);
|
||||
@@ -1702,7 +1677,6 @@ drawbar(Monitor *m)
|
||||
m->m.y + (topbar ? 0 : m->m.height - m->b.real_height));
|
||||
wlr_scene_buffer_set_buffer(m->scene_buffer, &buf->base);
|
||||
wlr_buffer_unlock(&buf->base);
|
||||
pthread_mutex_unlock(&mutex);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -1847,174 +1821,6 @@ fullscreennotify(struct wl_listener *listener, void *data)
|
||||
setfullscreen(c, client_wants_fullscreen(c));
|
||||
}
|
||||
|
||||
void
|
||||
gtkactivate(GtkApplication *app, void *data)
|
||||
{
|
||||
GdkDisplay *display;
|
||||
GtkCssProvider *cssp;
|
||||
char csss[64];
|
||||
Monitor *m;
|
||||
uint32_t bgcolor;
|
||||
|
||||
bgcolor = colors[SchemeNorm][1] >> 8;
|
||||
display = gdk_display_get_default();
|
||||
cssp = gtk_css_provider_new();
|
||||
sprintf(csss, "window{background-color:#%06x;}", bgcolor);
|
||||
gtk_css_provider_load_from_string(cssp, csss);
|
||||
gtk_style_context_add_provider_for_display(display,
|
||||
GTK_STYLE_PROVIDER(cssp),
|
||||
GTK_STYLE_PROVIDER_PRIORITY_USER);
|
||||
|
||||
wl_list_for_each(m, &mons, link)
|
||||
gtkspawnstray(m, app);
|
||||
|
||||
g_object_unref(cssp);
|
||||
}
|
||||
|
||||
void
|
||||
gtkclosewindows(void *data, void *udata)
|
||||
{
|
||||
GtkWindow *window = GTK_WINDOW(data);
|
||||
|
||||
gtk_window_close(window);
|
||||
}
|
||||
|
||||
void
|
||||
gtkhandletogglebarmsg(void *data)
|
||||
{
|
||||
GtkApplication *app;
|
||||
GList *windows;
|
||||
|
||||
app = GTK_APPLICATION(g_application_get_default());
|
||||
windows = gtk_application_get_windows(app);
|
||||
g_list_foreach(windows, gtktoggletray, data);
|
||||
}
|
||||
|
||||
void
|
||||
gtkhandlewidthnotify(SnSystray *systray, GParamSpec *pspec, void *data)
|
||||
{
|
||||
Monitor *m = (Monitor *)data;
|
||||
int traywidth;
|
||||
|
||||
traywidth = sn_systray_get_width(systray);
|
||||
|
||||
updatebar(m, traywidth);
|
||||
drawbar(m);
|
||||
}
|
||||
|
||||
void*
|
||||
gtkinit(void *data)
|
||||
{
|
||||
GtkApplication *app = gtk_application_new("org.dwl.systray",
|
||||
G_APPLICATION_NON_UNIQUE);
|
||||
g_signal_connect(app, "activate", G_CALLBACK(gtkactivate), NULL);
|
||||
g_application_run(G_APPLICATION(app), 0, NULL);
|
||||
|
||||
g_object_unref(app);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
gtkspawnstray(Monitor *m, GtkApplication *app)
|
||||
{
|
||||
GdkMonitor *gdkmon;
|
||||
GtkWindow *window;
|
||||
SnSystray *systray;
|
||||
const char *conn;
|
||||
gboolean anchors[4];
|
||||
int iconsize, tray_init_width, tray_height;
|
||||
|
||||
gdkmon = gtkwlrtogdkmon(m);
|
||||
if (gdkmon == NULL)
|
||||
die("Failed to get gdkmon");
|
||||
|
||||
conn = gdk_monitor_get_connector(gdkmon);
|
||||
iconsize = m->b.real_height - 2 * traymargins;
|
||||
tray_height = m->b.real_height;
|
||||
tray_init_width = m->b.real_height;
|
||||
|
||||
if (topbar) {
|
||||
anchors[GTK_LAYER_SHELL_EDGE_LEFT] = false;
|
||||
anchors[GTK_LAYER_SHELL_EDGE_RIGHT] = true;
|
||||
anchors[GTK_LAYER_SHELL_EDGE_TOP] = true;
|
||||
anchors[GTK_LAYER_SHELL_EDGE_BOTTOM] = false;
|
||||
} else {
|
||||
anchors[GTK_LAYER_SHELL_EDGE_LEFT] = false;
|
||||
anchors[GTK_LAYER_SHELL_EDGE_RIGHT] = true;
|
||||
anchors[GTK_LAYER_SHELL_EDGE_TOP] = false;
|
||||
anchors[GTK_LAYER_SHELL_EDGE_BOTTOM] = true;
|
||||
}
|
||||
|
||||
systray = sn_systray_new(iconsize,
|
||||
traymargins,
|
||||
trayspacing,
|
||||
conn);
|
||||
window = GTK_WINDOW(gtk_window_new());
|
||||
|
||||
gtk_window_set_default_size(window, tray_init_width, tray_height);
|
||||
gtk_window_set_child(window, GTK_WIDGET(systray));
|
||||
gtk_window_set_application(window, app);
|
||||
gtk_layer_init_for_window(window);
|
||||
gtk_layer_set_layer(window, GTK_LAYER_SHELL_LAYER_BOTTOM);
|
||||
gtk_layer_set_exclusive_zone(window, -1);
|
||||
gtk_layer_set_monitor(window, gdkmon);
|
||||
|
||||
for (int j = 0; j < GTK_LAYER_SHELL_EDGE_ENTRY_NUMBER; j++) {
|
||||
gtk_layer_set_anchor(window, j, anchors[j]);
|
||||
}
|
||||
|
||||
updatebar(m, tray_init_width);
|
||||
g_signal_connect(systray, "notify::curwidth", G_CALLBACK(gtkhandlewidthnotify), m);
|
||||
gtk_window_present(window);
|
||||
}
|
||||
|
||||
void
|
||||
gtkterminate(void *data)
|
||||
{
|
||||
GtkApplication *app;
|
||||
GList *windows;
|
||||
|
||||
app = GTK_APPLICATION(g_application_get_default());
|
||||
windows = gtk_application_get_windows(app);
|
||||
g_list_foreach(windows, gtkclosewindows, NULL);
|
||||
}
|
||||
|
||||
GdkMonitor*
|
||||
gtkwlrtogdkmon(Monitor *wlrmon)
|
||||
{
|
||||
GdkMonitor *gdkmon = NULL;
|
||||
|
||||
GListModel *gdkmons;
|
||||
GdkDisplay *display;
|
||||
const char *gdkname;
|
||||
const char *wlrname;
|
||||
unsigned int i;
|
||||
|
||||
wlrname = wlrmon->wlr_output->name;
|
||||
display = gdk_display_get_default();
|
||||
gdkmons = gdk_display_get_monitors(display);
|
||||
|
||||
for (i = 0; i < g_list_model_get_n_items(gdkmons); i++) {
|
||||
GdkMonitor *mon = g_list_model_get_item(gdkmons, i);
|
||||
gdkname = gdk_monitor_get_connector(mon);
|
||||
if (strcmp(wlrname, gdkname) == 0)
|
||||
gdkmon = mon;
|
||||
}
|
||||
|
||||
return gdkmon;
|
||||
}
|
||||
|
||||
void
|
||||
gtktoggletray(void *data, void *udata)
|
||||
{
|
||||
GtkWidget *widget = GTK_WIDGET(data);
|
||||
int *pbarvisible = (int *)udata;
|
||||
int barvisible = GPOINTER_TO_INT(pbarvisible);
|
||||
|
||||
gtk_widget_set_visible(widget, barvisible);
|
||||
}
|
||||
|
||||
void
|
||||
gpureset(struct wl_listener *listener, void *data)
|
||||
{
|
||||
@@ -2386,6 +2192,40 @@ monocle(Monitor *m)
|
||||
wlr_scene_node_raise_to_top(&c->scene->node);
|
||||
}
|
||||
|
||||
void
|
||||
movestack(const Arg *arg)
|
||||
{
|
||||
Client *c, *sel = focustop(selmon);
|
||||
|
||||
if (!sel) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (wl_list_length(&clients) <= 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (arg->i > 0) {
|
||||
wl_list_for_each(c, &sel->link, link) {
|
||||
if (VISIBLEON(c, selmon) || &c->link == &clients) {
|
||||
break; /* found it */
|
||||
}
|
||||
}
|
||||
} else {
|
||||
wl_list_for_each_reverse(c, &sel->link, link) {
|
||||
if (VISIBLEON(c, selmon) || &c->link == &clients) {
|
||||
break; /* found it */
|
||||
}
|
||||
}
|
||||
/* backup one client */
|
||||
c = wl_container_of(c->link.prev, c, link);
|
||||
}
|
||||
|
||||
wl_list_remove(&sel->link);
|
||||
wl_list_insert(&c->link, &sel->link);
|
||||
arrange(selmon);
|
||||
}
|
||||
|
||||
void
|
||||
motionabsolute(struct wl_listener *listener, void *data)
|
||||
{
|
||||
@@ -2654,8 +2494,6 @@ powermgrsetmode(struct wl_listener *listener, void *data)
|
||||
void
|
||||
quit(const Arg *arg)
|
||||
{
|
||||
g_idle_add_once(gtkterminate, NULL);
|
||||
pthread_join(gtkthread, NULL);
|
||||
wl_display_terminate(dpy);
|
||||
}
|
||||
|
||||
@@ -3219,9 +3057,6 @@ setup(void)
|
||||
fprintf(stderr, "failed to setup XWayland X server, continuing without it\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
// Gtk functions are only allowed to be called from this thread.
|
||||
pthread_create(>kthread, NULL, >kinit, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -3332,21 +3167,9 @@ tile(Monitor *m)
|
||||
void
|
||||
togglebar(const Arg *arg)
|
||||
{
|
||||
int barvisible;
|
||||
int *pbarvisible;
|
||||
|
||||
wlr_scene_node_set_enabled(&selmon->scene_buffer->node,
|
||||
!selmon->scene_buffer->node.enabled);
|
||||
arrangelayers(selmon);
|
||||
|
||||
// Notify gtkthread
|
||||
if (selmon->scene_buffer->node.enabled)
|
||||
barvisible = 1;
|
||||
else
|
||||
barvisible = 0;
|
||||
|
||||
pbarvisible = GINT_TO_POINTER(barvisible);
|
||||
g_idle_add_once(gtkhandletogglebarmsg, pbarvisible);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -3588,7 +3411,7 @@ updatemons(struct wl_listener *listener, void *data)
|
||||
if (stext[0] == '\0')
|
||||
strncpy(stext, "dwl-"VERSION, sizeof(stext));
|
||||
wl_list_for_each(m, &mons, link) {
|
||||
updatebar(m, 0);
|
||||
updatebar(m);
|
||||
drawbar(m);
|
||||
}
|
||||
|
||||
@@ -3603,7 +3426,7 @@ updatemons(struct wl_listener *listener, void *data)
|
||||
}
|
||||
|
||||
void
|
||||
updatebar(Monitor *m, int traywidth)
|
||||
updatebar(Monitor *m)
|
||||
{
|
||||
size_t i;
|
||||
int rw, rh;
|
||||
@@ -3611,7 +3434,7 @@ updatebar(Monitor *m, int traywidth)
|
||||
|
||||
wlr_output_transformed_resolution(m->wlr_output, &rw, &rh);
|
||||
m->b.width = rw;
|
||||
m->b.real_width = (int)((float)m->b.width / m->wlr_output->scale) - traywidth;
|
||||
m->b.real_width = (int)((float)m->b.width / m->wlr_output->scale);
|
||||
|
||||
wlr_scene_node_set_enabled(&m->scene_buffer->node, m->wlr_output->enabled ? showbar : 0);
|
||||
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
*.h
|
||||
@@ -1 +0,0 @@
|
||||
*.a
|
||||
Reference in New Issue
Block a user