@@ -82,8 +82,8 @@ struct LVGLWidget<BaseWidget>::PrivateData {
8282 void init ()
8383 {
8484 lv_init ();
85- lv_delay_set_cb (msleep );
86- lv_tick_set_cb (gettime_ms );
85+ lv_delay_set_cb (DISTRHO_NAMESPACE::d_msleep );
86+ lv_tick_set_cb (DISTRHO_NAMESPACE::d_gettime_ms );
8787
8888 #ifdef DPF_LVGL_AUTO_SCALING
8989 static constexpr const int scaleFactor = 1 ;
@@ -111,6 +111,10 @@ struct LVGLWidget<BaseWidget>::PrivateData {
111111 lv_indev_set_driver_data (indev, this );
112112 lv_indev_set_group (indev, group);
113113 }
114+ else
115+ {
116+ d_stderr2 (" failed to create lvgl input device for keyboard events" );
117+ }
114118
115119 if (lv_indev_t * const indev = lv_indev_create ())
116120 {
@@ -120,6 +124,10 @@ struct LVGLWidget<BaseWidget>::PrivateData {
120124 lv_indev_set_driver_data (indev, this );
121125 lv_indev_set_group (indev, group);
122126 }
127+ else
128+ {
129+ d_stderr2 (" failed to create lvgl input device for mouse pointer events" );
130+ }
123131
124132 if (lv_indev_t * const indev = lv_indev_create ())
125133 {
@@ -129,6 +137,10 @@ struct LVGLWidget<BaseWidget>::PrivateData {
129137 lv_indev_set_driver_data (indev, this );
130138 lv_indev_set_group (indev, group);
131139 }
140+ else
141+ {
142+ d_stderr2 (" failed to create lvgl input device for mouse wheel events" );
143+ }
132144
133145 #ifdef DGL_OPENGL
134146 glGenTextures (1 , &textureId);
@@ -225,6 +237,8 @@ struct LVGLWidget<BaseWidget>::PrivateData {
225237 const uint32_t data_size = stride * height;
226238
227239 textureData = static_cast <uint8_t *>(std::realloc (textureData, data_size));
240+ DISTRHO_SAFE_ASSERT_RETURN (textureData != nullptr ,);
241+
228242 std::memset (textureData, 0 , data_size);
229243
230244 textureSize = Size<uint>(width, height);
@@ -241,25 +255,15 @@ struct LVGLWidget<BaseWidget>::PrivateData {
241255
242256 // ----------------------------------------------------------------------------------------------------------------
243257
244- static void msleep (const uint32_t millis) noexcept
245- {
246- return DISTRHO_NAMESPACE::d_msleep (millis);
247- }
248-
249- static uint32_t gettime_ms () noexcept
250- {
251- return DISTRHO_NAMESPACE::d_gettime_ms ();
252- }
253-
254- // ----------------------------------------------------------------------------------------------------------------
255-
256258 static void resolution_changed_cb (lv_event_t * const ev)
257259 {
258260 lv_display_t * const evdisplay = static_cast <lv_display_t *>(lv_event_get_current_target (ev));
259261 PrivateData* const evthis = static_cast <PrivateData*>(lv_display_get_driver_data (evdisplay));
260262 const uint width = lv_display_get_horizontal_resolution (evdisplay);
261263 const uint height = lv_display_get_vertical_resolution (evdisplay);
262264
265+ d_debug (" lvgl resolution changed to %ux%u" , width, height);
266+
263267 evthis->recreateTextureData (width, height);
264268 }
265269
@@ -298,6 +302,12 @@ struct LVGLWidget<BaseWidget>::PrivateData {
298302 _lv_area_join (&evthis->updatedArea , &tmp, area);
299303 }
300304
305+ d_debug (" lvgl flush with updated area %dx%d %dx%d" ,
306+ evthis->updatedArea .x1 ,
307+ evthis->updatedArea .y1 ,
308+ evthis->updatedArea .x2 ,
309+ evthis->updatedArea .y2 );
310+
301311 evthis->repaint (Rectangle<uint>(evthis->updatedArea .x1 ,
302312 evthis->updatedArea .y1 ,
303313 evthis->updatedArea .x2 - evthis->updatedArea .x1 ,
@@ -442,6 +452,7 @@ void LVGLWidget<BaseWidget>::onDisplay()
442452 lvglData->updatedArea .x2 == width &&
443453 lvglData->updatedArea .y2 == height)
444454 {
455+ d_debug (" onDisplay updatedArea changed with full size, reset texture" );
445456 glTexImage2D (GL_TEXTURE_2D, 0 , intformat, width, height, 0 , format, ftype, lvglData->textureData );
446457 }
447458 // partial size
@@ -455,6 +466,7 @@ void LVGLWidget<BaseWidget>::onDisplay()
455466 const uint8_t colsize = lv_color_format_get_size (lv_display_get_color_format (lvglData->display ));
456467 const int32_t offset = partial_y * width * colsize + partial_x * colsize;
457468
469+ d_debug (" onDisplay updatedArea changed with partial size, update texture" );
458470 glTexSubImage2D (GL_TEXTURE_2D, 0 ,
459471 partial_x,
460472 partial_y,
@@ -713,13 +725,21 @@ void LVGLWidget<BaseWidget>::onResize(const Widget::ResizeEvent& event)
713725 const uint width = event.size .getWidth ();
714726 const uint height = event.size .getHeight ();
715727 #endif
728+ d_debug (" onResize %u %u" , width, height);
729+
716730 lv_area_set (&lvglData->updatedArea , 0 , 0 , width, height);
717731
718732 lv_global = lvglData->global ;
719733 lv_display_set_resolution (lvglData->display , width, height);
720734 lv_refr_now (lvglData->display );
721735}
722736
737+ template <class BaseWidget >
738+ void LVGLWidget<BaseWidget>::PrivateData::repaint(const Rectangle<uint>& rect)
739+ {
740+ self->repaint (rect);
741+ }
742+
723743// --------------------------------------------------------------------------------------------------------------------
724744// LVGLSubWidget
725745
@@ -764,12 +784,6 @@ LVGLWidget<TopLevelWidget>::~LVGLWidget()
764784 delete lvglData;
765785}
766786
767- template <>
768- void LVGLWidget<TopLevelWidget>::PrivateData::repaint(const Rectangle<uint>& rect)
769- {
770- self->repaint (rect);
771- }
772-
773787template class LVGLWidget <TopLevelWidget>;
774788
775789// --------------------------------------------------------------------------------------------------------------------
@@ -798,12 +812,6 @@ LVGLWidget<StandaloneWindow>::~LVGLWidget()
798812 delete lvglData;
799813}
800814
801- template <>
802- void LVGLWidget<StandaloneWindow>::PrivateData::repaint(const Rectangle<uint>& rect)
803- {
804- self->repaint (rect);
805- }
806-
807815template class LVGLWidget <StandaloneWindow>;
808816
809817// --------------------------------------------------------------------------------------------------------------------
0 commit comments