awesomeWM / awesome

awesome window manager
https://awesomewm.org/
GNU General Public License v2.0
6.39k stars 597 forks source link

Use scalable cursor for high-res display #836

Closed danielmorlock closed 8 years ago

danielmorlock commented 8 years ago

I'm using awesome on my 3200x1800 eDP. I was able to set a scaleable cursor for X apps and GTK apps adding this to ~/.Xresources:

Xcursor.theme: Vanilla-DMZ-AA
Xcursor.size: 48

... this to ~/.gtkrc-2.0

gtk-cursor-theme-name = "Vanilla-DMZ-AA"
gtk-cursor-theme-size = 48

... and this to ~/.config/gtk-3.0/settings.ini

gtk-cursor-theme-name = Vanilla-DMZ-AA
gtk-cursor-theme-size = 48

Unfortunately, the cursor in awesome-wm is not affected from this. Any suggestions?

danielmorlock commented 8 years ago

Setting Xft.dpi: 194 in ~/Xresources has also no effect on the awesome-wm cursor.

actionless commented 8 years ago

for me only Xft.dpi: 192 is enough

are you sure your xresources are imported correctly? is font in awesome wm itself scaled?

or mb your cursor theme do not have large version of cursor? try setting some default cursor theme

also i remember some unrelated bug with cursor, to workaround it i had to create symlink ~/.icons/default to my current cursor theme

psychon commented 8 years ago

Which awesome version? Since 2013 (https://github.com/awesomeWM/awesome/commit/aaa771f8879e0a16dfcaa7f5f6c60cc356498c18), awesome uses libxcb-cursor instead of Xlib's cursor stuff. The bug must be in there.

Does xprop -root RESOURCE_MANAGER show your ~/.Xresources content? Did you perhaps get the file name of this file wrong? (Note the dot in the beginning) Looking at the source code of libxcb-cursor (https://cgit.freedesktop.org/xcb/util-cursor/tree/cursor/cursor.c#n91), you can also try setting something like XCURSOR_SIZE=48 in awesome's environment. How to do this depends on how you start awesome.

danielmorlock commented 8 years ago

I'm using 3.5.8.

The setting Xft.dpi: 194 is shown in xprop -root RESOURCE_MANAGER. This takes also effect on my terminal urxvt which looks quiet good with 194 dpi. I also tried to set -dpi parameter when starting X which also has no effect on the font-size and cursor-size of awesome.

I try changing XCURSOR_SIZE which obvisouly must have some effect on the cursor size. But I wondering why awesome is ignoring my dpi settings at all.

psychon commented 8 years ago

Could you show me the output of xprop -root RESOURCE_MANAGER? This must surely be a bug in libxcb-util-cursor.... Edit: For future-me, here is the code that xcb-util-cursor uses for parsing RESOURCE_MANAGER: https://cgit.freedesktop.org/xcb/util-cursor/tree/cursor/cursor.c#n44

danielmorlock commented 8 years ago
$ xprop -root RESOURCE_MANAGER
RESOURCE_MANAGER(STRING) = "URvxt.urlButton:\t2\nURxvt.background:\t#f2f1f0\nURxvt.color0:\t#eee8d5\nURxvt.color1:\t#dc322f\nURxvt.color10:\t#93a1a1\nURxvt.color11:\t#839496\nURxvt.color12:\t#657b83\nURxvt.color13:\t#6c71c4\nURxvt.color14:\t#586e75\nURxvt.color15:\t#002b36\nURxvt.color2:\t#859900\nURxvt.color3:\t#b58900\nURxvt.color4:\t#268bd2\nURxvt.color5:\t#d33682\nURxvt.color6:\t#2aa198\nURxvt.color7:\t#073642\nURxvt.color8:\t#f2f1f0\nURxvt.color9:\t#cb4b16\nURxvt.copyCommand:\txsel -ib\nURxvt.cursorColor:\t#586e75\nURxvt.fadeColor:\t#f2f1f0\nURxvt.font:\txft:Monospace:size=8\nURxvt.foreground:\t#657b83\nURxvt.intensityStyles:\tfalse\nURxvt.iso14755:\tfalse\nURxvt.iso14755_52:\tfalse\nURxvt.keysym.M-C-v:\tperl:clipboard:paste_escaped\nURxvt.keysym.M-Escape:\tperl:keyboard-select:activate\nURxvt.keysym.M-c:\tperl:clipboard:copy\nURxvt.keysym.M-u:\tperl:url-select:select_next\nURxvt.keysym.M-v:\tperl:clipboard:paste\nURxvt.letterSpace:\t-1\nURxvt.pasteCommand:\txsel -ob\nURxvt.perl-ext-common:\turl-select,keyboard-select,clipboard\nURxvt.perl-lib:\t.urxvt/perl\nURxvt.pointerColorBackground:\t#93a1a1\nURxvt.pointerColorForeground:\t#586e75\nURxvt.reverseVideo:\tfalse\nURxvt.saveLines:\t2000\nURxvt.scrollBar:\tfalse\nURxvt.underlineURLs:\ttrue\nURxvt.urgentOnBell:\ttrue\nURxvt.urlLauncher:\tfirefox\nURxvt.visualBell:\tfalse\nXft.antialias:\t1\nXft.autohint:\t0\nXft.dpi:\t194\nXft.hinting:\t1\nXft.hintstyle:\thintfull\nXft.lcdfilter:\tlcddefault\nXft.rgba:\trgb\nxterm*background:\t#f2f1f0\nxterm*color0:\t#eee8d5\nxterm*color1:\t#dc322f\nxterm*color10:\t#93a1a1\nxterm*color11:\t#839496\nxterm*color12:\t#657b83\nxterm*color13:\t#6c71c4\nxterm*color14:\t#586e75\nxterm*color15:\t#002b36\nxterm*color2:\t#859900\nxterm*color3:\t#b58900\nxterm*color4:\t#268bd2\nxterm*color5:\t#d33682\nxterm*color6:\t#2aa198\nxterm*color7:\t#073642\nxterm*color8:\t#f2f1f0\nxterm*color9:\t#cb4b16\nxterm*cursorColor:\t#586e75\nxterm*faceName:\tDejaVu Sans Mono:size=8\nxterm*fadeColor:\t#f2f1f0\nxterm*foreground:\t#657b83\nxterm*pointerColorBackground:\t#93a1a1\nxterm*pointerColorForeground:\t#586e75\nxterm*scrollBar:\tfalse\nxterm*termName:\txterm-256color\n"
psychon commented 8 years ago

Hm... I just took your output, put that into a file and applied it. The mouse cursor got larger after an awesome restart. I then doubled Xft.dpi, restarted and the mouse cursor got even larger.

I cannot reproduce this issue, sorry. :-(

danielmorlock commented 8 years ago

I put Xft.dpi: 140 in ~/.Xresources.local and applied it with:

$ xrdb -merge ~/.Xresources.local

After an awesome restart, I expect the cursor to get larger, but nothing happens.

danielmorlock commented 8 years ago

So I also added a XCursor theme to Xresources.local and applied it. If a start a new rxvt, the new cursor is used. If I restart awesome, nothing changes. Any ideas?

$ cat ~/.Xresources.local
Xcursor.theme: Vanilla-DMZ-AA
Xft.dpi: 140
psychon commented 8 years ago

Which distro do you use? Which version of xcb-util-cursor? Since I'm out of ideas, let's try moving this upstream: @stapelberg Could you take a look at this? The problem is "cursor size & theme are ignored" and if I test out his .Xressources locally (queried via xprop -root RESSOURCE_MANAGER and applies here locally), everything works for me.

danielmorlock commented 8 years ago

I'm using Gentoo Linux and xcb-util-cursor-0.1.2 + awesome 3.5.9. @psychon Which versions are you using? Can you confirm that your cursor in awesome changes its theme if you load the following Xresources:

Xcursor.theme: Vanilla-DMZ-AA
Xft.dpi: 140
psychon commented 8 years ago

Yup, works here on Fedora 23, xcb-util-cursor 0.1.2 and both awesome 3.5.9 and git/master. (Only the size changes, not the theme, but I guess that's due to "no such theme")

danielmorlock commented 8 years ago

So the cursor changes just by setting the Xft.dpi setting? Does the size of your cursor also change if you set the DPI by xrandr --dpi <int> ?

psychon commented 8 years ago

I'm using Xephyr for these experiments. Xephyr does not support RandR. Also, I don't think xcb-util-cursor looks at that value.

So what I did to test your example:

stapelberg commented 8 years ago

I’ve downloaded Vanilla-DMZ-AA from https://www.archlinux.org/packages/community/any/xcursor-vanilla-dmz-aa/ (“Download from mirror”) and extracted it to ~/.icons/, i.e. its index.theme is located at ~/.icons/Vanilla-DMZ-AA/index.theme.

Then, I’ve changed my Xcursor.theme to read Xcursor.theme: Vanilla-DMZ-AA. Xft.dpi is set to 192 on my machine already. After restarting awesome, the correct cursor theme in the correct size is picked up (i.e. the cursor is big).

So, from my end, I also can’t reproduce this.

Can you apply the following patch to libxcb-util-cursor and provide the output of awesome starting up please?

diff --git i/cursor/cursor.c w/cursor/cursor.c
index 2f56f19..ce4f225 100644
--- i/cursor/cursor.c
+++ w/cursor/cursor.c
@@ -85,6 +85,11 @@ static void parse_resource_manager(xcb_cursor_context_t *c, const xcb_get_proper
         }
     }

+    printf("resource manager parsed\n");
+    printf("xcursor theme: *%s*\n", c->rm[RM_XCURSOR_THEME]);
+    printf("xcursor size: *%s*\n", c->rm[RM_XCURSOR_SIZE]);
+    printf("xft dpi: *%s*\n", c->rm[RM_XFT_DPI]);
+
     free(rm);
 }

diff --git i/cursor/load_cursor.c w/cursor/load_cursor.c
index 53da009..56ca057 100644
--- i/cursor/load_cursor.c
+++ w/cursor/load_cursor.c
@@ -126,6 +126,8 @@ static int open_cursor_file(xcb_cursor_context_t *c, const char *theme, const ch
     int fd = -1;
     char *inherits = NULL;

+    printf("open_cursor_file(%s, %s)\n", theme, name);
+
     *scan_core = -1;

     if (strcmp(theme, "core") == 0 &&
@@ -156,6 +158,7 @@ static int open_cursor_file(xcb_cursor_context_t *c, const char *theme, const ch
             return -1;
         }
         fd = open(full, O_RDONLY);
+        printf("opening %s: %d\n", full, fd);
         free(full);
         if (fd == -1 && inherits == NULL) {
             if (asprintf(&full, "%s/index.theme", themedir) == -1) {
@@ -173,6 +176,7 @@ static int open_cursor_file(xcb_cursor_context_t *c, const char *theme, const ch
          (path != NULL && fd == -1);
          (path = next_path(path))) {
         fd = open_cursor_file(c, path, name, scan_core);
+        printf("open(%s, %s) = %d\n", path, name, fd);
     }

     if (inherits != NULL)
@@ -194,6 +198,8 @@ xcb_cursor_t xcb_cursor_load_cursor(xcb_cursor_context_t *c, const char *name) {
     uint32_t last_height = 0;
     xcb_cursor_t cid = XCB_NONE;

+    printf("xcb_cursor_load_cursor(%s)\n", name);
+
     // NB: if !render_present, fd will be -1 and thus the next if statement
     // will trigger the fallback.
     if (c->render_version != RV_NONE) {
diff --git i/cursor/parse_cursor_file.c w/cursor/parse_cursor_file.c
index 21f72bf..95c7ee7 100644
--- i/cursor/parse_cursor_file.c
+++ w/cursor/parse_cursor_file.c
@@ -72,6 +72,8 @@ static uint32_t find_best_size(xcint_cursor_file_t *cf, const uint32_t target, u
         if (cf->tocs[n].type != XCURSOR_IMAGE_TYPE)
             continue;

+        printf("size = %d, target = %d\n", size, target);
+
         /* If the distance is less to the target size, this is a better fit. */
         if (best == 0 || dist(size, target) < dist(best, target)) {
             best = size;
@@ -101,6 +103,8 @@ int parse_cursor_file(xcb_cursor_context_t *c, const int fd, xcint_image_t **ima
     /* The amount of images stored in 'images', used when cleaning up. */
     int cnt = 0;

+    printf("parse_cursor_file(%d)\n", fd);
+
     if (!read_entirely(fd, &(cf.header), sizeof(xcint_file_header_t)))
         return -EINVAL;

@@ -134,6 +138,8 @@ int parse_cursor_file(xcb_cursor_context_t *c, const int fd, xcint_image_t **ima
     if ((best = find_best_size(&cf, c->size, &nsizes)) == 0 || nsizes == 0)
         goto error;

+    printf("best = %d\n", best);
+
     *nimg = nsizes;
     if ((*images = calloc(nsizes, sizeof(xcint_image_t))) == NULL)
         goto error;
danielmorlock commented 8 years ago
4404 xcursor theme: *Vanilla-DMZ-AA*
4405 xcursor size: *32*
4406 xft dpi: *(null)*
4407 xcb_cursor_load_cursor(left_ptr)
4408 open_cursor_file(Vanilla-DMZ-AA, left_ptr)
4409 opening /home/daniel/.icons/Vanilla-DMZ-AA/cursors/left_ptr: -1
4410 opening /usr/share/icons/Vanilla-DMZ-AA/cursors/left_ptr: -1
4411 opening /usr/share/pixmaps/Vanilla-DMZ-AA/cursors/left_ptr: -1
4412 opening /usr/X11R6/lib/X11/icons/Vanilla-DMZ-AA/cursors/left_ptr: -1
4413 open_cursor_file(default, left_ptr)
4414 opening /home/daniel/.icons/default/cursors/left_ptr: -1
4415 opening /usr/share/icons/default/cursors/left_ptr: -1
4416 opening /usr/share/pixmaps/default/cursors/left_ptr: -1
4417 opening /usr/X11R6/lib/X11/icons/default/cursors/left_ptr: -1
4418 open_cursor_file(Adwaita, left_ptr)
4419 opening /home/daniel/.icons/Adwaita/cursors/left_ptr: -1
4420 opening /usr/share/icons/Adwaita/cursors/left_ptr: -1
4421 opening /usr/share/pixmaps/Adwaita/cursors/left_ptr: -1
4422 opening /usr/X11R6/lib/X11/icons/Adwaita/cursors/left_ptr: -1
4423 open(Adwaita, left_ptr) = -1
4424     percentage:          100%
4425 xcb_cursor_load_cursor(watch)
4426 open_cursor_file(Vanilla-DMZ-AA, watch)
4427 opening /home/daniel/.icons/Vanilla-DMZ-AA/cursors/watch: -1
4428 opening /usr/share/icons/Vanilla-DMZ-AA/cursors/watch: -1
4429 opening /usr/share/pixmaps/Vanilla-DMZ-AA/cursors/watch: -1
4430 opening /usr/X11R6/lib/X11/icons/Vanilla-DMZ-AA/cursors/watch: -1
4431 open_cursor_file(default, watch)
4432 opening /home/daniel/.icons/default/cursors/watch: -1
4433 opening /usr/share/icons/default/cursors/watch: -1
4434 opening /usr/share/pixmaps/default/cursors/watch: -1
4435 opening /usr/X11R6/lib/X11/icons/default/cursors/watch: -1
4436 open_cursor_file(Adwaita, watch)
4437 opening /home/daniel/.icons/Adwaita/cursors/watch: -1
4438 opening /usr/share/icons/Adwaita/cursors/watch: -1
4439 opening /usr/share/pixmaps/Adwaita/cursors/watch: -1
4440 opening /usr/X11R6/lib/X11/icons/Adwaita/cursors/watch: -1
4441 open(Adwaita, watch) = -1
4442 xcb_cursor_load_cursor(cross)
4443 open_cursor_file(Vanilla-DMZ-AA, cross)
4444 opening /home/daniel/.icons/Vanilla-DMZ-AA/cursors/cross: -1
4445 opening /usr/share/icons/Vanilla-DMZ-AA/cursors/cross: -1
4446 opening /usr/share/pixmaps/Vanilla-DMZ-AA/cursors/cross: -1
4447 opening /usr/X11R6/lib/X11/icons/Vanilla-DMZ-AA/cursors/cross: -1
4448 open_cursor_file(default, cross)
4449 opening /home/daniel/.icons/default/cursors/cross: -1
4450 opening /usr/share/icons/default/cursors/cross: -1
4451 opening /usr/share/pixmaps/default/cursors/cross: -1
4452 opening /usr/X11R6/lib/X11/icons/default/cursors/cross: -1
4453 open_cursor_file(Adwaita, cross)
4454 opening /home/daniel/.icons/Adwaita/cursors/cross: -1
4455 opening /usr/share/icons/Adwaita/cursors/cross: -1
4456 opening /usr/share/pixmaps/Adwaita/cursors/cross: -1
4457 opening /usr/X11R6/lib/X11/icons/Adwaita/cursors/cross: -1
4458 open(Adwaita, cross) = -1

Following the output of your patch, it seems that libxcxb-util-cursor can't find the cursor files which are located at /usr/share/cursors/xorg-x11/Vanilla-DMZ-AA/cursors/watch.

stapelberg commented 8 years ago

Ah, gentoo sets --with-cursorpath for x11-libs/libXcursor, see https://gitweb.gentoo.org/repo/gentoo.git/tree/x11-libs/libXcursor/libXcursor-1.1.14.ebuild?id=56bd759df1d0c750a065b8c845e93d5dfa6b549d#n22

https://gitweb.gentoo.org/repo/gentoo.git/tree/x11-libs/xcb-util-cursor/xcb-util-cursor-0.1.2.ebuild?id=c5455e9e02ca056c50eab8edb611d5f2dd030e99 is the corresponding ebuild for xcb-util-cursor, which doesn’t have a compile-time flag to adjust the cursor search path.

xcb-util-cursor currently uses ~/.icons:/usr/share/icons:/usr/share/pixmaps:/usr/X11R6/lib/X11/icons if the environment variable XCURSOR_PATH isn’t set.

@danielmorlock Can you try setting XCURSOR_PATH and report back if the cursor loads correctly?

@psychon If @danielmorlock reports success, could you add such a flag to xcb-util-cursor please? :)

psychon commented 8 years ago

@stapelberg Are you asking me since I'm now your local auto-foo expert? If so: I'd suggest to just copy the code from libXcursor: https://cgit.freedesktop.org/xorg/lib/libXcursor/tree/configure.ac#n79 (lines 63 to 79). No idea why they have a separate icon dir nor what the code does with it, git grep says that ICONDIR is only used in xcursor.pc.in and src/library.c (but the use in the C code is basically dead code, since it only applies when XCURSORPATH is not yet defined). If you want, I'll submit a patch to you for this, I don't like the way that they are setting the C define...

stapelberg commented 8 years ago

I’m asking both because you know a lot more about autotools than I do, but also because I’m heavily constrained on spare cycles to get any work done. I’d appreciate it if you could do the change and send a tested patch which I’ll just have to merge (or just submit it yourself if you have permission).

danielmorlock commented 8 years ago

Setting XCURSOR_PATH to /usr/share/cursors/xorg-x11 solved my issue. Setting the environment variable is a workaround for me, I would expect that xcb-util-cursor finds the vanilla cursors out of the box. So I don't know what the correct location for cursors is, but I would expect xcb-util-cursor to have somehing like --with-cursorpath so that we have a chance to set the default paths at build time.

psychon commented 8 years ago

@stapelberg Patch: http://sprunge.us/FgTE How did I test (= I didn't really test that it functions as expected, I just tested that the define works): http://sprunge.us/LFDX

stapelberg commented 8 years ago

Thanks for the patch!

@danielmorlock Could you apply that patch to the ebuild, set the --with-cursorpath and confirm that this works for you please?

danielmorlock commented 8 years ago

Works. In case of interest, here is the patched ebuild: https://gitlab.awesome-it.de/daniel.morlock/overlay/blob/master/x11-libs/xcb-util-cursor/xcb-util-cursor-0.1.2-r1.ebuild Thanks!

stapelberg commented 8 years ago

Released xcb-util-cursor 0.1.3.

@danielmorlock Maybe you want to file an issue with gentoo to update their xcb-util-cursor ebuild to 0.1.3 and set the --with-cursorpath flag.

psychon commented 8 years ago

@stapelberg Thanks for solving this mysterious bug! :-)

danielmorlock commented 8 years ago

Filed an issue with gentoo: https://bugs.gentoo.org/show_bug.cgi?id=582818