diff options
| author | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2024-02-28 09:13:35 +0100 |
|---|---|---|
| committer | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2024-02-28 09:13:35 +0100 |
| commit | f4fb973c5d81928c76336827d2a7471715fc1323 (patch) | |
| tree | abca0b2c3b38817e4705a44292711ca9365e19cb | |
| parent | fa7fe3137268baaa1b4a37defc0916fec3865c7c (diff) | |
Simplify code to recognize GUI rescaling shortcuts
| -rw-r--r-- | src/Fl_Screen_Driver.cxx | 13 | ||||
| -rw-r--r-- | src/fl_shortcut.cxx | 10 |
2 files changed, 7 insertions, 16 deletions
diff --git a/src/Fl_Screen_Driver.cxx b/src/Fl_Screen_Driver.cxx index ced46e75f..d63644e7c 100644 --- a/src/Fl_Screen_Driver.cxx +++ b/src/Fl_Screen_Driver.cxx @@ -481,17 +481,10 @@ int Fl_Screen_Driver::scale_handler(int event) { if (!keyboard_screen_scaling) return 0; if ( event != FL_SHORTCUT || !Fl::event_command() ) return 0; - const char *key = Fl::event_text(); - char ek[2] = ""; - if (!key || !*key) { - ek[0] = (char)(Fl::event_key() & 0xff); - ek[1] = '\0'; - key = (const char *)ek; - } enum {none, zoom_in, zoom_out, zoom_reset} zoom = none; - if (key[0] == '0' || (strcmp(key, "à") == 0 /* for Fr keyboards*/)) zoom = zoom_reset; - else if (key[0] == '+' || key[0] == '=') zoom = zoom_in; - else if (key[0] == '-' || (key[0] == '6' /* for Fr keyboards*/)) zoom = zoom_out; + if (Fl::test_shortcut(FL_COMMAND+'+')) zoom = zoom_in; + else if (Fl::test_shortcut(FL_COMMAND+'-')) zoom = zoom_out; + else if (Fl::test_shortcut(FL_COMMAND+'0')) zoom = zoom_reset; if (zoom != none) { int i, count; if (Fl::grab()) return 0; // don't rescale when menu windows are on diff --git a/src/fl_shortcut.cxx b/src/fl_shortcut.cxx index 92fc7e882..f5380be06 100644 --- a/src/fl_shortcut.cxx +++ b/src/fl_shortcut.cxx @@ -78,12 +78,10 @@ int Fl::test_shortcut(unsigned int shortcut) { if ((shift&FL_CTRL) && key >= 0x3f && key <= 0x5F && firstChar==(key^0x40)) return 1; // firstChar should be within a-z - // kludge to recognize shortcut FL_COMMAND+'+' - if (shift == FL_COMMAND && Fl::event_key() == '=' && - shortcut == FL_COMMAND + '+') return 1; - // kludge to recognize shortcut FL_CTRL+'0' with Fr keyboard - if (shift == FL_CTRL && !strcmp(Fl::event_text(), "à") && - shortcut == FL_CTRL + '0') return 1; + // kludge to recognize shortcut FL_COMMAND+'+' without pressing SHIFT + if (shortcut == FL_COMMAND + '+' && + (shift&(FL_META|FL_ALT|FL_CTRL|FL_SHIFT)) == FL_COMMAND && + Fl::event_key() == '=') return 1; return 0; } |
