@@ -54,17 +54,17 @@ namespace wl {
5454 }
5555
5656 if (!display_name) {
57- BOOST_LOG (error) << " Environment variable WAYLAND_DISPLAY has not been defined" sv;
57+ BOOST_LOG (error) << " [wayland] Environment variable WAYLAND_DISPLAY has not been defined" sv;
5858 return -1 ;
5959 }
6060
6161 display_internal.reset (wl_display_connect (display_name));
6262 if (!display_internal) {
63- BOOST_LOG (error) << " Couldn't connect to Wayland display: " sv << display_name;
63+ BOOST_LOG (error) << " [wayland] Couldn't connect to Wayland display: " sv << display_name;
6464 return -1 ;
6565 }
6666
67- BOOST_LOG (info) << " Found display [" sv << display_name << ' ]' ;
67+ BOOST_LOG (info) << " [wayland] Found display [" sv << display_name << ' ]' ;
6868
6969 return 0 ;
7070 }
@@ -127,26 +127,26 @@ namespace wl {
127127 inline void monitor_t::xdg_name (zxdg_output_v1 *, const char *name) {
128128 this ->name = name;
129129
130- BOOST_LOG (info) << " Name: " sv << this ->name ;
130+ BOOST_LOG (info) << " [wayland] Name: " sv << this ->name ;
131131 }
132132
133133 void monitor_t::xdg_description (zxdg_output_v1 *, const char *description) {
134134 this ->description = description;
135135
136- BOOST_LOG (info) << " Found monitor: " sv << this ->description ;
136+ BOOST_LOG (info) << " [wayland] Found monitor: " sv << this ->description ;
137137 }
138138
139139 void monitor_t::xdg_position (zxdg_output_v1 *, std::int32_t x, std::int32_t y) {
140140 viewport.offset_x = x;
141141 viewport.offset_y = y;
142142
143- BOOST_LOG (info) << " Offset: " sv << x << ' x' << y;
143+ BOOST_LOG (info) << " [wayland] Offset: " sv << x << ' x' << y;
144144 }
145145
146146 void monitor_t::xdg_size (zxdg_output_v1 *, std::int32_t width, std::int32_t height) {
147147 viewport.logical_width = width;
148148 viewport.logical_height = height;
149- BOOST_LOG (info) << " Logical size: " sv << width << ' x' << height;
149+ BOOST_LOG (info) << " [wayland] Logical size: " sv << width << ' x' << height;
150150 }
151151
152152 void monitor_t::wl_mode (
@@ -159,7 +159,7 @@ namespace wl {
159159 viewport.width = width;
160160 viewport.height = height;
161161
162- BOOST_LOG (info) << " Resolution: " sv << width << ' x' << height;
162+ BOOST_LOG (info) << " [wayland] Resolution: " sv << width << ' x' << height;
163163 }
164164
165165 void monitor_t::listen (zxdg_output_manager_v1 *output_manager) {
@@ -189,35 +189,35 @@ namespace wl {
189189 const char *interface,
190190 std::uint32_t version
191191 ) {
192- BOOST_LOG (debug) << " Available interface: " sv << interface << ' (' << id << " ) version " sv << version;
192+ BOOST_LOG (debug) << " [wayland] Available interface: " sv << interface << ' (' << id << " ) version " sv << version;
193193
194194 if (!std::strcmp (interface, wl_output_interface.name )) {
195- BOOST_LOG (info) << " Found interface: " sv << interface << ' (' << id << " ) version " sv << version;
195+ BOOST_LOG (info) << " [wayland] Found interface: " sv << interface << ' (' << id << " ) version " sv << version;
196196 monitors.emplace_back (
197197 std::make_unique<monitor_t >(
198198 (wl_output *) wl_registry_bind (registry, id, &wl_output_interface, 2 )
199199 )
200200 );
201201 } else if (!std::strcmp (interface, zxdg_output_manager_v1_interface.name )) {
202- BOOST_LOG (info) << " Found interface: " sv << interface << ' (' << id << " ) version " sv << version;
202+ BOOST_LOG (info) << " [wayland] Found interface: " sv << interface << ' (' << id << " ) version " sv << version;
203203 output_manager = (zxdg_output_manager_v1 *) wl_registry_bind (registry, id, &zxdg_output_manager_v1_interface, version);
204204
205205 this ->interface [XDG_OUTPUT] = true ;
206206 } else if (!std::strcmp (interface, zwlr_screencopy_manager_v1_interface.name )) {
207- BOOST_LOG (info) << " Found interface: " sv << interface << ' (' << id << " ) version " sv << version;
207+ BOOST_LOG (info) << " [wayland] Found interface: " sv << interface << ' (' << id << " ) version " sv << version;
208208 screencopy_manager = (zwlr_screencopy_manager_v1 *) wl_registry_bind (registry, id, &zwlr_screencopy_manager_v1_interface, version);
209209
210210 this ->interface [WLR_EXPORT_DMABUF] = true ;
211211 } else if (!std::strcmp (interface, zwp_linux_dmabuf_v1_interface.name )) {
212- BOOST_LOG (info) << " Found interface: " sv << interface << ' (' << id << " ) version " sv << version;
212+ BOOST_LOG (info) << " [wayland] Found interface: " sv << interface << ' (' << id << " ) version " sv << version;
213213 dmabuf_interface = (zwp_linux_dmabuf_v1 *) wl_registry_bind (registry, id, &zwp_linux_dmabuf_v1_interface, version);
214214
215215 this ->interface [LINUX_DMABUF] = true ;
216216 }
217217 }
218218
219219 void interface_t::del_interface (wl_registry *registry, uint32_t id) {
220- BOOST_LOG (info) << " Delete: " sv << id;
220+ BOOST_LOG (info) << " [wayland] Delete: " sv << id;
221221 }
222222
223223 // Initialize GBM
@@ -230,7 +230,7 @@ namespace wl {
230230 drmDevice *devices[16 ];
231231 int n = drmGetDevices2 (0 , devices, 16 );
232232 if (n <= 0 ) {
233- BOOST_LOG (error) << " No DRM devices found" sv;
233+ BOOST_LOG (error) << " [wayland] No DRM devices found" sv;
234234 return false ;
235235 }
236236
@@ -246,14 +246,14 @@ namespace wl {
246246 drmFreeDevices (devices, n);
247247
248248 if (drm_fd < 0 ) {
249- BOOST_LOG (error) << " Failed to open DRM render node" sv;
249+ BOOST_LOG (error) << " [wayland] Failed to open DRM render node" sv;
250250 return false ;
251251 }
252252
253253 gbm_device = gbm_create_device (drm_fd);
254254 if (!gbm_device) {
255255 close (drm_fd);
256- BOOST_LOG (error) << " Failed to create GBM device" sv;
256+ BOOST_LOG (error) << " [wayland] Failed to create GBM device" sv;
257257 return false ;
258258 }
259259
@@ -343,8 +343,6 @@ namespace wl {
343343 shm_info.width = width;
344344 shm_info.height = height;
345345 shm_info.stride = stride;
346-
347- BOOST_LOG (debug) << " Screencopy supports SHM format: " sv << format;
348346 }
349347
350348 // DMA-BUF format callback
@@ -358,14 +356,12 @@ namespace wl {
358356 dmabuf_info.format = format;
359357 dmabuf_info.width = width;
360358 dmabuf_info.height = height;
361-
362- BOOST_LOG (debug) << " Screencopy supports DMA-BUF format: " sv << format;
363359 }
364360
365361 // Flags callback
366362 void dmabuf_t::flags (zwlr_screencopy_frame_v1 *frame, std::uint32_t flags) {
367363 y_invert = flags & ZWLR_SCREENCOPY_FRAME_V1_FLAGS_Y_INVERT;
368- BOOST_LOG (debug ) << " Frame flags: " sv << flags << (y_invert ? " (y_invert)" : " " );
364+ BOOST_LOG (verbose ) << " Frame flags: " sv << flags << (y_invert ? " (y_invert)" : " " );
369365 }
370366
371367 // DMA-BUF creation helper
@@ -433,11 +429,11 @@ namespace wl {
433429 create_and_copy_dmabuf (frame);
434430 } else if (shm_info.supported ) {
435431 // SHM fallback would go here
436- BOOST_LOG (warning) << " SHM capture not implemented" sv;
432+ BOOST_LOG (warning) << " [wayland] SHM capture not implemented" sv;
437433 zwlr_screencopy_frame_v1_destroy (frame);
438434 status = REINIT;
439435 } else {
440- BOOST_LOG (error) << " No supported buffer types" sv;
436+ BOOST_LOG (error) << " [wayland] No supported buffer types" sv;
441437 zwlr_screencopy_frame_v1_destroy (frame);
442438 status = REINIT;
443439 }
@@ -468,7 +464,7 @@ namespace wl {
468464 auto frame = static_cast <zwlr_screencopy_frame_v1 *>(data);
469465 auto self = static_cast <dmabuf_t *>(zwlr_screencopy_frame_v1_get_user_data (frame));
470466
471- BOOST_LOG (error) << " Failed to create buffer from params" sv;
467+ BOOST_LOG (error) << " [wayland] Failed to create buffer from params" sv;
472468 self->cleanup_gbm ();
473469
474470 zwp_linux_buffer_params_v1_destroy (params);
@@ -483,12 +479,16 @@ namespace wl {
483479 std::uint32_t tv_sec_lo,
484480 std::uint32_t tv_nsec
485481 ) {
486- BOOST_LOG (debug) << " Frame ready" sv;
487-
488482 // Frame is ready for use, GBM buffer now contains screen content
489483 current_frame->destroy ();
490484 current_frame = get_next_frame ();
491485
486+ std::uint64_t sec = (std::uint64_t (tv_sec_hi) << 32 ) | tv_sec_lo;
487+ auto ready_ts = std::chrono::seconds (sec) + std::chrono::nanoseconds (tv_nsec);
488+ current_frame->frame_timestamp = std::chrono::steady_clock::time_point {
489+ std::chrono::duration_cast<std::chrono::steady_clock::duration>(ready_ts)
490+ };
491+
492492 // Keep the GBM buffer alive but destroy the Wayland objects
493493 if (current_wl_buffer) {
494494 wl_buffer_destroy (current_wl_buffer);
@@ -503,7 +503,7 @@ namespace wl {
503503
504504 // Failed callback
505505 void dmabuf_t::failed (zwlr_screencopy_frame_v1 *frame) {
506- BOOST_LOG (error) << " Frame capture failed" sv;
506+ BOOST_LOG (error) << " [wayland] Frame capture failed" sv;
507507
508508 // Clean up resources
509509 cleanup_gbm ();
@@ -514,6 +514,7 @@ namespace wl {
514514 status = REINIT;
515515 }
516516
517+ // Only called if using zwlr_screencopy_frame_v1_copy_with_damage()
517518 void dmabuf_t::damage (
518519 zwlr_screencopy_frame_v1 *frame,
519520 std::uint32_t x,
@@ -550,7 +551,7 @@ namespace wl {
550551 display.roundtrip ();
551552
552553 if (!interface[interface_t ::XDG_OUTPUT]) {
553- BOOST_LOG (error) << " Missing Wayland wire XDG_OUTPUT" sv;
554+ BOOST_LOG (error) << " [wayland] Missing Wayland wire XDG_OUTPUT" sv;
554555 return {};
555556 }
556557
0 commit comments