mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2024-12-29 12:15:59 +01:00
Listen on configure event for PPI changes
This allows detection of a PPI change due to the window moving to another monitor
This commit is contained in:
parent
8e3f056121
commit
063b234a2a
4 changed files with 37 additions and 5 deletions
|
@ -256,6 +256,17 @@ cb_widget_screen_changed(GtkWidget* widget, GdkScreen* previous_screen, gpointer
|
|||
zathura_update_view_ppi(zathura);
|
||||
}
|
||||
|
||||
void
|
||||
cb_widget_configured(GtkWidget* UNUSED(widget), GdkEvent* UNUSED(event), gpointer data)
|
||||
{
|
||||
zathura_t* zathura = data;
|
||||
if (zathura == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
zathura_update_view_ppi(zathura);
|
||||
}
|
||||
|
||||
void
|
||||
cb_scale_factor(GObject* object, GParamSpec* UNUSED(pspec), gpointer data)
|
||||
{
|
||||
|
|
|
@ -83,7 +83,8 @@ void cb_refresh_view(GtkWidget* view, gpointer data);
|
|||
* This function gets called when the monitors associated with the GdkScreen
|
||||
* change.
|
||||
*
|
||||
* It udpates the stored value for the monitor PPI.
|
||||
* It checks for a change of monitor PPI, storing the new value and triggering
|
||||
* a refresh if appropriate.
|
||||
*
|
||||
* @param screen The GDK screen
|
||||
* @param gpointer The zathura instance
|
||||
|
@ -94,8 +95,9 @@ void cb_monitors_changed(GdkScreen* screen, gpointer data);
|
|||
* This function gets called when the screen associated with the view widget
|
||||
* changes.
|
||||
*
|
||||
* It udpates updates the connection on the monitors-changed ignal and the
|
||||
* stored value for the monitor PPI.
|
||||
* It updates the connection on the monitors-changed signal and checks for a
|
||||
* change of monitor PPI, storing the new value and triggering a refresh if
|
||||
* appropriate.
|
||||
*
|
||||
* @param widget The view widget
|
||||
* @param previous_screen The widget's previous screen
|
||||
|
@ -103,6 +105,20 @@ void cb_monitors_changed(GdkScreen* screen, gpointer data);
|
|||
*/
|
||||
void cb_widget_screen_changed(GtkWidget* widget, GdkScreen* previous_screen, gpointer data);
|
||||
|
||||
/**
|
||||
* This function gets called when the main window's size, position or stacking
|
||||
* changes.
|
||||
*
|
||||
* It checks for a change of monitor PPI (due to the window moving between
|
||||
* different monitors), storing the new value and triggering a refresh if
|
||||
* appropriate.
|
||||
*
|
||||
* @param widget The main window widget
|
||||
* @param event The configure event
|
||||
* @param gpointer The zathura instance
|
||||
*/
|
||||
void cb_widget_configured(GtkWidget* widget, GdkEvent* event, gpointer data);
|
||||
|
||||
/**
|
||||
* This function gets called when the view widget scale factor changes (e.g.
|
||||
* when moving from a regular to a HiDPI screen).
|
||||
|
|
|
@ -868,10 +868,12 @@ render_all(zathura_t* zathura)
|
|||
|
||||
girara_debug("Queuing resize for page %u to %u x %u (%f x %f).", page_id, page_width, page_height, width, height);
|
||||
GtkWidget* widget = zathura_page_get_widget(zathura, page);
|
||||
if (widget != NULL) {
|
||||
gtk_widget_set_size_request(widget, page_width, page_height);
|
||||
gtk_widget_queue_resize(widget);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static gint
|
||||
render_thread_sort(gconstpointer a, gconstpointer b, gpointer UNUSED(data))
|
||||
|
|
|
@ -226,6 +226,9 @@ init_ui(zathura_t* zathura)
|
|||
g_signal_connect(G_OBJECT(zathura->ui.session->gtk.view),
|
||||
"screen-changed", G_CALLBACK(cb_widget_screen_changed), zathura);
|
||||
|
||||
g_signal_connect(G_OBJECT(zathura->ui.session->gtk.window),
|
||||
"configure-event", G_CALLBACK(cb_widget_configured), zathura);
|
||||
|
||||
/* initialize the screen-changed handler to 0 (i.e. invalid) */
|
||||
zathura->signals.monitors_changed_handler = 0;
|
||||
|
||||
|
|
Loading…
Reference in a new issue