Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

commander: hidpi scaling? #1044

Open
zmike opened this issue Dec 11, 2020 · 3 comments
Open

commander: hidpi scaling? #1044

zmike opened this issue Dec 11, 2020 · 3 comments

Comments

@zmike
Copy link

zmike commented Dec 11, 2020

I recently started using a 4k setup, doubling my font dpi, and noticed that the commander popup is still the same size as with a lower resolution, meaning that it can only show 2 entries. Any chance this could be scaled a bit?

@b4n
Copy link
Member

b4n commented Dec 11, 2020

Currently it's hard-coded to a 500×200 default size, and if resized the new size doesn't survives a Geany restart. There's 3 things I could do:

  1. adapt that default size to the display scale (which is not the DPI)
  2. adapt to the height of a line, but that's tricky to compute
  3. allow configuration (or at least, restoring) default size

First option seems easy enough, and see below for a test patch.
Option 2 is probably best, but is clearly the most complicated of all.
Option 3 would be fairly easy, but I'm not sure if it's really practical.

Here's the patch for solution 1 (untested, as I don't have a HiDPI monitor at hand). Note that this requires a Geany GTK3 build with GTK >= 3.10 (fairly old by now) and you having set the scaling factor rather than just raised the DPI through the roof.

diff --git a/commander/src/commander-plugin.c b/commander/src/commander-plugin.c
index 9f8d0718..a138ec41 100644
--- a/commander/src/commander-plugin.c
+++ b/commander/src/commander-plugin.c
@@ -654,11 +654,16 @@ create_panel (void)
   GtkWidget          *scroll;
   GtkTreeViewColumn  *col;
   GtkCellRenderer    *cell;
+  gint                scale = 1;
+  
+#if GTK_CHECK_VERSION (3, 10)
+  scale = gtk_widget_get_scale_factor (geany_data->main_widgets->window);
+#endif
   
   plugin_data.panel = g_object_new (GTK_TYPE_WINDOW,
                                     "decorated", FALSE,
-                                    "default-width", 500,
-                                    "default-height", 200,
+                                    "default-width", 500 * scale,
+                                    "default-height", 200 * scale,
                                     "transient-for", geany_data->main_widgets->window,
                                     "window-position", GTK_WIN_POS_CENTER_ON_PARENT,
                                     "type-hint", GDK_WINDOW_TYPE_HINT_DIALOG,

@zmike
Copy link
Author

zmike commented Dec 22, 2020

Sorry for the delay. I can confirm that this works perfectly 👍

GTK_CHECK_VERSION() requires 3 args though, so probably you meant to add another , 0 in there :)

thanks!

@zmike
Copy link
Author

zmike commented Dec 22, 2020

hm actually though, there is a problem here: if I set GDK_SCALE instead of the usual Xft.dpi doubling, geany doesn't pick up the increased font size for the main editor and everything is tiny.

setting both GDK_SCALE and doubling Xft.dpi creates the same problem in the original issue, however, so I think more work is needed here...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants