GHOST/Wayland: store API compatible fractional scaling values

Use values compatible with Wayland's fractional-scale API.

No funcitonal changes.
This commit is contained in:
Campbell Barton 2023-04-11 16:00:54 +10:00
parent 8dae058768
commit 34f386c730
3 changed files with 8 additions and 6 deletions

View File

@ -4520,7 +4520,8 @@ static void xdg_output_handle_logical_size(void *data,
* Until this is fixed, validate that _some_ kind of scaling is being
* done (we can't match exactly because fractional scaling can't be
* detected otherwise), then override if necessary. */
if ((output->size_logical[0] == width) && (output->scale_fractional == wl_fixed_from_int(1))) {
if ((output->size_logical[0] == width) &&
(output->scale_fractional == (1 * FRACTIONAL_DENOMINATOR))) {
GHOST_PRINT("xdg_output scale did not match, overriding with wl_output scale\n");
#ifdef USE_GNOME_CONFINE_HACK
@ -4667,7 +4668,7 @@ static void output_handle_done(void *data, struct wl_output * /*wl_output*/)
GHOST_ASSERT(size_native[0] && output->size_logical[0],
"Screen size values were not set when they were expected to be.");
output->scale_fractional = wl_fixed_from_int(size_native[0]) / output->size_logical[0];
output->scale_fractional = (size_native[0] * FRACTIONAL_DENOMINATOR) / output->size_logical[0];
output->has_scale_fractional = true;
}
}

View File

@ -31,6 +31,8 @@
# include <thread>
#endif
#define FRACTIONAL_DENOMINATOR 120
class GHOST_WindowWayland;
bool ghost_wl_output_own(const struct wl_output *wl_output);
@ -100,10 +102,10 @@ struct GWL_Output {
* as this is what is used for most API calls.
* Only use fractional scaling to calculate the DPI.
*
* \note Internally an #wl_fixed_t is used to store the scale of the display,
* so use the same value here (avoid floating point arithmetic in general).
* \note Use the same scale as #wp_fractional_scale_manager_v1
* (avoid floating point arithmetic in general).
*/
wl_fixed_t scale_fractional = wl_fixed_from_int(1);
int scale_fractional = (1 * FRACTIONAL_DENOMINATOR);
bool has_scale_fractional = false;
std::string make;

View File

@ -40,7 +40,6 @@
#include <xdg-activation-v1-client-protocol.h>
#include <xdg-decoration-unstable-v1-client-protocol.h>
#include <xdg-shell-client-protocol.h>
#define FRACTIONAL_DENOMINATOR 120
#include <atomic>