mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2025-01-16 21:47:51 +01:00
Fix sc_adjust_window
This commit is contained in:
parent
4868bcec55
commit
cbb22739e5
1 changed files with 11 additions and 4 deletions
15
shortcuts.c
15
shortcuts.c
|
@ -76,8 +76,8 @@ sc_adjust_window(girara_session_t* session, girara_argument_t* argument,
|
||||||
/* get window size */
|
/* get window size */
|
||||||
GtkAllocation allocation;
|
GtkAllocation allocation;
|
||||||
gtk_widget_get_allocation(session->gtk.view, &allocation);
|
gtk_widget_get_allocation(session->gtk.view, &allocation);
|
||||||
gint width = allocation.width;
|
double width = allocation.width;
|
||||||
gint height = allocation.height;
|
double height = allocation.height;
|
||||||
|
|
||||||
/* correct view size */
|
/* correct view size */
|
||||||
if (gtk_widget_get_visible(GTK_WIDGET(session->gtk.inputbar)) == true) {
|
if (gtk_widget_get_visible(GTK_WIDGET(session->gtk.inputbar)) == true) {
|
||||||
|
@ -119,6 +119,13 @@ sc_adjust_window(girara_session_t* session, girara_argument_t* argument,
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int rotation = zathura_document_get_rotation(zathura->document);
|
unsigned int rotation = zathura_document_get_rotation(zathura->document);
|
||||||
|
double page_ratio = total_height / total_width;
|
||||||
|
double window_ratio = height / width;
|
||||||
|
|
||||||
|
if (rotation == 90 || rotation == 270) {
|
||||||
|
page_ratio = total_width / total_height;
|
||||||
|
}
|
||||||
|
|
||||||
switch (argument->n) {
|
switch (argument->n) {
|
||||||
case ZATHURA_ADJUST_WIDTH:
|
case ZATHURA_ADJUST_WIDTH:
|
||||||
if (rotation == 0 || rotation == 180) {
|
if (rotation == 0 || rotation == 180) {
|
||||||
|
@ -129,13 +136,13 @@ sc_adjust_window(girara_session_t* session, girara_argument_t* argument,
|
||||||
break;
|
break;
|
||||||
case ZATHURA_ADJUST_BESTFIT:
|
case ZATHURA_ADJUST_BESTFIT:
|
||||||
if (rotation == 0 || rotation == 180) {
|
if (rotation == 0 || rotation == 180) {
|
||||||
if (width < height) {
|
if (page_ratio < window_ratio) {
|
||||||
zathura_document_set_scale(zathura->document, width / total_width);
|
zathura_document_set_scale(zathura->document, width / total_width);
|
||||||
} else {
|
} else {
|
||||||
zathura_document_set_scale(zathura->document, height / total_height);
|
zathura_document_set_scale(zathura->document, height / total_height);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (width < height) {
|
if (page_ratio < window_ratio) {
|
||||||
zathura_document_set_scale(zathura->document, width / total_height);
|
zathura_document_set_scale(zathura->document, width / total_height);
|
||||||
} else {
|
} else {
|
||||||
zathura_document_set_scale(zathura->document, height / total_width);
|
zathura_document_set_scale(zathura->document, height / total_width);
|
||||||
|
|
Loading…
Reference in a new issue