Skip to contentSkip to conversation

ui/cocoa: user friendly characters for release mouse

PATCH In review Christian Schoenebeck 3 participants 9 messages Dec 27, 2022 – Mar 13, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ui/cocoa: user friendly characters for release mouse

While mouse is grabbed, window title contains a hint for the user what keyboard keys to press to release the mouse. Make that hint text a bit more user friendly for a Mac user:

- Replace "Ctrl" and "Alt" by appropriate symbols for those keyboard keys typically displayed for them on a Mac (encode those symbols by using UTF-8 characters).

- Drop " + " in between the keys, as that's not common on macOS for documenting keyboard shortcuts.

- Convert lower case "g" to upper case "G", as that's common on macOS.

- Add one additional space at start and end of key stroke set, to visually separate the key strokes from the rest of the text.

---
 ui/cocoa.m | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
ui/cocoa.m +5 -2
index e915c344a8..289a2b193e 100644
@@ -72,6 +72,9 @@
 
 #define cgrect(nsrect) (*(CGRect *)&(nsrect))
 
+#define UC_CTRL_KEY "\xe2\x8c\x83"
+#define UC_ALT_KEY "\xe2\x8c\xa5"
+
 typedef struct {
     int width;
     int height;
@@ -1135,9 +1138,9 @@ - (void) grabMouse
 
     if (!isFullscreen) {
         if (qemu_name)
-            [normalWindow setTitle:[NSString stringWithFormat:@"QEMU %s - (Press ctrl + alt + g to release Mouse)", qemu_name]];
+            [normalWindow setTitle:[NSString stringWithFormat:@"QEMU %s - (Press  " UC_CTRL_KEY " " UC_ALT_KEY " G  to release Mouse)", qemu_name]];
         else
-            [normalWindow setTitle:@"QEMU - (Press ctrl + alt + g to release Mouse)"];
+            [normalWindow setTitle:@"QEMU - (Press  " UC_CTRL_KEY " " UC_ALT_KEY " G  to release Mouse)"];
     }
     [self hideCursor];
     CGAssociateMouseAndMouseCursorPosition(isAbsoluteEnabled);
Signature · 1 line
2.32.0 (Apple Git-132)
#1 lore raw
Quoted 13 lines · CET Christian Schoenebeck

While mouse is grabbed, window title contains a hint for the user what keyboard keys to press to release the mouse. Make that hint text a bit more user friendly for a Mac user:

- Replace "Ctrl" and "Alt" by appropriate symbols for those keyboard keys typically displayed for them on a Mac (encode those symbols by using UTF-8 characters).

- Drop " + " in between the keys, as that's not common on macOS for documenting keyboard shortcuts.

- Convert lower case "g" to upper case "G", as that's common on macOS.

Quoted 7 lines

- Add one additional space at start and end of key stroke set, to visually separate the key strokes from the rest of the text.

---
 ui/cocoa.m | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

Screenshot attached how title bar looks like (on Mac hosts) after this change.

Quoted 27 lines
ui/cocoa.m +5 -2
index e915c344a8..289a2b193e 100644
@@ -72,6 +72,9 @@
 
 #define cgrect(nsrect) (*(CGRect *)&(nsrect))
 
+#define UC_CTRL_KEY "\xe2\x8c\x83"
+#define UC_ALT_KEY "\xe2\x8c\xa5"
+
 typedef struct {
     int width;
     int height;
@@ -1135,9 +1138,9 @@ - (void) grabMouse
 
     if (!isFullscreen) {
         if (qemu_name)
-            [normalWindow setTitle:[NSString stringWithFormat:@"QEMU %s - (Press ctrl + alt + g to release Mouse)", qemu_name]];
+            [normalWindow setTitle:[NSString stringWithFormat:@"QEMU %s - (Press  " UC_CTRL_KEY " " UC_ALT_KEY " G  to release Mouse)", qemu_name]];
         else
-            [normalWindow setTitle:@"QEMU - (Press ctrl + alt + g to release Mouse)"];
+            [normalWindow setTitle:@"QEMU - (Press  " UC_CTRL_KEY " " UC_ALT_KEY " G  to release Mouse)"];
     }
     [self hideCursor];
     CGAssociateMouseAndMouseCursorPosition(isAbsoluteEnabled);
Tested-by Reviewed-by on v1 1/1
#2 lore raw
In reply to Christian Schoenebeck
Quoted 36 lines · Christian Schoenebeck

While mouse is grabbed, window title contains a hint for the user what keyboard keys to press to release the mouse. Make that hint text a bit more user friendly for a Mac user:

- Replace "Ctrl" and "Alt" by appropriate symbols for those keyboard keys typically displayed for them on a Mac (encode those symbols by using UTF-8 characters).

- Drop " + " in between the keys, as that's not common on macOS for documenting keyboard shortcuts.

- Convert lower case "g" to upper case "G", as that's common on macOS.

- Add one additional space at start and end of key stroke set, to visually separate the key strokes from the rest of the text.

---
  ui/cocoa.m | 7 +++++--
  1 file changed, 5 insertions(+), 2 deletions(-)
ui/cocoa.m +3 -0
index e915c344a8..289a2b193e 100644
@@ -72,6 +72,9 @@
 
  #define cgrect(nsrect) (*(CGRect *)&(nsrect))
 
+#define UC_CTRL_KEY "\xe2\x8c\x83"
+#define UC_ALT_KEY "\xe2\x8c\xa5"
+
  typedef struct {
      int width;
      int height;

ui/cocoa.m - (void) grabMouse · line 1141

Quoted 5 lines
ui/cocoa.m +1 -1
@@ -1135,9 +1138,9 @@ - (void) grabMouse
 
      if (!isFullscreen) {
          if (qemu_name)
-            [normalWindow setTitle:[NSString stringWithFormat:@"QEMU %s - (Press ctrl + alt + g to release Mouse)", qemu_name]];
+            [normalWindow setTitle:[NSString stringWithFormat:@"QEMU %s - (Press  " UC_CTRL_KEY " " UC_ALT_KEY " G  to release Mouse)", qemu_name]];

I was a bit confused by the control symbol at first and tough I had to press '^'; thus I'm not sure keeping 'ctrl' wouldn't be clearer. The UC_ALT_KEY symbol certainly is. Anyhow,

Quoted 6 lines
ui/cocoa.m +1 -1
          else
-            [normalWindow setTitle:@"QEMU - (Press ctrl + alt + g to release Mouse)"];
+            [normalWindow setTitle:@"QEMU - (Press  " UC_CTRL_KEY " " UC_ALT_KEY " G  to release Mouse)"];
      }
      [self hideCursor];
      CGAssociateMouseAndMouseCursorPosition(isAbsoluteEnabled);
#3 lore raw
Quoted 38 lines · CET Philippe Mathieu-Daudé
Quoted 37 lines · Christian Schoenebeck

While mouse is grabbed, window title contains a hint for the user what keyboard keys to press to release the mouse. Make that hint text a bit more user friendly for a Mac user:

- Replace "Ctrl" and "Alt" by appropriate symbols for those keyboard keys typically displayed for them on a Mac (encode those symbols by using UTF-8 characters).

- Drop " + " in between the keys, as that's not common on macOS for documenting keyboard shortcuts.

- Convert lower case "g" to upper case "G", as that's common on macOS.

- Add one additional space at start and end of key stroke set, to visually separate the key strokes from the rest of the text.

---
  ui/cocoa.m | 7 +++++--
  1 file changed, 5 insertions(+), 2 deletions(-)
ui/cocoa.m +3 -0
index e915c344a8..289a2b193e 100644
@@ -72,6 +72,9 @@
 
  #define cgrect(nsrect) (*(CGRect *)&(nsrect))
 
+#define UC_CTRL_KEY "\xe2\x8c\x83"
+#define UC_ALT_KEY "\xe2\x8c\xa5"
+
  typedef struct {
      int width;
      int height;
@@ -1135,9 +1138,9 @@ - (void) grabMouse
 
Quoted 8 lines

ui/cocoa.m - (void) grabMouse · line 1141

Quoted 4 lines
ui/cocoa.m +1 -1
      if (!isFullscreen) {
          if (qemu_name)
-            [normalWindow setTitle:[NSString stringWithFormat:@"QEMU %s - (Press ctrl + alt + g to release Mouse)", qemu_name]];
+            [normalWindow setTitle:[NSString stringWithFormat:@"QEMU %s - (Press  " UC_CTRL_KEY " " UC_ALT_KEY " G  to release Mouse)", qemu_name]];

I was a bit confused by the control symbol at first and tough I had to press '^'; thus I'm not sure keeping 'ctrl' wouldn't be clearer. The UC_ALT_KEY symbol certainly is. Anyhow,

It _should_ be clear to Mac users that "^" == "control" key on a Mac keyboard, as that's how it is presented for keyboard shortcuts in all Mac menus. But if it's really irritating then we can also revert that to either "Ctrl" or "control". It's a quick change.

I just got itched by the "Alt" hint actually, which is not printed on any Mac keyboard.

Quoted 2 lines

Thanks!

Quoted 9 lines
Quoted 6 lines
ui/cocoa.m +1 -1
          else
-            [normalWindow setTitle:@"QEMU - (Press ctrl + alt + g to release Mouse)"];
+            [normalWindow setTitle:@"QEMU - (Press  " UC_CTRL_KEY " " UC_ALT_KEY " G  to release Mouse)"];
      }
      [self hideCursor];
      CGAssociateMouseAndMouseCursorPosition(isAbsoluteEnabled);
#4 lore raw
In reply to Christian Schoenebeck
Quoted 11 lines · CET Christian Schoenebeck

While mouse is grabbed, window title contains a hint for the user what keyboard keys to press to release the mouse. Make that hint text a bit more user friendly for a Mac user:

- Replace "Ctrl" and "Alt" by appropriate symbols for those keyboard keys typically displayed for them on a Mac (encode those symbols by using UTF-8 characters).

- Drop " + " in between the keys, as that's not common on macOS for documenting keyboard shortcuts.

Quoted 7 lines

- Convert lower case "g" to upper case "G", as that's common on macOS.

- Add one additional space at start and end of key stroke set, to visually separate the key strokes from the rest of the text.

---

Ping

Quoted 30 lines
 ui/cocoa.m | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
ui/cocoa.m +5 -2
index e915c344a8..289a2b193e 100644
@@ -72,6 +72,9 @@
 
 #define cgrect(nsrect) (*(CGRect *)&(nsrect))
 
+#define UC_CTRL_KEY "\xe2\x8c\x83"
+#define UC_ALT_KEY "\xe2\x8c\xa5"
+
 typedef struct {
     int width;
     int height;
@@ -1135,9 +1138,9 @@ - (void) grabMouse
 
     if (!isFullscreen) {
         if (qemu_name)
-            [normalWindow setTitle:[NSString stringWithFormat:@"QEMU %s - (Press ctrl + alt + g to release Mouse)", qemu_name]];
+            [normalWindow setTitle:[NSString stringWithFormat:@"QEMU %s - (Press  " UC_CTRL_KEY " " UC_ALT_KEY " G  to release Mouse)", qemu_name]];
         else
-            [normalWindow setTitle:@"QEMU - (Press ctrl + alt + g to release Mouse)"];
+            [normalWindow setTitle:@"QEMU - (Press  " UC_CTRL_KEY " " UC_ALT_KEY " G  to release Mouse)"];
     }
     [self hideCursor];
     CGAssociateMouseAndMouseCursorPosition(isAbsoluteEnabled);
#5 lore raw
Quoted 14 lines · CET Christian Schoenebeck
Quoted 13 lines · CET Christian Schoenebeck

While mouse is grabbed, window title contains a hint for the user what keyboard keys to press to release the mouse. Make that hint text a bit more user friendly for a Mac user:

- Replace "Ctrl" and "Alt" by appropriate symbols for those keyboard keys typically displayed for them on a Mac (encode those symbols by using UTF-8 characters).

- Drop " + " in between the keys, as that's not common on macOS for documenting keyboard shortcuts.

- Convert lower case "g" to upper case "G", as that's common on macOS.

Quoted 7 lines
Quoted 5 lines

- Add one additional space at start and end of key stroke set, to visually separate the key strokes from the rest of the text.

---

Ping

Gerd,

given that I got a RB and TB from Philippe, would you queue this minor macOS patch please?

Best regards,
Christian Schoenebeck

Quoted 34 lines
Quoted 30 lines
 ui/cocoa.m | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
ui/cocoa.m +5 -2
index e915c344a8..289a2b193e 100644
@@ -72,6 +72,9 @@
 
 #define cgrect(nsrect) (*(CGRect *)&(nsrect))
 
+#define UC_CTRL_KEY "\xe2\x8c\x83"
+#define UC_ALT_KEY "\xe2\x8c\xa5"
+
 typedef struct {
     int width;
     int height;
@@ -1135,9 +1138,9 @@ - (void) grabMouse
 
     if (!isFullscreen) {
         if (qemu_name)
-            [normalWindow setTitle:[NSString stringWithFormat:@"QEMU %s - (Press ctrl + alt + g to release Mouse)", qemu_name]];
+            [normalWindow setTitle:[NSString stringWithFormat:@"QEMU %s - (Press  " UC_CTRL_KEY " " UC_ALT_KEY " G  to release Mouse)", qemu_name]];
         else
-            [normalWindow setTitle:@"QEMU - (Press ctrl + alt + g to release Mouse)"];
+            [normalWindow setTitle:@"QEMU - (Press  " UC_CTRL_KEY " " UC_ALT_KEY " G  to release Mouse)"];
     }
     [self hideCursor];
     CGAssociateMouseAndMouseCursorPosition(isAbsoluteEnabled);
#6 lore raw
Quoted 21 lines · Christian Schoenebeck
Quoted 20 lines · CET Christian Schoenebeck
Quoted 18 lines · CET Christian Schoenebeck

While mouse is grabbed, window title contains a hint for the user what keyboard keys to press to release the mouse. Make that hint text a bit more user friendly for a Mac user:

- Replace "Ctrl" and "Alt" by appropriate symbols for those keyboard keys typically displayed for them on a Mac (encode those symbols by using UTF-8 characters).

- Drop " + " in between the keys, as that's not common on macOS for documenting keyboard shortcuts.

- Convert lower case "g" to upper case "G", as that's common on macOS.

- Add one additional space at start and end of key stroke set, to visually separate the key strokes from the rest of the text.

---

Quoted 6 lines
Quoted 1 line

Ping

Gerd,

given that I got a RB and TB from Philippe, would you queue this minor macOS patch please?

Isn't this already merged as 23bdd0de97a18 ?

Regards,
BALATON Zoltan

Quoted 42 lines

Best regards,
Christian Schoenebeck

Quoted 34 lines
Quoted 30 lines
 ui/cocoa.m | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
ui/cocoa.m +5 -2
index e915c344a8..289a2b193e 100644
@@ -72,6 +72,9 @@
 
 #define cgrect(nsrect) (*(CGRect *)&(nsrect))
 
+#define UC_CTRL_KEY "\xe2\x8c\x83"
+#define UC_ALT_KEY "\xe2\x8c\xa5"
+
 typedef struct {
     int width;
     int height;
@@ -1135,9 +1138,9 @@ - (void) grabMouse
 
     if (!isFullscreen) {
         if (qemu_name)
-            [normalWindow setTitle:[NSString stringWithFormat:@"QEMU %s - (Press ctrl + alt + g to release Mouse)", qemu_name]];
+            [normalWindow setTitle:[NSString stringWithFormat:@"QEMU %s - (Press  " UC_CTRL_KEY " " UC_ALT_KEY " G  to release Mouse)", qemu_name]];
         else
-            [normalWindow setTitle:@"QEMU - (Press ctrl + alt + g to release Mouse)"];
+            [normalWindow setTitle:@"QEMU - (Press  " UC_CTRL_KEY " " UC_ALT_KEY " G  to release Mouse)"];
     }
     [self hideCursor];
     CGAssociateMouseAndMouseCursorPosition(isAbsoluteEnabled);
#7 lore raw
Quoted 22 lines · CET BALATON Zoltan
Quoted 21 lines · Christian Schoenebeck
Quoted 20 lines · CET Christian Schoenebeck
Quoted 18 lines · CET Christian Schoenebeck

While mouse is grabbed, window title contains a hint for the user what keyboard keys to press to release the mouse. Make that hint text a bit more user friendly for a Mac user:

- Replace "Ctrl" and "Alt" by appropriate symbols for those keyboard keys typically displayed for them on a Mac (encode those symbols by using UTF-8 characters).

- Drop " + " in between the keys, as that's not common on macOS for documenting keyboard shortcuts.

- Convert lower case "g" to upper case "G", as that's common on macOS.

- Add one additional space at start and end of key stroke set, to visually separate the key strokes from the rest of the text.

---

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

Ping

Gerd,

given that I got a RB and TB from Philippe, would you queue this minor macOS patch please?

Isn't this already merged as 23bdd0de97a18 ?

Ah yes, thanks! Sorry for the noise!

Best regards,
Christian Schoenebeck

#8 lore raw
Quoted 25 lines · Christian Schoenebeck
Quoted 24 lines · CET BALATON Zoltan
Quoted 23 lines · Christian Schoenebeck
Quoted 21 lines · CET Christian Schoenebeck
Quoted 11 lines · CET Christian Schoenebeck

While mouse is grabbed, window title contains a hint for the user what keyboard keys to press to release the mouse. Make that hint text a bit more user friendly for a Mac user:

- Replace "Ctrl" and "Alt" by appropriate symbols for those keyboard keys typically displayed for them on a Mac (encode those symbols by using UTF-8 characters).

- Drop " + " in between the keys, as that's not common on macOS for documenting keyboard shortcuts.

Quoted 7 lines

- Convert lower case "g" to upper case "G", as that's common on macOS.

- Add one additional space at start and end of key stroke set, to visually separate the key strokes from the rest of the text.

---

Ping

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

Gerd,

given that I got a RB and TB from Philippe, would you queue this minor macOS patch please?

Isn't this already merged as 23bdd0de97a18 ?

Ah yes, thanks! Sorry for the noise!

Sorry my bad, back then I forgot to reply to the patch mentioning I'd queue this patch.