~kennylevinsen/greetd-devel

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch

[PATCH] Title windows with the monitor plug name.

Details
Message ID
<20240303185023.59717-1-jamesdsparling@gmail.com>
DKIM signature
pass
Download raw message
Patch: +18 -0
---
Small patch that allows different CSS styling to be applied to each
monitor on a multi-head system. e.g:

window#DP-1 { background-image: url("image.tiff"); }
window#DP-2 { background-image: url("image2.tiff"); }

Code taken from jovanlanik/gtklock on Github

(This is my first time using the email-patch workflow, aplologies if it
is formatted incorrectly)

 gtkgreet/window.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/gtkgreet/window.c b/gtkgreet/window.c
index dcde118..656fb82 100644
--- a/gtkgreet/window.c
+++ b/gtkgreet/window.c
@@ -301,6 +301,8 @@ static gboolean window_background(GtkWidget *widget, cairo_t *cr, gpointer data)
    return FALSE;
}

#pragma GCC diagnostic ignored "-Wdeprecated-declarations"

struct Window *create_window(GdkMonitor *monitor) {
    struct Window *w = calloc(1, sizeof(struct Window));
    if (w == NULL) {
@@ -312,6 +314,22 @@ struct Window *create_window(GdkMonitor *monitor) {

    w->window = gtk_application_window_new(gtkgreet->app);
    g_signal_connect(w->window, "destroy", G_CALLBACK(window_destroy_notify), NULL);

    /*
		This code uses a deprecated function and assumes one GDK screen...
		However there isn't really a good way to do this in GTK3 currently.
		Related issue: https://gitlab.gnome.org/GNOME/gtk/-/issues/4982
    */
    char *name = NULL;
    GdkDisplay *display = gtk_widget_get_display(w->window);
    GdkScreen *screen = gtk_widget_get_screen(w->window);
    for(int i = 0; i < gdk_display_get_n_monitors(display); i++) {
      GdkMonitor *monitor = gdk_display_get_monitor(display, i);
      if(monitor != w->monitor) continue;
      name = gdk_screen_get_monitor_plug_name(screen, i);
    }

    if (name) gtk_widget_set_name(w->window, name);
    gtk_window_set_title(GTK_WINDOW(w->window), "Greeter");
    gtk_window_set_default_size(GTK_WINDOW(w->window), 200, 200);

-- 
2.44.0
Reply to thread Export thread (mbox)