summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlbrecht Schlosser <albrechts.fltk@online.de>2020-01-31 15:48:21 +0100
committerAlbrecht Schlosser <albrechts.fltk@online.de>2020-01-31 15:48:21 +0100
commitf93b825b08fd848d793bd65f9a87d7f99b5df8b8 (patch)
treeb2bb9cccf31fc4bcd21b9a3b11ea68285a4adace /src
parent65a798f9a237f149d5c320697440fd9cb030f460 (diff)
Update Fl::keyboard_screen_scaling()
- make the internal variable static - make it callable after fl_open_display() - document that it's currently only usable to switch scaling off
Diffstat (limited to 'src')
-rw-r--r--src/Fl.cxx23
-rw-r--r--src/Fl_Screen_Driver.H10
-rw-r--r--src/Fl_Screen_Driver.cxx7
3 files changed, 26 insertions, 14 deletions
diff --git a/src/Fl.cxx b/src/Fl.cxx
index 5f6d1e236..6742b0bc9 100644
--- a/src/Fl.cxx
+++ b/src/Fl.cxx
@@ -3,17 +3,17 @@
//
// Main event handling code for the Fast Light Tool Kit (FLTK).
//
-// Copyright 1998-2018 by Bill Spitzak and others.
+// Copyright 1998-2020 by Bill Spitzak and others.
//
// This library is free software. Distribution and use rights are outlined in
// the file "COPYING" which should have been included with this file. If this
// file is missing or damaged, see the license at:
//
-// http://www.fltk.org/COPYING.php
+// https://www.fltk.org/COPYING.php
//
// Please report all bugs and problems on the following page:
//
-// http://www.fltk.org/str.php
+// https://www.fltk.org/str.php
//
/** \file
@@ -2155,11 +2155,20 @@ int Fl::screen_scaling_supported() {
}
/** Controls the possibility 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.
- */
+
+ This function \b should be called before fl_open_display() runs.
+ If it is not called, the default is to handle these keys for
+ window scaling.
+
+ \note This function can currently only be used to switch the internal
+ handler \b off, i.e. \p value must be 0 (zero) - all other values
+ result in undefined behavior and are reserved for future extension.
+
+ \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;
+ Fl_Screen_Driver::keyboard_screen_scaling = value;
}
// Pointers you can use to change FLTK to another language.
diff --git a/src/Fl_Screen_Driver.H b/src/Fl_Screen_Driver.H
index 0b693f95b..b7bb6df83 100644
--- a/src/Fl_Screen_Driver.H
+++ b/src/Fl_Screen_Driver.H
@@ -3,17 +3,17 @@
//
// All screen related calls in a driver style class.
//
-// Copyright 1998-2018 by Bill Spitzak and others.
+// Copyright 1998-2020 by Bill Spitzak and others.
//
// This library is free software. Distribution and use rights are outlined in
// the file "COPYING" which should have been included with this file. If this
// file is missing or damaged, see the license at:
//
-// http://www.fltk.org/COPYING.php
+// https://www.fltk.org/COPYING.php
//
// Please report all bugs and problems on the following page:
//
-// http://www.fltk.org/str.php
+// https://www.fltk.org/str.php
//
/**
@@ -63,10 +63,10 @@ protected:
int num_screens;
static float fl_intersection(int x1, int y1, int w1, int h1,
- int x2, int y2, int w2, int h2);
+ int x2, int y2, int w2, int h2);
public:
- bool keyboard_screen_scaling; // true means ctrl/+/-/0/ resize windows
+ static int keyboard_screen_scaling; // true means ctrl/+/-/0/ resize windows
static char bg_set;
static char bg2_set;
static char fg_set;
diff --git a/src/Fl_Screen_Driver.cxx b/src/Fl_Screen_Driver.cxx
index eb4dce212..092570521 100644
--- a/src/Fl_Screen_Driver.cxx
+++ b/src/Fl_Screen_Driver.cxx
@@ -37,9 +37,10 @@ char Fl_Screen_Driver::bg_set = 0;
char Fl_Screen_Driver::bg2_set = 0;
char Fl_Screen_Driver::fg_set = 0;
+int Fl_Screen_Driver::keyboard_screen_scaling = 1;
Fl_Screen_Driver::Fl_Screen_Driver() :
-num_screens(-1), text_editor_extra_key_bindings(NULL), keyboard_screen_scaling(true)
+num_screens(-1), text_editor_extra_key_bindings(NULL)
{
}
@@ -397,6 +398,7 @@ void Fl_Screen_Driver::transient_scale_display(float f, int nscreen)
// respond to Ctrl-'+' and Ctrl-'-' and Ctrl-'0' (Ctrl-'=' is same as Ctrl-'+') by rescaling all windows
int Fl_Screen_Driver::scale_handler(int event)
{
+ if (!keyboard_screen_scaling) return 0;
if ( event != FL_SHORTCUT || (!Fl::event_command()) ) return 0;
int key = Fl::event_key() & ~(FL_SHIFT+FL_COMMAND);
if (key == '=' || key == '-' || key == '+' || key == '0' || key == 0xE0/* for '0' on Fr keyboard */) {
@@ -471,7 +473,8 @@ void Fl_Screen_Driver::open_display()
been_here = true;
if (rescalable()) {
use_startup_scale_factor();
- if (keyboard_screen_scaling) 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));