Skip to content

Commit

Permalink
Fix positioning when started on secondary monitor
Browse files Browse the repository at this point in the history
Previously, we were treating the desktop as an uninterrupted uniform
plane, and optimistically assuming that GTK will always stick our window
at absolute coordinates 0,0 when we create a window.

This assumption does not match reality: by default, GTK positions new
windows in the top-left corner of the currently active physical monitor.
This caused the overlay window to be misplaced when hudkit was started
on a monitor other than the top-left-most one.

Fixes #2
  • Loading branch information
anko committed Jul 15, 2020
1 parent af83357 commit b92f16b
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion main.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ int main(int argc, char **argv) {

// Create the window, set basic properties
GtkWidget *window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
gtk_window_set_gravity(GTK_WINDOW(window), GDK_GRAVITY_NORTH_WEST);
gtk_window_move(GTK_WINDOW(window), 0, 0);

gtk_window_set_title(GTK_WINDOW(window), "hudkit overlay window");
g_signal_connect(G_OBJECT(window), "delete-event", gtk_main_quit, NULL);
gtk_widget_set_app_paintable(window, TRUE);
Expand Down

0 comments on commit b92f16b

Please sign in to comment.