Commit e7f0e30d authored by Sebastian Ramacher's avatar Sebastian Ramacher
Browse files

only call sc_adjust_window if the allocation of the window really changed

parent 2f38126a
......@@ -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;
}
......@@ -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);
}
......
......@@ -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;
......
......@@ -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));
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment