Skip to content

Commit

Permalink
desktop-canvas-view: scale desktop workarea
Browse files Browse the repository at this point in the history
The problem is that in the function canvas_container_set_workarea the screen width
and height are in "application pixels" while the workarea ones are in "device
pixels" so when the scaling is > 1, the margins are not properly setted.

We need to scale-down the workarea geometries to "application pixels".

https://bugzilla.gnome.org/show_bug.cgi?id=769302

origin commit:
https://gitlab.gnome.org/GNOME/nautilus/commit/315a55df
  • Loading branch information
azzar1 authored and lukefromdc committed Apr 5, 2018
1 parent 37ebfa8 commit 35eb416
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/file-manager/fm-desktop-icon-view.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,19 +115,23 @@ icon_container_set_workarea (CajaIconContainer *icon_container,
{
int left, right, top, bottom;
int screen_width, screen_height;
int scale;
int i;

left = right = top = bottom = 0;

screen_width = WidthOfScreen (gdk_x11_screen_get_xscreen (screen));
screen_height = HeightOfScreen (gdk_x11_screen_get_xscreen (screen));

scale = gdk_window_get_scale_factor (gdk_screen_get_root_window (screen));
scale = scale ? scale : 1;

for (i = 0; i < n_items; i += 4)
{
int x = workareas [i];
int y = workareas [i + 1];
int width = workareas [i + 2];
int height = workareas [i + 3];
int x = workareas [i] / scale;
int y = workareas [i + 1] / scale;
int width = workareas [i + 2] / scale;
int height = workareas [i + 3] / scale;

if ((x + width) > screen_width || (y + height) > screen_height)
continue;
Expand Down

0 comments on commit 35eb416

Please sign in to comment.