Add Fl::keyboard_screen_scaling(int) to control recognition of ctrl/+/-/0/

This commit is contained in:
ManoloFLTK 2020-01-31 09:42:36 +01:00
parent 9d4d5ffdeb
commit 4ba6cef0b9
5 changed files with 14 additions and 3 deletions

View File

@ -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.

View File

@ -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);
/** @} */

View File

@ -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();

View File

@ -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();

View File

@ -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));