mirror of
https://github.com/fltk/fltk.git
synced 2026-06-01 06:14:28 +08:00
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
This commit is contained in:
@@ -3,17 +3,17 @@
|
|||||||
//
|
//
|
||||||
// Main header file for the Fast Light Tool Kit (FLTK).
|
// Main header file 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
|
// 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
|
// the file "COPYING" which should have been included with this file. If this
|
||||||
// file is missing or damaged, see the license at:
|
// 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:
|
// Please report all bugs and problems on the following page:
|
||||||
//
|
//
|
||||||
// http://www.fltk.org/str.php
|
// https://www.fltk.org/str.php
|
||||||
//
|
//
|
||||||
|
|
||||||
/** \file
|
/** \file
|
||||||
@@ -1037,7 +1037,7 @@ int main() {
|
|||||||
static float screen_scale(int n); // via screen driver
|
static float screen_scale(int n); // via screen driver
|
||||||
static void screen_scale(int n, float factor); // via screen driver
|
static void screen_scale(int n, float factor); // via screen driver
|
||||||
static int screen_scaling_supported();
|
static int screen_scaling_supported();
|
||||||
static void keyboard_screen_scaling(int);
|
static void keyboard_screen_scaling(int value);
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
|
|||||||
+16
-7
@@ -3,17 +3,17 @@
|
|||||||
//
|
//
|
||||||
// Main event handling code for the Fast Light Tool Kit (FLTK).
|
// 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
|
// 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
|
// the file "COPYING" which should have been included with this file. If this
|
||||||
// file is missing or damaged, see the license at:
|
// 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:
|
// Please report all bugs and problems on the following page:
|
||||||
//
|
//
|
||||||
// http://www.fltk.org/str.php
|
// https://www.fltk.org/str.php
|
||||||
//
|
//
|
||||||
|
|
||||||
/** \file
|
/** \file
|
||||||
@@ -2155,11 +2155,20 @@ int Fl::screen_scaling_supported() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Controls the possibility to scale all windows by ctrl/+/-/0/ or cmd/+/-/0/.
|
/** 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) {
|
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.
|
// Pointers you can use to change FLTK to another language.
|
||||||
|
|||||||
@@ -3,17 +3,17 @@
|
|||||||
//
|
//
|
||||||
// All screen related calls in a driver style class.
|
// 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
|
// 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
|
// the file "COPYING" which should have been included with this file. If this
|
||||||
// file is missing or damaged, see the license at:
|
// 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:
|
// 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;
|
int num_screens;
|
||||||
static float fl_intersection(int x1, int y1, int w1, int h1,
|
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:
|
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 bg_set;
|
||||||
static char bg2_set;
|
static char bg2_set;
|
||||||
static char fg_set;
|
static char fg_set;
|
||||||
|
|||||||
@@ -37,9 +37,10 @@ char Fl_Screen_Driver::bg_set = 0;
|
|||||||
char Fl_Screen_Driver::bg2_set = 0;
|
char Fl_Screen_Driver::bg2_set = 0;
|
||||||
char Fl_Screen_Driver::fg_set = 0;
|
char Fl_Screen_Driver::fg_set = 0;
|
||||||
|
|
||||||
|
int Fl_Screen_Driver::keyboard_screen_scaling = 1;
|
||||||
|
|
||||||
Fl_Screen_Driver::Fl_Screen_Driver() :
|
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
|
// 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)
|
int Fl_Screen_Driver::scale_handler(int event)
|
||||||
{
|
{
|
||||||
|
if (!keyboard_screen_scaling) return 0;
|
||||||
if ( event != FL_SHORTCUT || (!Fl::event_command()) ) return 0;
|
if ( event != FL_SHORTCUT || (!Fl::event_command()) ) return 0;
|
||||||
int key = Fl::event_key() & ~(FL_SHIFT+FL_COMMAND);
|
int key = Fl::event_key() & ~(FL_SHIFT+FL_COMMAND);
|
||||||
if (key == '=' || key == '-' || key == '+' || key == '0' || key == 0xE0/* for '0' on Fr keyboard */) {
|
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;
|
been_here = true;
|
||||||
if (rescalable()) {
|
if (rescalable()) {
|
||||||
use_startup_scale_factor();
|
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 mx, my;
|
||||||
int ns = Fl::screen_driver()->get_mouse(mx, my);
|
int ns = Fl::screen_driver()->get_mouse(mx, my);
|
||||||
Fl_Graphics_Driver::default_driver().scale(scale(ns));
|
Fl_Graphics_Driver::default_driver().scale(scale(ns));
|
||||||
|
|||||||
Reference in New Issue
Block a user