FLTK 1.4.1
Screen functions

Fl global screen functions declared in <FL/Fl.H>. More...

Functions

static int Fl::h ()
 Returns the height in pixels of the main screen work area.
 
static void Fl::keyboard_screen_scaling (int value)
 Controls the possibility to scale all windows by ctrl/+/-/0/ or cmd/+/-/0/. More...
 
static int Fl::screen_count ()
 Gets the total count of available screens. More...
 
static void Fl::screen_dpi (float &h, float &v, int n=0)
 Gets the screen resolution in dots-per-inch for the given screen. More...
 
static int Fl::screen_num (int x, int y)
 Gets the screen number of a screen that contains the specified screen position x, y. More...
 
static int Fl::screen_num (int x, int y, int w, int h)
 Gets the screen number of the screen which intersects the most with the rectangle defined by x, y, w, h. More...
 
static float Fl::screen_scale (int n)
 Gets the GUI scaling factor of screen number n. More...
 
static void Fl::screen_scale (int n, float factor)
 Sets the GUI scaling factor of screen number n. More...
 
static int Fl::screen_scaling_supported ()
 Returns whether scaling factors are supported by this platform. More...
 
static void Fl::screen_work_area (int &X, int &Y, int &W, int &H)
 Gets the bounding box of the work area of the screen that contains the mouse pointer. More...
 
static void Fl::screen_work_area (int &X, int &Y, int &W, int &H, int mx, int my)
 Gets the bounding box of the work area of a screen that contains the specified screen position mx, my. More...
 
static void Fl::screen_work_area (int &X, int &Y, int &W, int &H, int n)
 Gets the bounding box of the work area of the given screen. More...
 
static void Fl::screen_xywh (int &X, int &Y, int &W, int &H)
 Gets the bounding box of a screen that contains the mouse pointer. More...
 
static void Fl::screen_xywh (int &X, int &Y, int &W, int &H, int mx, int my)
 Gets the bounding box of a screen that contains the specified screen position mx, my. More...
 
static void Fl::screen_xywh (int &X, int &Y, int &W, int &H, int mx, int my, int mw, int mh)
 Gets the screen bounding rect for the screen which intersects the most with the rectangle defined by mx, my, mw, mh. More...
 
static void Fl::screen_xywh (int &X, int &Y, int &W, int &H, int n)
 Gets the screen bounding rect for the given screen. More...
 
static int Fl::w ()
 Returns the width in pixels of the main screen work area.
 
static int Fl::x ()
 Returns the leftmost x coordinate of the main screen work area.
 
static int Fl::y ()
 Returns the topmost y coordinate of the main screen work area.
 

Detailed Description

Fl global screen functions declared in <FL/Fl.H>.

FLTK supports high-DPI screens using a screen scaling factor. The scaling factor is initialized by the library to a value based on information obtained from the OS. If this initial value is not satisfactory, the FLTK_SCALING_FACTOR environment variable can be set to a value FLTK will multiply to the OS-given value. The 2 variants of functions Fl::screen_scale() allow to programmatically get and set scaling factor values. The scaling factor value can be further changed at runtime by typing Ctrl/+/-/0/ (Cmd/+/-/0/ under macOS). See FL_SHORTCUT for more details about these shortcuts.

Function Documentation

◆ keyboard_screen_scaling()

void Fl::keyboard_screen_scaling ( int  value)
static

Controls the possibility to scale all windows by ctrl/+/-/0/ or cmd/+/-/0/.

This function 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 off, i.e. value must be 0 (zero) - all other values result in undefined behavior and are reserved for future extension.
Parameters
value0 to stop recognition of ctrl/+/-/0/ (or cmd/+/-/0/ under macOS) keys as window scaling.
Since
1.4.0

◆ screen_count()

int Fl::screen_count ( )
static

Gets the total count of available screens.

Note
Screen numbers range from 0 to Fl::screen_count() - 1 in the FLTK API.

◆ screen_dpi()

void Fl::screen_dpi ( float &  h,
float &  v,
int  n = 0 
)
static

Gets the screen resolution in dots-per-inch for the given screen.

Parameters
[out]h,vhorizontal and vertical resolution
[in]nthe screen number (0 to Fl::screen_count() - 1)
See also
void screen_xywh(int &x, int &y, int &w, int &h, int mx, int my)

◆ screen_num() [1/2]

int Fl::screen_num ( int  x,
int  y 
)
static

Gets the screen number of a screen that contains the specified screen position x, y.

Parameters
[in]x,ythe absolute screen position
Returns
a screen number ∈ [0 , Fl::screen_count()-1]
Attention
When the running system contains screens with different scaling factors, this API may become ambiguous because a given value pair (x, y) may belong to distinct screens. In that situation other APIs should be preferred, e.g. Fl_Window::screen_num() and Fl::screen_scale(int).

◆ screen_num() [2/2]

int Fl::screen_num ( int  x,
int  y,
int  w,
int  h 
)
static

Gets the screen number of the screen which intersects the most with the rectangle defined by x, y, w, h.

Parameters
[in]x,y,w,hthe rectangle to search for intersection with
Returns
a screen number ∈ [0 , Fl::screen_count()-1]

◆ screen_scale() [1/2]

float Fl::screen_scale ( int  n)
static

Gets the GUI scaling factor of screen number n.

The valid range of n is 0 .. Fl::screen_count() - 1.

The return value is 1.0 if screen scaling is not supported or n is outside the valid range.

Returns
Current screen scaling factor (default: 1.0)
See also
Fl::screen_count()
Fl::screen_scaling_supported()
Since
1.4.0

◆ screen_scale() [2/2]

void Fl::screen_scale ( int  n,
float  factor 
)
static

Sets the GUI scaling factor of screen number n.

The valid range of n is 0 .. Fl::screen_count() - 1.

This method does nothing if n is out of range or screen scaling is not supported by this platform.

Otherwise it also sets the scaling factor of all windows mapped to screen number n or all screens, depending on the type of screen scaling support on the platform.

Parameters
[in]nscreen number
[in]factorscaling factor of screen n
See also
Fl::screen_scaling_supported()
Since
1.4.0

◆ screen_scaling_supported()

int Fl::screen_scaling_supported ( )
static

Returns whether scaling factors are supported by this platform.

Return values
0scaling factors are not supported by this platform
1a single scaling factor is shared by all screens
2each screen can have its own scaling factor
See also
Fl::screen_scale(int)
Since
1.4.0

◆ screen_work_area() [1/3]

void Fl::screen_work_area ( int &  X,
int &  Y,
int &  W,
int &  H 
)
static

Gets the bounding box of the work area of the screen that contains the mouse pointer.

Parameters
[out]X,Y,W,Hthe work area bounding box
See also
void screen_work_area(int &x, int &y, int &w, int &h, int n)

◆ screen_work_area() [2/3]

void Fl::screen_work_area ( int &  X,
int &  Y,
int &  W,
int &  H,
int  mx,
int  my 
)
static

Gets the bounding box of the work area of a screen that contains the specified screen position mx, my.

Parameters
[out]X,Y,W,Hthe work area bounding box
[in]mx,mythe absolute screen position
See also
void screen_work_area(int &x, int &y, int &w, int &h, int n)

◆ screen_work_area() [3/3]

void Fl::screen_work_area ( int &  X,
int &  Y,
int &  W,
int &  H,
int  n 
)
static

Gets the bounding box of the work area of the given screen.

Parameters
[out]X,Y,W,Hthe work area bounding box
[in]nthe screen number (0 to Fl::screen_count() - 1)
See also
void screen_xywh(int &x, int &y, int &w, int &h, int mx, int my)
Note
Under X11, the screen work area is given values that differ from that screen's bounding box only if the system contains a single screen. Under Wayland, a screen work area is always equal to that screen's bounding box.
Like all quantities accessible via public APIs of FLTK, values of X,Y,W,H are given in FLTK units, that is, in drawing units divided by the scaling factor of screen n.

◆ screen_xywh() [1/4]

void Fl::screen_xywh ( int &  X,
int &  Y,
int &  W,
int &  H 
)
static

Gets the bounding box of a screen that contains the mouse pointer.

Parameters
[out]X,Y,W,Hthe corresponding screen bounding box
See also
void screen_xywh(int &x, int &y, int &w, int &h, int mx, int my)

◆ screen_xywh() [2/4]

void Fl::screen_xywh ( int &  X,
int &  Y,
int &  W,
int &  H,
int  mx,
int  my 
)
static

Gets the bounding box of a screen that contains the specified screen position mx, my.

Parameters
[out]X,Y,W,Hthe corresponding screen bounding box
[in]mx,mythe absolute screen position

◆ screen_xywh() [3/4]

void Fl::screen_xywh ( int &  X,
int &  Y,
int &  W,
int &  H,
int  mx,
int  my,
int  mw,
int  mh 
)
static

Gets the screen bounding rect for the screen which intersects the most with the rectangle defined by mx, my, mw, mh.

Parameters
[out]X,Y,W,Hthe corresponding screen bounding box
[in]mx,my,mw,mhthe rectangle to search for intersection with
See also
void screen_xywh(int &X, int &Y, int &W, int &H, int n)

◆ screen_xywh() [4/4]

void Fl::screen_xywh ( int &  X,
int &  Y,
int &  W,
int &  H,
int  n 
)
static

Gets the screen bounding rect for the given screen.

Under Windows, Mac OS X, and X11 + the Gnome desktop, screen #0 contains the menubar/taskbar

Parameters
[out]X,Y,W,Hthe corresponding screen bounding box
[in]nthe screen number (0 to Fl::screen_count() - 1)
Note
Like all quantities accessible via public APIs of FLTK, values of X,Y,W,H are given in FLTK units, that is, in drawing units divided by the scaling factor of screen n.
See also
void screen_xywh(int &x, int &y, int &w, int &h, int mx, int my)