@@ -63,23 +63,6 @@ static const struct ext_image_copy_capture_session_v1_listener recording_session
6363 .stopped = session_handle_stopped,
6464};
6565
66- static void dmabuf_created (void *data, struct zwp_linux_buffer_params_v1 *,
67- struct wl_buffer *wl_buffer)
68- {
69- TooltipMedia *tooltip_media = (TooltipMedia*)data;
70-
71- tooltip_media->buffer = wl_buffer;
72- }
73-
74- static void dmabuf_failed (void *data, struct zwp_linux_buffer_params_v1 *)
75- {}
76-
77- static const struct zwp_linux_buffer_params_v1_listener params_listener =
78- {
79- .created = dmabuf_created,
80- .failed = dmabuf_failed,
81- };
82-
8366/* Copy Capture Callbacks */
8467
8568static void frame_handle_transform (void *,
@@ -102,8 +85,6 @@ static void frame_handle_ready(void *data,
10285{
10386 TooltipMedia *tooltip_media = (TooltipMedia*)data;
10487
105- tooltip_media->frame_in_flight = false ;
106-
10788 if (tooltip_media->buffer == nullptr )
10889 {
10990 printf (" %s buffer null\n " , __func__);
@@ -163,19 +144,12 @@ static void frame_handle_ready(void *data,
163144 auto texture = builder->build ();
164145
165146 tooltip_media->set_paintable (texture);
166- tooltip_media->frame_in_flight = false ;
167147}
168148
169149static void frame_handle_failed (void *data,
170- struct ext_image_copy_capture_frame_v1 *handle ,
150+ struct ext_image_copy_capture_frame_v1 * ,
171151 uint32_t reason)
172- {
173- TooltipMedia *tooltip_media = (TooltipMedia*)data;
174-
175- ext_image_copy_capture_frame_v1_destroy (handle);
176- tooltip_media->frame = nullptr ;
177- tooltip_media->frame_in_flight = false ;
178- }
152+ {}
179153
180154static const struct ext_image_copy_capture_frame_v1_listener frame_listener = {
181155 .transform = frame_handle_transform,
@@ -190,16 +164,26 @@ static void frame_handle_linux_dmabuf(uint32_t width, uint32_t height, TooltipMe
190164 auto format = (tooltip_media->current_buffer_format == WL_SHM_FORMAT_XRGB8888 ) ?
191165 GBM_FORMAT_XRGB8888 : GBM_FORMAT_ARGB8888 ;
192166
167+ if (tooltip_media->gbm_bo_fd > 0 )
168+ {
169+ close (tooltip_media->gbm_bo_fd );
170+ }
171+
193172 if (tooltip_media->bo )
194173 {
195174 gbm_bo_destroy (tooltip_media->bo );
196175 tooltip_media->bo = nullptr ;
197176 }
198177
178+ if (tooltip_media->buffer )
179+ {
180+ wl_buffer_destroy (tooltip_media->buffer );
181+ tooltip_media->buffer = nullptr ;
182+ }
183+
199184 if (tooltip_media->params )
200185 {
201186 zwp_linux_buffer_params_v1_destroy (tooltip_media->params );
202- tooltip_media->params = nullptr ;
203187 }
204188
205189 auto w = width;
@@ -225,15 +209,16 @@ static void frame_handle_linux_dmabuf(uint32_t width, uint32_t height, TooltipMe
225209 tooltip_media->stride = gbm_bo_get_stride (tooltip_media->bo );
226210 tooltip_media->params = zwp_linux_dmabuf_v1_create_params (tooltip_media->window_list ->dmabuf );
227211
212+ tooltip_media->gbm_bo_fd = gbm_bo_get_fd (tooltip_media->bo );
213+
228214 uint64_t mod = gbm_bo_get_modifier (tooltip_media->bo );
229215 zwp_linux_buffer_params_v1_add (tooltip_media->params ,
230- gbm_bo_get_fd ( tooltip_media->bo ) , 0 ,
216+ tooltip_media->gbm_bo_fd , 0 ,
231217 gbm_bo_get_offset (tooltip_media->bo , 0 ),
232218 gbm_bo_get_stride (tooltip_media->bo ),
233219 mod >> 32 , mod & 0xffffffff );
234220
235- zwp_linux_buffer_params_v1_add_listener (tooltip_media->params , ¶ms_listener, tooltip_media);
236- zwp_linux_buffer_params_v1_create (tooltip_media->params , w, h, format, 0 );
221+ tooltip_media->buffer = zwp_linux_buffer_params_v1_create_immed (tooltip_media->params , w, h, format, 0 );
237222}
238223
239224void TooltipMedia::request_next_frame ()
@@ -264,25 +249,17 @@ void TooltipMedia::request_next_frame()
264249 return ;
265250 }
266251
267- if (frame_in_flight)
268- {
269- return ;
270- }
271-
272252 if (frame)
273253 {
274254 ext_image_copy_capture_frame_v1_destroy (frame);
275- frame = NULL ;
276255 }
277256
278257 frame = ext_image_copy_capture_session_v1_create_frame (recording_session);
279- frame = frame;
280258
281259 ext_image_copy_capture_frame_v1_add_listener (frame, &frame_listener, this );
282260 ext_image_copy_capture_frame_v1_attach_buffer (frame, buffer);
283261 ext_image_copy_capture_frame_v1_damage_buffer (frame, 0 , 0 , width, height);
284262 ext_image_copy_capture_frame_v1_capture (frame);
285- frame_in_flight = true ;
286263}
287264
288265void TooltipMedia::start_toplevel_source_session ()
@@ -300,11 +277,6 @@ TooltipMedia::TooltipMedia(WayfireWindowList *window_list, ext_foreign_toplevel_
300277{
301278 this ->window_list = window_list;
302279 this ->ext_handle = ext_handle;
303- set_can_shrink (true );
304- set_content_fit (Gtk::ContentFit::CONTAIN );
305- set_vexpand (false );
306- set_hexpand (false );
307- set_size_request (200 , -1 );
308280
309281 start_toplevel_source_session ();
310282
@@ -352,9 +324,9 @@ TooltipMedia::~TooltipMedia()
352324 zwp_linux_buffer_params_v1_destroy (this ->params );
353325 }
354326
355- if (this ->bo && this -> map_data )
327+ if (this ->gbm_bo_fd > 0 )
356328 {
357- gbm_bo_unmap (this ->bo , this -> map_data );
329+ close (this ->gbm_bo_fd );
358330 }
359331
360332 if (this ->bo )
0 commit comments