Fix some issues with browser/view switching

This commit is contained in:
Přemysl Eric Janouch 2021-11-20 13:03:30 +01:00
parent 75994cd85a
commit 2b8350eceb
Signed by: p
GPG Key ID: A0420B94F92B9493
2 changed files with 14 additions and 16 deletions

View File

@ -198,7 +198,6 @@ fastiv_view_realize(GtkWidget *widget)
#ifdef GDK_WINDOWING_X11 #ifdef GDK_WINDOWING_X11
// FIXME: This causes some flicker while scrolling, because it disables // FIXME: This causes some flicker while scrolling, because it disables
// double buffering, see: https://gitlab.gnome.org/GNOME/gtk/-/issues/2560 // 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 // If GTK+'s OpenGL integration fails to deliver, we need to use the window
// directly, sidestepping the toolkit entirely. // directly, sidestepping the toolkit entirely.
@ -214,16 +213,18 @@ fastiv_view_realize(GtkWidget *widget)
static gboolean static gboolean
fastiv_view_draw(GtkWidget *widget, cairo_t *cr) fastiv_view_draw(GtkWidget *widget, cairo_t *cr)
{ {
FastivView *self = FASTIV_VIEW(widget); // Placed here due to our using a native GdkWindow on X11,
if (!self->surface || // which makes the widget have no double buffering or default background.
!gtk_cairo_should_draw_window(cr, gtk_widget_get_window(widget)))
return TRUE;
GtkAllocation allocation; GtkAllocation allocation;
gtk_widget_get_allocation(widget, &allocation); gtk_widget_get_allocation(widget, &allocation);
gtk_render_background(gtk_widget_get_style_context(widget), cr, 0, 0, gtk_render_background(gtk_widget_get_style_context(widget), cr, 0, 0,
allocation.width, allocation.height); 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; int w, h;
get_display_dimensions(self, &w, &h); get_display_dimensions(self, &w, &h);

View File

@ -146,6 +146,10 @@ load_directory(const gchar *dirname)
// XXX: When something outside the filtered entries is open, the index is // XXX: When something outside the filtered entries is open, the index is
// kept at -1, and browsing doesn't work. How to behave here? // kept at -1, and browsing doesn't work. How to behave here?
// Should we add it to the pointer array as an exception? // 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 static void
@ -168,9 +172,6 @@ open(const gchar *path)
g_free(uri); 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); gchar *basename = g_path_get_basename(path);
g_free(g.basename); g_free(g.basename);
g.basename = basename; g.basename = basename;
@ -187,6 +188,9 @@ open(const gchar *path)
} }
} }
g_free(dirname); 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 * static GtkWidget *
@ -298,14 +302,7 @@ open_any_path(const char *path)
load_directory(canonical); load_directory(canonical);
else else
open(canonical); open(canonical);
g_free(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; return success;
} }