1
0
mirror of https://github.com/artizirk/wdisplays.git synced 2024-11-25 01:40:59 +02:00

Show headerbar when window is fullscreen

Fixes #14
This commit is contained in:
Jason Francis 2020-03-14 21:49:46 -04:00
parent ba331cab53
commit e66756e2c4
3 changed files with 24 additions and 1 deletions

View File

@ -76,7 +76,7 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkBox">
<object class="GtkBox" id="main_box">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>

View File

@ -1231,6 +1231,25 @@ static void overlay_selected(GSimpleAction *action, GVariant *param, gpointer da
}
}
static void window_state_changed(GtkWidget *window, GdkEventWindowState *event,
gpointer data) {
struct wd_state *state = data;
if (event->changed_mask & GDK_WINDOW_STATE_FULLSCREEN) {
g_object_ref(state->header_stack);
GtkWidget *container = gtk_widget_get_parent(state->header_stack);
gtk_container_remove(GTK_CONTAINER(container), state->header_stack);
if (event->new_window_state & GDK_WINDOW_STATE_FULLSCREEN) {
gtk_container_add(GTK_CONTAINER(state->main_box), state->header_stack);
gtk_box_reorder_child(GTK_BOX(state->main_box), state->header_stack, 0);
} else {
gtk_widget_unrealize(window);
gtk_window_set_titlebar(GTK_WINDOW(window), state->header_stack);
gtk_widget_map(window);
}
g_object_unref(state->header_stack);
}
}
static void activate(GtkApplication* app, gpointer user_data) {
GdkDisplay *gdk_display = gdk_display_get_default();
if (!GDK_IS_WAYLAND_DISPLAY(gdk_display)) {
@ -1254,6 +1273,7 @@ static void activate(GtkApplication* app, gpointer user_data) {
GtkBuilder *builder = gtk_builder_new_from_resource("/wdisplays.ui");
GtkWidget *window = GTK_WIDGET(gtk_builder_get_object(builder, "heads_window"));
state->main_box = GTK_WIDGET(gtk_builder_get_object(builder, "main_box"));
state->header_stack = GTK_WIDGET(gtk_builder_get_object(builder, "header_stack"));
state->stack_switcher = GTK_WIDGET(gtk_builder_get_object(builder, "heads_stack_switcher"));
state->stack = GTK_WIDGET(gtk_builder_get_object(builder, "heads_stack"));
@ -1277,6 +1297,8 @@ static void activate(GtkApplication* app, gpointer user_data) {
gtk_builder_connect_signals(builder, state);
gtk_box_set_homogeneous(GTK_BOX(gtk_builder_get_object(builder, "zoom_box")), FALSE);
g_signal_connect(window, "window-state-event", G_CALLBACK(window_state_changed), state);
state->canvas = wd_gl_viewport_new();
gtk_container_add(GTK_CONTAINER(state->scroller), state->canvas);
gtk_widget_add_events(state->canvas, GDK_POINTER_MOTION_MASK

View File

@ -209,6 +209,7 @@ struct wd_state {
bool panning;
struct wd_point pan_last;
GtkWidget *main_box;
GtkWidget *header_stack;
GtkWidget *stack_switcher;
GtkWidget *stack;