From 2b8350ecebec5cca5edd25951bdb3f0c0b8ee4b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C5=99emysl=20Eric=20Janouch?= Date: Sat, 20 Nov 2021 13:03:30 +0100 Subject: [PATCH] Fix some issues with browser/view switching --- fastiv-view.c | 13 +++++++------ fastiv.c | 17 +++++++---------- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/fastiv-view.c b/fastiv-view.c index 602e4e5..35b19fa 100644 --- a/fastiv-view.c +++ b/fastiv-view.c @@ -198,7 +198,6 @@ fastiv_view_realize(GtkWidget *widget) #ifdef GDK_WINDOWING_X11 // FIXME: This causes some flicker while scrolling, because it disables // double buffering, see: https://gitlab.gnome.org/GNOME/gtk/-/issues/2560 - // FIXME: It also breaks Tab-switching at the start of program. // // If GTK+'s OpenGL integration fails to deliver, we need to use the window // directly, sidestepping the toolkit entirely. @@ -214,16 +213,18 @@ fastiv_view_realize(GtkWidget *widget) static gboolean fastiv_view_draw(GtkWidget *widget, cairo_t *cr) { - FastivView *self = FASTIV_VIEW(widget); - if (!self->surface || - !gtk_cairo_should_draw_window(cr, gtk_widget_get_window(widget))) - return TRUE; - + // Placed here due to our using a native GdkWindow on X11, + // which makes the widget have no double buffering or default background. GtkAllocation allocation; gtk_widget_get_allocation(widget, &allocation); gtk_render_background(gtk_widget_get_style_context(widget), cr, 0, 0, allocation.width, allocation.height); + FastivView *self = FASTIV_VIEW(widget); + if (!self->surface || + !gtk_cairo_should_draw_window(cr, gtk_widget_get_window(widget))) + return TRUE; + int w, h; get_display_dimensions(self, &w, &h); diff --git a/fastiv.c b/fastiv.c index f37e9f8..7524021 100644 --- a/fastiv.c +++ b/fastiv.c @@ -146,6 +146,10 @@ load_directory(const gchar *dirname) // XXX: When something outside the filtered entries is open, the index is // kept at -1, and browsing doesn't work. How to behave here? // Should we add it to the pointer array as an exception? + if (dirname) { + gtk_stack_set_visible_child(GTK_STACK(g.stack), g.browser_paned); + gtk_widget_grab_focus(g.browser_scroller); + } } static void @@ -168,9 +172,6 @@ open(const gchar *path) g_free(uri); } - gtk_window_set_title(GTK_WINDOW(g.window), path); - gtk_stack_set_visible_child(GTK_STACK(g.stack), g.view_scroller); - gchar *basename = g_path_get_basename(path); g_free(g.basename); g.basename = basename; @@ -187,6 +188,9 @@ open(const gchar *path) } } g_free(dirname); + + gtk_window_set_title(GTK_WINDOW(g.window), path); + gtk_stack_set_visible_child(GTK_STACK(g.stack), g.view_scroller); } static GtkWidget * @@ -298,14 +302,7 @@ open_any_path(const char *path) load_directory(canonical); else open(canonical); - g_free(canonical); - if (g.files_index < 0) { - gtk_stack_set_visible_child(GTK_STACK(g.stack), g.browser_paned); - gtk_widget_grab_focus(g.browser_scroller); - } else { - gtk_stack_set_visible_child(GTK_STACK(g.stack), g.view_scroller); - } return success; }