Skip to content

Instantly share code, notes, and snippets.

@udiboy1209
Created October 2, 2019 07:34
Show Gist options
  • Save udiboy1209/9e3ab41723cfec6785bd2a679d8b08ec to your computer and use it in GitHub Desktop.
Save udiboy1209/9e3ab41723cfec6785bd2a679d8b08ec to your computer and use it in GitHub Desktop.
Relative position patch for lightdm-mini-greeter
diff --unified --recursive --color lightdm-mini-greeter-0.3.4/data/lightdm-mini-greeter.conf lightdm-mini-greeter-0.3.4-new/data/lightdm-mini-greeter.conf
--- lightdm-mini-greeter-0.3.4/data/lightdm-mini-greeter.conf 2018-11-02 19:32:27.000000000 +0530
+++ lightdm-mini-greeter-0.3.4-new/data/lightdm-mini-greeter.conf 2019-09-15 23:52:02.692974802 +0530
@@ -56,3 +56,7 @@
password-color = "#F8F8F0"
# The background color of the password input.
password-background-color = "#1B1D1E"
+
+# Relative position of window on screen (0-1 float)
+x-pos = 0.5
+y-pos = 0.5
diff --unified --recursive --color lightdm-mini-greeter-0.3.4/src/config.c lightdm-mini-greeter-0.3.4-new/src/config.c
--- lightdm-mini-greeter-0.3.4/src/config.c 2018-11-02 19:32:27.000000000 +0530
+++ lightdm-mini-greeter-0.3.4-new/src/config.c 2019-09-15 23:52:02.696308136 +0530
@@ -96,6 +96,10 @@
config->layout_spacing = (guint) layout_spacing;
}
+ config->x_pos = g_key_file_get_double(
+ keyfile, "greeter-theme", "x-pos", NULL);
+ config->y_pos = g_key_file_get_double(
+ keyfile, "greeter-theme", "y-pos", NULL);
g_key_file_free(keyfile);
diff --unified --recursive --color lightdm-mini-greeter-0.3.4/src/config.h lightdm-mini-greeter-0.3.4-new/src/config.h
--- lightdm-mini-greeter-0.3.4/src/config.h 2018-11-02 19:32:27.000000000 +0530
+++ lightdm-mini-greeter-0.3.4-new/src/config.h 2019-09-15 23:52:02.696308136 +0530
@@ -38,6 +38,10 @@
guint restart_key;
guint hibernate_key;
guint suspend_key;
+
+ // Window position
+ gdouble x_pos;
+ gdouble y_pos;
} Config;
diff --unified --recursive --color lightdm-mini-greeter-0.3.4/src/ui.c lightdm-mini-greeter-0.3.4-new/src/ui.c
--- lightdm-mini-greeter-0.3.4/src/ui.c 2018-11-02 19:32:27.000000000 +0530
+++ lightdm-mini-greeter-0.3.4-new/src/ui.c 2019-09-15 23:52:02.696308136 +0530
@@ -129,7 +129,7 @@
gtk_container_set_border_width(GTK_CONTAINER(main_window), config->layout_spacing);
gtk_widget_set_name(GTK_WIDGET(main_window), "main");
- g_signal_connect(main_window, "show", G_CALLBACK(place_main_window), NULL);
+ g_signal_connect(main_window, "show", G_CALLBACK(place_main_window), config);
g_signal_connect(main_window, "destroy", G_CALLBACK(gtk_main_quit), NULL);
ui->main_window = main_window;
@@ -154,10 +154,13 @@
gint window_width, window_height;
gtk_window_get_size(GTK_WINDOW(main_window), &window_width, &window_height);
+ Config *config = (Config *) user_data;
+ gint xpos = (gint) (primary_monitor_geometry.width * config->x_pos);
+ gint ypos = (gint) (primary_monitor_geometry.height * config->y_pos);
gtk_window_move(
GTK_WINDOW(main_window),
- primary_monitor_geometry.x + primary_monitor_geometry.width / 2 - window_width / 2,
- primary_monitor_geometry.y + primary_monitor_geometry.height / 2 - window_height / 2);
+ primary_monitor_geometry.x + xpos - window_width / 2,
+ primary_monitor_geometry.y + ypos - window_height / 2);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment