diff --git a/callbacks.c b/callbacks.c index 3452466..9a4b2a1 100644 --- a/callbacks.c +++ b/callbacks.c @@ -290,14 +290,22 @@ error_ret: } bool -cb_view_resized(GtkWidget* UNUSED(widget), GtkAllocation* UNUSED(allocation), zathura_t* zathura) +cb_view_resized(GtkWidget* UNUSED(widget), GtkAllocation* allocation, zathura_t* zathura) { if (zathura == NULL || zathura->document == NULL) { return false; } - girara_argument_t argument = { zathura->document->adjust_mode, NULL }; - sc_adjust_window(zathura->ui.session, &argument, NULL, 0); + static int height = -1; + static int width = -1; - return true; + /* adjust only if the allocation changed */ + if (width != allocation->width || height != allocation->height) { + girara_argument_t argument = { zathura->document->adjust_mode, NULL }; + sc_adjust_window(zathura->ui.session, &argument, NULL, 0); + width = allocation->width; + height = allocation->height; + } + + return false; } diff --git a/document.c b/document.c index e182087..240b6e2 100644 --- a/document.c +++ b/document.c @@ -354,6 +354,8 @@ zathura_document_open(zathura_t* zathura, const char* path, const char* password document->adjust_mode = ADJUST_BESTFIT; } else if (g_strcmp0(adjust_open, "width") == 0) { document->adjust_mode = ADJUST_WIDTH; + } else { + document->adjust_mode = ADJUST_NONE; } g_free(adjust_open); } diff --git a/shortcuts.c b/shortcuts.c index da5d386..9a345f3 100644 --- a/shortcuts.c +++ b/shortcuts.c @@ -57,6 +57,10 @@ sc_adjust_window(girara_session_t* session, girara_argument_t* argument, } zathura->document->adjust_mode = argument->n; + if (argument->n == ADJUST_NONE) { + /* there is nothing todo */ + goto error_ret; + } /* get window size */ GtkAllocation allocation; diff --git a/zathura.c b/zathura.c index 67f7233..b452dfd 100644 --- a/zathura.c +++ b/zathura.c @@ -40,15 +40,15 @@ zathura_init(int argc, char* argv[]) /* parse command line options */ #if (GTK_MAJOR_VERSION == 2) GdkNativeWindow embed = 0; +#else + Window embed = 0; #endif gchar* config_dir = NULL, *data_dir = NULL, *plugin_path = NULL; bool forkback = false; GOptionEntry entries[] = { -#if (GTK_MAJOR_VERSION == 2) { "reparent", 'e', 0, G_OPTION_ARG_INT, &embed, "Reparents to window specified by xid", "xid" }, -#endif { "config-dir", 'c', 0, G_OPTION_ARG_FILENAME, &config_dir, "Path to the config directory", "path" }, { "data-dir", 'd', 0, G_OPTION_ARG_FILENAME, &data_dir, "Path to the data directory", "path" }, { "plugins-dir", 'p', 0, G_OPTION_ARG_STRING, &plugin_path, "Path to the directories containing plugins", "path" }, @@ -167,9 +167,7 @@ zathura_init(int argc, char* argv[]) g_free(configuration_file); /* initialize girara */ -#if (GTK_MAJOR_VERSION == 2) zathura->ui.session->gtk.embed = embed; -#endif if (girara_session_init(zathura->ui.session, "zathura") == false) { goto error_out; @@ -184,7 +182,7 @@ zathura_init(int argc, char* argv[]) goto error_free; } - g_signal_connect(G_OBJECT(zathura->ui.session->gtk.view), "size-allocate", G_CALLBACK(cb_view_resized), zathura); + g_signal_connect(G_OBJECT(zathura->ui.session->gtk.window), "size-allocate", G_CALLBACK(cb_view_resized), zathura); /* callbacks */ GtkAdjustment* view_vadjustment = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(zathura->ui.session->gtk.view));