summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>2020-01-31 09:42:36 +0100
committerManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>2020-01-31 09:42:36 +0100
commit4ba6cef0b96de6bf76a019cc2367267db8840c73 (patch)
treea45c1ea0b809249c35c279907edddc5e3b614250
parent9d4d5ffdeb8dacb18f1af47772cb1ee56e7daca7 (diff)
Add Fl::keyboard_screen_scaling(int) to control recognition of ctrl/+/-/0/
-rw-r--r--CHANGES.txt2
-rw-r--r--FL/Fl.H1
-rw-r--r--src/Fl.cxx8
-rw-r--r--src/Fl_Screen_Driver.H2
-rw-r--r--src/Fl_Screen_Driver.cxx4
5 files changed, 14 insertions, 3 deletions
diff --git a/CHANGES.txt b/CHANGES.txt
index 75592e7be..83d6e33b1 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -18,6 +18,8 @@ Changes in FLTK 1.4.0 Released: ??? ?? 2019
New Features and Extensions
- (add new items here)
+ - New Fl::keyboard_screen_scaling(0) call stops recognition of ctrl/+/-/0/
+ keystrokes as scaling all windows of a screen.
- New "Preview" switch added to the GTK native file chooser dialog
available on the X11 platform. This requires function fl_register_images()
to have been called.
diff --git a/FL/Fl.H b/FL/Fl.H
index e35083226..04f9b0db7 100644
--- a/FL/Fl.H
+++ b/FL/Fl.H
@@ -1037,6 +1037,7 @@ int main() {
static float screen_scale(int n); // via screen driver
static void screen_scale(int n, float factor); // via screen driver
static int screen_scaling_supported();
+ static void keyboard_screen_scaling(int);
/** @} */
diff --git a/src/Fl.cxx b/src/Fl.cxx
index 2652ad9ff..6f2660611 100644
--- a/src/Fl.cxx
+++ b/src/Fl.cxx
@@ -2154,6 +2154,14 @@ int Fl::screen_scaling_supported() {
return Fl::screen_driver()->rescalable();
}
+/** Controls the possibilty to scale all windows by ctrl/+/-/0/ or cmd/+/-/0/.
+ This function must be called before fl_open_display() runs to be effective.
+ \param value 0 to stop recognition of ctrl/+/-/0/ (or cmd/+/-/0/ under macOS) keys as window scaling.
+ */
+void Fl::keyboard_screen_scaling(int value) {
+ Fl::screen_driver()->keyboard_screen_scaling = value;
+}
+
// Pointers you can use to change FLTK to another language.
// Note: Similar pointers are defined in FL/fl_ask.H and src/fl_ask.cxx
FL_EXPORT const char* fl_local_shift = Fl::system_driver()->shift_name();
diff --git a/src/Fl_Screen_Driver.H b/src/Fl_Screen_Driver.H
index 05924812c..0b693f95b 100644
--- a/src/Fl_Screen_Driver.H
+++ b/src/Fl_Screen_Driver.H
@@ -66,11 +66,11 @@ protected:
int x2, int y2, int w2, int h2);
public:
+ bool keyboard_screen_scaling; // true means ctrl/+/-/0/ resize windows
static char bg_set;
static char bg2_set;
static char fg_set;
-public:
virtual float scale(int n) {return 1;}
virtual void scale(int n, float f) { }
static Fl_Screen_Driver *newScreenDriver();
diff --git a/src/Fl_Screen_Driver.cxx b/src/Fl_Screen_Driver.cxx
index c18cd40d3..eb4dce212 100644
--- a/src/Fl_Screen_Driver.cxx
+++ b/src/Fl_Screen_Driver.cxx
@@ -39,7 +39,7 @@ char Fl_Screen_Driver::fg_set = 0;
Fl_Screen_Driver::Fl_Screen_Driver() :
-num_screens(-1), text_editor_extra_key_bindings(NULL)
+num_screens(-1), text_editor_extra_key_bindings(NULL), keyboard_screen_scaling(true)
{
}
@@ -471,7 +471,7 @@ void Fl_Screen_Driver::open_display()
been_here = true;
if (rescalable()) {
use_startup_scale_factor();
- Fl::add_handler(Fl_Screen_Driver::scale_handler);
+ if (keyboard_screen_scaling) Fl::add_handler(Fl_Screen_Driver::scale_handler);
int mx, my;
int ns = Fl::screen_driver()->get_mouse(mx, my);
Fl_Graphics_Driver::default_driver().scale(scale(ns));