Skip to content

Commit 442f75d

Browse files
committed
stuff
1 parent bf1105b commit 442f75d

7 files changed

Lines changed: 25 additions & 27 deletions

File tree

src/ruisapp/glue/egl_utils.hxx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ struct egl_context_wrapper {
451451
);
452452
}
453453

454-
void disable_vsync()
454+
void set_vsync_enabled(bool enabled)
455455
{
456456
utki::assert(
457457
eglGetCurrentContext() == this->context,
@@ -461,7 +461,11 @@ struct egl_context_wrapper {
461461
SL
462462
);
463463

464-
if (eglSwapInterval(this->egl_display.display, 0) != EGL_TRUE) {
464+
if (eglSwapInterval(
465+
this->egl_display.display, //
466+
enabled ? 1 : 0 // number of vsync frames before framebuffer buffer swap
467+
) != EGL_TRUE)
468+
{
465469
throw std::runtime_error("egl_context_wrapper::disable_vsync(): eglSwapInterval(0) failed");
466470
}
467471
}

src/ruisapp/glue/linux/wayland/wayland_output.cxx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ void wayland_output_wrapper::wl_output_geometry(
4848
});
4949

5050
// TODO: is it needed to notify about outputs changed? Aren't wayland surfaces supposed to receive enter output events?
51-
5251
// auto& ww = get_impl(ruisapp::application::inst());
5352
// ww.notify_outputs_changed();
5453
}
@@ -72,7 +71,6 @@ void wayland_output_wrapper::wl_output_mode(
7271
});
7372

7473
// TODO: is it needed to notify about outputs changed? Aren't wayland surfaces supposed to receive enter output events?
75-
7674
// auto& ww = get_impl(ruisapp::application::inst());
7775
// ww.notify_outputs_changed();
7876
}
@@ -93,7 +91,6 @@ void wayland_output_wrapper::wl_output_scale(
9391
});
9492

9593
// TODO: is it needed to notify about outputs changed? Aren't wayland surfaces supposed to receive enter output events?
96-
9794
// auto& ww = get_impl(ruisapp::application::inst());
9895
// ww.notify_outputs_changed();
9996
}

src/ruisapp/glue/linux/wayland/window.hxx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,7 @@ public:
143143
}
144144
}
145145

146-
// TODO: make this function part of ruis::native_window interface
147-
bool is_rendering_context_bound() const noexcept
146+
bool is_rendering_context_bound() const noexcept override
148147
{
149148
return eglGetCurrentContext() == this->egl_context.context;
150149
}
@@ -193,8 +192,7 @@ public:
193192
this->update_mouse_cursor();
194193
}
195194

196-
// TODO: make part of ruis::native_window intrface
197-
void disable_vsync()
195+
void set_vsync_enabled(bool enabled) noexcept override
198196
{
199197
utki::assert(
200198
[this]() {
@@ -203,7 +201,7 @@ public:
203201
SL
204202
);
205203

206-
this->egl_context.disable_vsync();
204+
this->egl_context.set_vsync_enabled(enabled);
207205
}
208206

209207
wl_callback* make_frame_callback()

src/ruisapp/glue/linux/xorg/window.hxx

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -692,8 +692,7 @@ public:
692692

693693
~native_window() override = default;
694694

695-
// TODO: make this function part of ruis::native_window interface
696-
void disable_vsync()
695+
void set_vsync_enabled(bool enable) noexcept override
697696
{
698697
utki::assert(
699698
[this]() {
@@ -721,7 +720,7 @@ public:
721720
glx_swap_interval_ext(
722721
this->display.get().xorg_display.display, //
723722
this->xorg_window.window,
724-
0
723+
enable ? 1 : 0 // swap interval in vsync frames
725724
);
726725
} else if (this->glx_context.supported_extensions.get(glx_context_wrapper::glx_extension::glx_mesa_swap_control
727726
))
@@ -738,8 +737,11 @@ public:
738737
utki::assert(glx_swap_interval_mesa, SL);
739738

740739
// disable v-sync
741-
if (glx_swap_interval_mesa(0) != 0) {
742-
throw std::runtime_error("glXSwapIntervalMESA() failed");
740+
if (glx_swap_interval_mesa(
741+
enable ? 1 : 0 // swap interval in vsync frames
742+
) != 0)
743+
{
744+
utki::logcat("WARNING: glXSwapIntervalMESA(", enable, ") failed");
743745
}
744746
} else {
745747
std::cout << "none of GLX_EXT_swap_control, GLX_MESA_swap_control GLX "
@@ -754,10 +756,10 @@ public:
754756
#elif defined(RUISAPP_RENDER_OPENGLES)
755757
if (eglSwapInterval(
756758
this->display.get().egl_display.display, //
757-
0
759+
enable ? 1 : 0 // swap interval in vsync frames
758760
) != EGL_TRUE)
759761
{
760-
throw std::runtime_error("eglSwapInterval() failed");
762+
utki::logcat("WARNING: eglSwapInterval(", enable, ") failed");
761763
}
762764
#endif
763765
}
@@ -956,8 +958,7 @@ private:
956958
#endif
957959
}
958960

959-
// TODO: make this function part of ruis::native_window interface
960-
bool is_rendering_context_bound() const noexcept
961+
bool is_rendering_context_bound() const noexcept override
961962
{
962963
#ifdef RUISAPP_RENDER_OPENGL
963964
return glXGetCurrentContext() == this->glx_context.context;

src/ruisapp/glue/sdl/application.cxx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ ruisapp::window& application_glue::make_window(ruisapp::window_parameters window
184184
);
185185

186186
ruisapp_window.get().gui.set_viewport( //
187-
ruis::rect({0, 0}, ruisapp_window.get().ruis_native_window.get().get_dims())
187+
ruis::rect({0, 0}, ruisapp_window.get().ruis_native_window.get().get_dims().to<ruis::real>())
188188
);
189189

190190
auto res = this->windows.insert( //
@@ -239,10 +239,8 @@ ruisapp::application::application(parameters params) :
239239

240240
void ruisapp::application::quit() noexcept
241241
{
242-
auto& glue = get_glue(*this);
243-
244-
// TODO: send SDL_QUIT event instead of setting the flag?
245-
glue.quit_flag.store(true);
242+
SDL_Event event = {SDL_QUIT};
243+
SDL_PushEvent(&event);
246244
}
247245

248246
ruisapp::window& ruisapp::application::make_window(ruisapp::window_parameters window_params)

src/ruisapp/glue/sdl/window.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ native_window::native_window(
292292
#endif
293293
}
294294

295-
ruis::vec2 native_window::get_dims() const noexcept
295+
r4::vector2<unsigned> native_window::get_dims() const noexcept
296296
{
297297
int width = 0;
298298
int height = 0;
@@ -310,7 +310,7 @@ ruis::vec2 native_window::get_dims() const noexcept
310310
dims *= this->get_scale_factor();
311311
#endif
312312

313-
return dims;
313+
return dims.to<unsigned>();
314314
}
315315

316316
void native_window::set_mouse_cursor(ruis::mouse_cursor c)

src/ruisapp/glue/sdl/window.hxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ public:
132132
return this->sdl_window.scale_factor;
133133
}
134134

135-
ruis::vec2 get_dims() const noexcept;
135+
r4::vector2<unsigned> get_dims() const noexcept override;
136136

137137
void set_mouse_cursor(ruis::mouse_cursor c) override;
138138

0 commit comments

Comments
 (0)