summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>2023-04-07 10:14:11 +0200
committerManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>2023-04-07 10:14:11 +0200
commitc149091debe9db1f326b90add9f2ec221d1616f9 (patch)
tree52d2c7f48b3ae31739d38f8d48d2c5f4a5bd8ac1
parent6f0e9b658090b177062b9bf001a0e757b99c6221 (diff)
Wayland: fix reporting of relative location of multiple displays
-rw-r--r--documentation/src/wayland.dox9
-rw-r--r--src/drivers/Wayland/Fl_Wayland_Screen_Driver.H5
-rw-r--r--src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx16
3 files changed, 17 insertions, 13 deletions
diff --git a/documentation/src/wayland.dox b/documentation/src/wayland.dox
index 444ab295b..7afca71d4 100644
--- a/documentation/src/wayland.dox
+++ b/documentation/src/wayland.dox
@@ -515,10 +515,6 @@ member variable of display # \c n. This variable is used by function
\c Fl_Wayland_Window_Driver::make_current() when it calls \c Fl_Wayland_Graphics_Driver::set_buffer()
that scales the graphics driver by this factor with \c cairo_scale().
-The display size information of <tt>struct Fl_Wayland_Screen_Driver::output</tt> accounts for
-the value of its \c wld_scale member
-variable: \c width and \c height are set to the number of pixels of the display / \c wld_scale.
-
Overall, an FLTK object, say an Fl_Window, of size \c WxH FLTK units occupies
<tt>W * wld_scale * gui_scale x H * wld_scale * gui_scale</tt> pixels on the display.
@@ -907,8 +903,9 @@ gives access, the Wayland way, to the linked list of displays in the system.
<pre>
struct Fl_Wayland_Screen_Driver::output { // one record for each display
uint32_t id; // an identifier of the display
- short width; // nber of horizontal pixels / wld_scale
- short height; // nber of vertical pixels / wld_scale
+ int x, y; // logical position of the top-left of display
+ int width; // nber of horizontal pixels
+ int height; // nber of vertical pixels
float dpi; // at this point, always 96.
struct wl_output *wl_output; // the Wayland object for this display
int wld_scale; // Wayland scale factor
diff --git a/src/drivers/Wayland/Fl_Wayland_Screen_Driver.H b/src/drivers/Wayland/Fl_Wayland_Screen_Driver.H
index a01c9b013..aeacf033d 100644
--- a/src/drivers/Wayland/Fl_Wayland_Screen_Driver.H
+++ b/src/drivers/Wayland/Fl_Wayland_Screen_Driver.H
@@ -66,8 +66,9 @@ public:
};
struct output { // one record for each screen
uint32_t id;
- short width; // in pixels
- short height; // in pixels
+ int x, y; // logical position of screen
+ int width; // in pixels
+ int height; // in pixels
float dpi;
struct wl_output *wl_output;
int wld_scale; // Wayland scale factor
diff --git a/src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx b/src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx
index 1dcf36cdc..bb04cec36 100644
--- a/src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx
+++ b/src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx
@@ -949,6 +949,8 @@ static void output_geometry(void *data,
{
//fprintf(stderr, "output_geometry: x=%d y=%d physical=%dx%d\n",x,y,physical_width,physical_height);
Fl_Wayland_Screen_Driver::output *output = (Fl_Wayland_Screen_Driver::output*)data;
+ output->x = int(x);
+ output->y = int(y);
output->dpi = 96; // to elaborate
}
@@ -956,8 +958,8 @@ static void output_mode(void *data, struct wl_output *wl_output, uint32_t flags,
int32_t width, int32_t height, int32_t refresh)
{
Fl_Wayland_Screen_Driver::output *output = (Fl_Wayland_Screen_Driver::output*)data;
- output->width = width;
- output->height = height;
+ output->width = int(width);
+ output->height = int(height);
//fprintf(stderr, "output_mode: [%p]=%dx%d\n",output->wl_output,width,height);
}
@@ -1018,6 +1020,9 @@ static struct wl_output_listener output_listener = {
};
+// Notice: adding use of unstable protocol "XDG output" would allow FLTK to be notified
+// in real time of changes to the relative location of multiple displays;
+// with the present code, that information is received at startup only.
static void registry_handle_global(void *user_data, struct wl_registry *wl_registry,
uint32_t id, const char *interface, uint32_t version) {
//fprintf(stderr, "interface=%s version=%u\n", interface, version);
@@ -1261,10 +1266,10 @@ static int workarea_xywh[4] = { -1, -1, -1, -1 };
void Fl_Wayland_Screen_Driver::init_workarea()
{
- workarea_xywh[0] = 0;
- workarea_xywh[1] = 0;
Fl_Wayland_Screen_Driver::output *output;
wl_list_for_each(output, &outputs, link) {
+ workarea_xywh[0] = output->x; // pixels
+ workarea_xywh[1] = output->y; // pixels
workarea_xywh[2] = output->width; // pixels
workarea_xywh[3] = output->height; // pixels
break;
@@ -1342,7 +1347,8 @@ void Fl_Wayland_Screen_Driver::screen_xywh(int &X, int &Y, int &W, int &H, int n
wl_list_for_each(output, &outputs, link) {
if (i++ == n) { // n'th screen of the system
float s = output->gui_scale * output->wld_scale;
- X = Y = 0;
+ X = output->x / s;
+ Y = output->y / s;
W = output->width / s;
H = output->height / s;
break;