mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2025-01-01 09:16:00 +01:00
Store monitors-changed handler for disconnection
This commit is contained in:
parent
8b93be9471
commit
af90d4050d
3 changed files with 14 additions and 7 deletions
|
@ -230,24 +230,26 @@ cb_monitors_changed(GdkScreen* screen, gpointer data)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cb_widget_screen_changed(GtkWidget* widget, GdkScreen* UNUSED(previous_screen), gpointer data)
|
cb_widget_screen_changed(GtkWidget* widget, GdkScreen* previous_screen, gpointer data)
|
||||||
{
|
{
|
||||||
girara_debug("signal received");
|
girara_debug("called");
|
||||||
|
|
||||||
zathura_t* zathura = data;
|
zathura_t* zathura = data;
|
||||||
if (widget == NULL || zathura == NULL) {
|
if (widget == NULL || zathura == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* disconnect previous screen handler if present */
|
||||||
|
if (previous_screen != NULL && zathura->signals.monitors_changed_handler > 0) {
|
||||||
|
g_signal_handler_disconnect(previous_screen, zathura->signals.monitors_changed_handler);
|
||||||
|
zathura->signals.monitors_changed_handler = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (gtk_widget_has_screen(widget)) {
|
if (gtk_widget_has_screen(widget)) {
|
||||||
GdkScreen* screen = gtk_widget_get_screen(widget);
|
GdkScreen* screen = gtk_widget_get_screen(widget);
|
||||||
|
|
||||||
/* disconnect signal on previous screen */
|
|
||||||
g_signal_handlers_disconnect_matched(screen, G_SIGNAL_MATCH_FUNC, 0, 0,
|
|
||||||
NULL, (gpointer) cb_monitors_changed, zathura);
|
|
||||||
|
|
||||||
/* connect to new screen */
|
/* connect to new screen */
|
||||||
g_signal_connect(G_OBJECT(screen),
|
zathura->signals.monitors_changed_handler = g_signal_connect(G_OBJECT(screen),
|
||||||
"monitors-changed", G_CALLBACK(cb_monitors_changed), zathura);
|
"monitors-changed", G_CALLBACK(cb_monitors_changed), zathura);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -222,6 +222,9 @@ init_ui(zathura_t* zathura)
|
||||||
g_signal_connect(G_OBJECT(zathura->ui.session->gtk.view),
|
g_signal_connect(G_OBJECT(zathura->ui.session->gtk.view),
|
||||||
"screen-changed", G_CALLBACK(cb_widget_screen_changed), zathura);
|
"screen-changed", G_CALLBACK(cb_widget_screen_changed), zathura);
|
||||||
|
|
||||||
|
/* initialize the screen-changed handler to 0 (i.e. invalid) */
|
||||||
|
zathura->signals.monitors_changed_handler = 0;
|
||||||
|
|
||||||
/* page view */
|
/* page view */
|
||||||
zathura->ui.page_widget = gtk_grid_new();
|
zathura->ui.page_widget = gtk_grid_new();
|
||||||
gtk_grid_set_row_homogeneous(GTK_GRID(zathura->ui.page_widget), TRUE);
|
gtk_grid_set_row_homogeneous(GTK_GRID(zathura->ui.page_widget), TRUE);
|
||||||
|
|
|
@ -163,6 +163,8 @@ struct zathura_s
|
||||||
#ifdef G_OS_UNIX
|
#ifdef G_OS_UNIX
|
||||||
guint sigterm;
|
guint sigterm;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
gulong monitors_changed_handler; /**< Signal handler for monitors-changed */
|
||||||
} signals;
|
} signals;
|
||||||
|
|
||||||
struct
|
struct
|
||||||
|
|
Loading…
Reference in a new issue