mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2025-02-27 14:34:39 +01:00
only call sc_adjust_window if the allocation of the window really changed
This commit is contained in:
parent
2f38126a7a
commit
e7f0e30d99
4 changed files with 21 additions and 9 deletions
16
callbacks.c
16
callbacks.c
|
@ -290,14 +290,22 @@ error_ret:
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
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) {
|
if (zathura == NULL || zathura->document == NULL) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
girara_argument_t argument = { zathura->document->adjust_mode, NULL };
|
static int height = -1;
|
||||||
sc_adjust_window(zathura->ui.session, &argument, NULL, 0);
|
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;
|
document->adjust_mode = ADJUST_BESTFIT;
|
||||||
} else if (g_strcmp0(adjust_open, "width") == 0) {
|
} else if (g_strcmp0(adjust_open, "width") == 0) {
|
||||||
document->adjust_mode = ADJUST_WIDTH;
|
document->adjust_mode = ADJUST_WIDTH;
|
||||||
|
} else {
|
||||||
|
document->adjust_mode = ADJUST_NONE;
|
||||||
}
|
}
|
||||||
g_free(adjust_open);
|
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;
|
zathura->document->adjust_mode = argument->n;
|
||||||
|
if (argument->n == ADJUST_NONE) {
|
||||||
|
/* there is nothing todo */
|
||||||
|
goto error_ret;
|
||||||
|
}
|
||||||
|
|
||||||
/* get window size */
|
/* get window size */
|
||||||
GtkAllocation allocation;
|
GtkAllocation allocation;
|
||||||
|
|
|
@ -40,15 +40,15 @@ zathura_init(int argc, char* argv[])
|
||||||
/* parse command line options */
|
/* parse command line options */
|
||||||
#if (GTK_MAJOR_VERSION == 2)
|
#if (GTK_MAJOR_VERSION == 2)
|
||||||
GdkNativeWindow embed = 0;
|
GdkNativeWindow embed = 0;
|
||||||
|
#else
|
||||||
|
Window embed = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
gchar* config_dir = NULL, *data_dir = NULL, *plugin_path = NULL;
|
gchar* config_dir = NULL, *data_dir = NULL, *plugin_path = NULL;
|
||||||
bool forkback = false;
|
bool forkback = false;
|
||||||
GOptionEntry entries[] =
|
GOptionEntry entries[] =
|
||||||
{
|
{
|
||||||
#if (GTK_MAJOR_VERSION == 2)
|
|
||||||
{ "reparent", 'e', 0, G_OPTION_ARG_INT, &embed, "Reparents to window specified by xid", "xid" },
|
{ "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" },
|
{ "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" },
|
{ "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" },
|
{ "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);
|
g_free(configuration_file);
|
||||||
|
|
||||||
/* initialize girara */
|
/* initialize girara */
|
||||||
#if (GTK_MAJOR_VERSION == 2)
|
|
||||||
zathura->ui.session->gtk.embed = embed;
|
zathura->ui.session->gtk.embed = embed;
|
||||||
#endif
|
|
||||||
|
|
||||||
if (girara_session_init(zathura->ui.session, "zathura") == false) {
|
if (girara_session_init(zathura->ui.session, "zathura") == false) {
|
||||||
goto error_out;
|
goto error_out;
|
||||||
|
@ -184,7 +182,7 @@ zathura_init(int argc, char* argv[])
|
||||||
goto error_free;
|
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 */
|
/* callbacks */
|
||||||
GtkAdjustment* view_vadjustment = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(zathura->ui.session->gtk.view));
|
GtkAdjustment* view_vadjustment = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(zathura->ui.session->gtk.view));
|
||||||
|
|
Loading…
Add table
Reference in a new issue