Skip to content

Commit efc61fb

Browse files
author
Aidan Goddard
committed
first pass at changing wayland scale to double type
1 parent 53bfb65 commit efc61fb

File tree

5 files changed

+16
-17
lines changed

5 files changed

+16
-17
lines changed

client/displayservers/Wayland/cursor.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ void waylandCursorFree(void)
183183

184184
void waylandCursorScaleChange(void)
185185
{
186-
int newScale = ceil(wl_fixed_to_double(wlWm.scale));
186+
int newScale = ceil(wlWm.scale);
187187
if (newScale == wlWm.cursorScale)
188188
return;
189189

client/displayservers/Wayland/gl.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,7 @@ void waylandEGLSwapBuffers(EGLDisplay display, EGLSurface surface, const struct
9292

9393
int width, height;
9494
wlWm.desktop->getSize(&width, &height);
95-
wl_egl_window_resize(wlWm.eglWindow, wl_fixed_to_int(width * wlWm.scale),
96-
wl_fixed_to_int(height * wlWm.scale), 0, 0);
95+
wl_egl_window_resize(wlWm.eglWindow, width * wlWm.scale, height * wlWm.scale, 0, 0);
9796

9897
if (width == 0 || height == 0)
9998
skipResize = true;
@@ -123,15 +122,15 @@ void waylandEGLSwapBuffers(EGLDisplay display, EGLSurface surface, const struct
123122
wp_viewport_destroy(wlWm.viewport);
124123
wlWm.viewport = NULL;
125124
}
126-
wl_surface_set_buffer_scale(wlWm.surface, wl_fixed_to_int(wlWm.scale));
125+
wl_surface_set_buffer_scale(wlWm.surface, floor(wlWm.scale));
127126
}
128127

129128
struct wl_region * region = wl_compositor_create_region(wlWm.compositor);
130129
wl_region_add(region, 0, 0, width, height);
131130
wl_surface_set_opaque_region(wlWm.surface, region);
132131
wl_region_destroy(region);
133132

134-
app_handleResizeEvent(width, height, wl_fixed_to_double(wlWm.scale),
133+
app_handleResizeEvent(width, height, wlWm.scale,
135134
(struct Border) {0, 0, 0, 0});
136135
app_invalidateWindow(true);
137136
waylandStopWaitFrame();

client/displayservers/Wayland/output.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@
2929

3030
static void outputUpdateScale(struct WaylandOutput * node)
3131
{
32-
wl_fixed_t original = node->scale;
32+
double original = node->scale;
3333

3434
if (!wlWm.useFractionalScale || !wlWm.viewporter || !node->logicalWidth)
35-
node->scale = wl_fixed_from_int(node->scaleInt);
35+
node->scale = node->scaleInt;
3636
else
3737
{
3838
int32_t modeWidth = node->modeRotate ? node->modeHeight : node->modeWidth;
39-
node->scale = wl_fixed_from_double(1.0 * modeWidth / node->logicalWidth);
39+
node->scale = 1.0 * modeWidth / node->logicalWidth;
4040
}
4141

4242
if (original != node->scale)
@@ -209,12 +209,12 @@ void waylandOutputTryUnbind(uint32_t name)
209209
}
210210
}
211211

212-
wl_fixed_t waylandOutputGetScale(struct wl_output * output)
212+
double waylandOutputGetScale(struct wl_output * output)
213213
{
214214
struct WaylandOutput * node;
215215

216216
wl_list_for_each(node, &wlWm.outputs, link)
217217
if (node->output == output)
218218
return node->scale;
219-
return 0;
219+
return 0.0;
220220
}

client/displayservers/Wayland/wayland.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ struct WaylandPoll
6262
struct WaylandOutput
6363
{
6464
uint32_t name;
65-
wl_fixed_t scale;
65+
double scale;
6666
int32_t scaleInt;
6767
int32_t logicalWidth;
6868
int32_t logicalHeight;
@@ -108,7 +108,7 @@ struct WaylandDSState
108108
struct wl_shm * shm;
109109
struct wl_compositor * compositor;
110110

111-
wl_fixed_t scale;
111+
double scale;
112112
bool fractionalScale;
113113
bool needsResize;
114114
bool configured;
@@ -284,7 +284,7 @@ bool waylandOutputInit(void);
284284
void waylandOutputFree(void);
285285
void waylandOutputBind(uint32_t name, uint32_t version);
286286
void waylandOutputTryUnbind(uint32_t name);
287-
wl_fixed_t waylandOutputGetScale(struct wl_output * output);
287+
double waylandOutputGetScale(struct wl_output * output);
288288

289289
// poll module
290290
bool waylandPollInit(void);

client/displayservers/Wayland/window.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,20 +33,20 @@
3333

3434
void waylandWindowUpdateScale(void)
3535
{
36-
wl_fixed_t maxScale = 0;
36+
double maxScale = 0;
3737
struct SurfaceOutput * node;
3838

3939
wl_list_for_each(node, &wlWm.surfaceOutputs, link)
4040
{
41-
wl_fixed_t scale = waylandOutputGetScale(node->output);
41+
double scale = waylandOutputGetScale(node->output);
4242
if (scale > maxScale)
4343
maxScale = scale;
4444
}
4545

4646
if (maxScale)
4747
{
4848
wlWm.scale = maxScale;
49-
wlWm.fractionalScale = wl_fixed_from_int(wl_fixed_to_int(maxScale)) != maxScale;
49+
wlWm.fractionalScale = floor(maxScale) != maxScale;
5050
wlWm.needsResize = true;
5151
waylandCursorScaleChange();
5252
app_invalidateWindow(true);
@@ -87,7 +87,7 @@ static const struct wl_surface_listener wlSurfaceListener = {
8787

8888
bool waylandWindowInit(const char * title, const char * appId, bool fullscreen, bool maximize, bool borderless, bool resizable)
8989
{
90-
wlWm.scale = wl_fixed_from_int(1);
90+
wlWm.scale = 1.0;
9191

9292
wlWm.frameEvent = lgCreateEvent(true, 0);
9393
if (!wlWm.frameEvent)

0 commit comments

Comments
 (0)