Skip to content

Commit b456eda

Browse files
soreautrigg
authored andcommitted
window-list: shm: Drop.
1 parent 1d0d8ab commit b456eda

7 files changed

Lines changed: 25 additions & 93 deletions

File tree

meson.build

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ dbusmenu_gtk = dependency('dbusmenu-glib-0.4')
3333
xkbregistry = dependency('xkbregistry')
3434
json = subproject('wf-json').get_variable('wfjson')
3535
openssl = dependency('openssl')
36-
gbm = dependency('gbm', required: get_option('live-previews-dmabuf'))
37-
drm = dependency('libdrm', required: get_option('live-previews-dmabuf'))
36+
gbm = dependency('gbm', required: false)
37+
drm = dependency('libdrm', required: false)
3838

3939
if get_option('wayland-logout') == true
4040
wayland_logout = subproject('wayland-logout')
@@ -45,8 +45,8 @@ if get_option('weather') == true
4545
add_project_arguments('-DHAVE_WEATHER=1', language: 'cpp')
4646
endif
4747

48-
if gbm.found() and drm.found() and not get_option('live-previews-dmabuf').disabled()
49-
add_project_arguments('-DHAVE_DMABUF=1', language: 'cpp')
48+
if not gbm.found() or not drm.found()
49+
message('Live window previews require gbm and libdrm dependencies')
5050
endif
5151

5252
if libpulse.found()

meson_options.txt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,3 @@ option(
2828
value: false,
2929
description: 'Install weather widgets and open-weather-fetch systemd service',
3030
)
31-
option(
32-
'live-previews-dmabuf',
33-
type: 'feature',
34-
value: 'auto',
35-
description: 'Enable live window preview tooltips when hovering over window-list buttons in wf-panel'
36-
)

src/panel/meson.build

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,10 @@ else
7272
message('Weather disabled, weather widgets and owf service not included.')
7373
endif
7474

75-
if gbm.found() and drm.found() and not get_option('live-previews-dmabuf').disabled()
75+
if gbm.found() and drm.found()
7676
deps += [gbm, drm]
7777
else
78-
message('Development packages for gbm and drm are required to enable live window preview tooltips in wf-panel.')
78+
message('Development packages for gbm and libdrm are required to enable live window preview tooltips in wf-panel.')
7979
endif
8080

8181
executable(

src/panel/widgets/window-list/toplevel.cpp

Lines changed: 10 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -63,29 +63,27 @@ static const struct ext_image_copy_capture_session_v1_listener recording_session
6363
.stopped = session_handle_stopped,
6464
};
6565

66-
#ifdef HAVE_DMABUF
6766
static void dmabuf_created(void *data, struct zwp_linux_buffer_params_v1*,
6867
struct wl_buffer *wl_buffer)
6968
{
7069
TooltipMedia *tooltip_media = (TooltipMedia*)data;
7170

71+
if (tooltip_media->buffer)
72+
{
73+
wl_buffer_destroy(tooltip_media->buffer);
74+
}
75+
7276
tooltip_media->buffer = wl_buffer;
7377
}
7478

7579
static void dmabuf_failed(void *data, struct zwp_linux_buffer_params_v1*)
76-
{
77-
TooltipMedia *tooltip_media = (TooltipMedia*)data;
78-
79-
std::cerr << "Failed to create dmabuf, trying shm" << std::endl;
80-
tooltip_media->window_list->live_previews_dmabuf = false;
81-
}
80+
{}
8281

8382
static const struct zwp_linux_buffer_params_v1_listener params_listener =
8483
{
8584
.created = dmabuf_created,
8685
.failed = dmabuf_failed,
8786
};
88-
#endif // HAVE_DMABUF
8987

9088
/* Copy Capture Callbacks */
9189

@@ -174,7 +172,7 @@ static void frame_handle_failed(void *data,
174172
uint32_t reason)
175173
{
176174
TooltipMedia *tooltip_media = (TooltipMedia*)data;
177-
std::cerr << "Failed to copy frame because reason: " << reason << std::endl;
175+
178176
ext_image_copy_capture_frame_v1_destroy(handle);
179177
tooltip_media->frame = nullptr;
180178
tooltip_media->frame_in_flight = false;
@@ -243,7 +241,6 @@ void TooltipMedia::request_next_frame()
243241
{
244242
if ((current_buffer_width <= 0) || (current_buffer_height <= 0))
245243
{
246-
printf("%s invalid size\n", __func__);
247244
return;
248245
}
249246

@@ -304,7 +301,6 @@ TooltipMedia::TooltipMedia(WayfireWindowList *window_list, ext_foreign_toplevel_
304301
{
305302
this->window_list = window_list;
306303
this->ext_handle = ext_handle;
307-
this->shm = window_list->shm;
308304
set_can_shrink(true);
309305
set_content_fit(Gtk::ContentFit::CONTAIN);
310306
set_vexpand(false);
@@ -347,24 +343,11 @@ TooltipMedia::~TooltipMedia()
347343
ext_image_copy_capture_session_v1_destroy(recording_session);
348344
}
349345

350-
if (
351-
#ifdef HAVE_DMABUF
352-
!this->window_list->live_previews_dmabuf &&
353-
#endif // HAVE_DMABUF
354-
this->shm_data && this->size)
355-
{
356-
if (munmap(this->shm_data, this->size) < 0)
357-
{
358-
perror("munmap failed");
359-
}
360-
}
361-
362346
if (this->buffer)
363347
{
364348
wl_buffer_destroy(this->buffer);
365349
}
366350

367-
#ifdef HAVE_DMABUF
368351
if (this->params)
369352
{
370353
zwp_linux_buffer_params_v1_destroy(this->params);
@@ -379,8 +362,6 @@ TooltipMedia::~TooltipMedia()
379362
{
380363
gbm_bo_destroy(this->bo);
381364
}
382-
383-
#endif // HAVE_DMABUF
384365
}
385366

386367
class WayfireToplevel::impl
@@ -536,7 +517,7 @@ class WayfireToplevel::impl
536517

537518
void set_tooltip_media()
538519
{
539-
if (this->tooltip_media || !this->ext_handle)
520+
if (this->tooltip_media || !this->ext_handle || !(bool)window_list->live_window_previews)
540521
{
541522
return;
542523
}
@@ -734,7 +715,8 @@ class WayfireToplevel::impl
734715
return false;
735716
}
736717

737-
if (this->window_list->list_toplevels.empty())
718+
if (this->window_list->list_toplevels.empty() || !this->ext_handle ||
719+
!(bool)window_list->live_window_previews)
738720
{
739721
tooltip->set_text(title);
740722
}

src/panel/widgets/window-list/toplevel.hpp

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#pragma once
22

3+
#include <gbm.h>
4+
#include <xf86drm.h>
35
#include <memory>
46
#include <gtkmm/box.h>
57
#include <gtkmm/picture.h>
@@ -9,17 +11,12 @@
911
#include <ext-foreign-toplevel-list-v1-client-protocol.h>
1012
#include <ext-image-capture-source-v1-client-protocol.h>
1113
#include <ext-image-copy-capture-v1-client-protocol.h>
14+
#include <linux-dmabuf-unstable-v1-client-protocol.h>
1215
#include <wayland-client-protocol.h>
1316
#include <wf-option-wrap.hpp>
1417
#include "wf-shell-app.hpp"
1518
#include "panel.hpp"
1619

17-
#ifdef HAVE_DMABUF
18-
#include <gbm.h>
19-
#include <xf86drm.h>
20-
#include <linux-dmabuf-unstable-v1-client-protocol.h>
21-
#endif // HAVE_DMABUF
22-
2320
class WayfireWindowList;
2421
class WayfireWindowListBox;
2522

@@ -34,9 +31,7 @@ class TooltipMedia : public Gtk::Picture
3431
{
3532
public:
3633
WayfireWindowList *window_list = nullptr;
37-
wl_shm *shm = nullptr;
3834
wl_buffer *buffer = nullptr;
39-
void *shm_data = nullptr;
4035
ext_foreign_toplevel_handle_v1 *ext_handle = NULL;
4136
ext_image_copy_capture_frame_v1 *frame = NULL;
4237
ext_image_capture_source_v1 *copy_capture_source = NULL;
@@ -48,14 +43,11 @@ class TooltipMedia : public Gtk::Picture
4843
uint32_t current_buffer_width = 0, width = -1;
4944
uint32_t current_buffer_height = 0, height = -1;
5045
uint32_t stride;
51-
size_t size = 0;
5246

53-
#ifdef HAVE_DMABUF
5447
gbm_bo *bo = nullptr;
5548
zwp_linux_buffer_params_v1 *params = nullptr;
5649
void *dmabuf_data = nullptr;
5750
void *map_data = nullptr;
58-
#endif // HAVE_DMABUF
5951

6052
TooltipMedia(WayfireWindowList *window_list, ext_foreign_toplevel_handle_v1 *ext_handle);
6153
~TooltipMedia();

src/panel/widgets/window-list/window-list.cpp

Lines changed: 4 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44

55
#include "window-list.hpp"
66

7-
#ifdef HAVE_DMABUF
8-
#include <fcntl.h>
9-
#endif // HAVE_DMABUF
7+
#include <fcntl.h>
108

119
#define DEFAULT_SIZE_PC 0.1
1210

@@ -137,7 +135,6 @@ ext_foreign_toplevel_list_v1_listener toplevel_list_v1_impl = {
137135
.finished = handle_finished,
138136
};
139137

140-
#ifdef HAVE_DMABUF
141138
static void dmabuf_feedback_done(void *data, struct zwp_linux_dmabuf_feedback_v1 *feedback)
142139
{
143140
WayfireWindowList *window_list = (WayfireWindowList*)data;
@@ -167,7 +164,6 @@ static void dmabuf_feedback_main_device(void *data, struct zwp_linux_dmabuf_feed
167164
{
168165
perror("Failed to get DRM device from dev id");
169166
std::cerr << "Trying shm" << std::endl;
170-
window_list->live_previews_dmabuf = false;
171167
return;
172168
}
173169

@@ -184,7 +180,6 @@ static void dmabuf_feedback_main_device(void *data, struct zwp_linux_dmabuf_feed
184180
{
185181
perror("Failed to open drm device");
186182
std::cerr << "Trying shm" << std::endl;
187-
window_list->live_previews_dmabuf = false;
188183
return;
189184
}
190185

@@ -194,7 +189,6 @@ static void dmabuf_feedback_main_device(void *data, struct zwp_linux_dmabuf_feed
194189
close(drm_fd);
195190
perror("Failed to create gbm device");
196191
std::cerr << "Trying shm" << std::endl;
197-
window_list->live_previews_dmabuf = false;
198192
return;
199193
}
200194

@@ -228,17 +222,13 @@ static const struct zwp_linux_dmabuf_feedback_v1_listener dmabuf_feedback_listen
228222
.tranche_formats = dmabuf_feedback_tranche_formats,
229223
.tranche_flags = dmabuf_feedback_tranche_flags,
230224
};
231-
#endif // HAVE_DMABUF
232225

233226
static void registry_add_object(void *data, wl_registry *registry, uint32_t name,
234227
const char *interface, uint32_t version)
235228
{
236229
WayfireWindowList *window_list = (WayfireWindowList*)data;
237230

238-
if (strcmp(interface, wl_shm_interface.name) == 0)
239-
{
240-
window_list->shm = (wl_shm*)wl_registry_bind(registry, name, &wl_shm_interface, version);
241-
} else if (strcmp(interface, zwlr_foreign_toplevel_manager_v1_interface.name) == 0)
231+
if (strcmp(interface, zwlr_foreign_toplevel_manager_v1_interface.name) == 0)
242232
{
243233
auto zwlr_toplevel_manager = (zwlr_foreign_toplevel_manager_v1*)
244234
wl_registry_bind(registry, name,
@@ -268,10 +258,7 @@ static void registry_add_object(void *data, wl_registry *registry, uint32_t name
268258
&ext_foreign_toplevel_image_capture_source_manager_v1_interface, version);
269259
window_list->toplevel_capture_manager = toplevel_capture_manager;
270260
printf("set toplevel_capture_manager: %p\n", toplevel_capture_manager);
271-
}
272-
273-
#ifdef HAVE_DMABUF
274-
else if (strcmp(interface, zwp_linux_dmabuf_v1_interface.name) == 0)
261+
} else if (strcmp(interface, zwp_linux_dmabuf_v1_interface.name) == 0)
275262
{
276263
window_list->dmabuf = (zwp_linux_dmabuf_v1*)wl_registry_bind(registry, name,
277264
&zwp_linux_dmabuf_v1_interface, version);
@@ -282,7 +269,6 @@ static void registry_add_object(void *data, wl_registry *registry, uint32_t name
282269
window_list);
283270
}
284271
}
285-
#endif // HAVE_DMABUF
286272
}
287273

288274
static void registry_remove_object(void *data, struct wl_registry *registry, uint32_t name)
@@ -342,12 +328,6 @@ void WayfireWindowList::init(Gtk::Box *container)
342328
return;
343329
}
344330

345-
#ifdef HAVE_DMABUF
346-
this->live_previews_dmabuf = this->dmabuf ? true : false;
347-
#else
348-
this->live_previews_dmabuf = false;
349-
#endif // HAVE_DMABUF
350-
351331
scrolled_window.add_css_class("window-list");
352332

353333
scrolled_window.set_hexpand(true);
@@ -472,9 +452,6 @@ void WayfireWindowList::handle_toplevel_closed(zwlr_foreign_toplevel_handle_v1 *
472452
toplevels.erase(toplevel);
473453
}
474454

475-
void WayfireWindowList::on_event(wf::json_t data)
476-
{}
477-
478455
WayfireWindowList::WayfireWindowList(WayfireOutput *output)
479456
{
480457
this->output = output;
@@ -494,9 +471,8 @@ WayfireWindowList::~WayfireWindowList()
494471
* when the window-list widget is unloaded. */
495472
toplevels.clear();
496473

497-
wl_shm_destroy(this->shm);
498474
zwlr_foreign_toplevel_manager_v1_destroy(this->manager);
499-
#ifdef HAVE_DMABUF
475+
500476
if (this->dmabuf)
501477
{
502478
zwp_linux_dmabuf_v1_destroy(this->dmabuf);
@@ -511,6 +487,4 @@ WayfireWindowList::~WayfireWindowList()
511487
{
512488
gbm_device_destroy(this->dmabuf_device);
513489
}
514-
515-
#endif
516490
}

src/panel/widgets/window-list/window-list.hpp

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ struct WayfireListToplevel
1919

2020
class WayfireToplevel;
2121

22-
class WayfireWindowList : public Gtk::Box, public WayfireWidget, public IIPCSubscriber
22+
class WayfireWindowList : public Gtk::Box, public WayfireWidget
2323
{
2424
WfOption<int> user_size{"panel/window_list_size"};
2525
std::shared_ptr<WayfireWindowListLayout> layout;
@@ -31,7 +31,6 @@ class WayfireWindowList : public Gtk::Box, public WayfireWidget, public IIPCSubs
3131
std::unique_ptr<WayfireListToplevel>> list_toplevels;
3232

3333
wl_display *display;
34-
wl_shm *shm = nullptr;
3534
zwlr_foreign_toplevel_manager_v1 *manager = NULL;
3635
ext_foreign_toplevel_list_v1 *foreign_toplevel_list = NULL;
3736
ext_image_copy_capture_manager_v1 *copy_capture_manager = NULL;
@@ -84,21 +83,12 @@ class WayfireWindowList : public Gtk::Box, public WayfireWidget, public IIPCSubs
8483
*/
8584
Gtk::Widget *get_widget_before(int x);
8685

87-
WfOption<bool> live_window_previews_opt{"panel/live_window_previews"};
86+
WfOption<bool> live_window_previews{"panel/live_window_previews"};
8887
void handle_new_wl_output(wl_output *output);
89-
void on_event(wf::json_t data) override;
90-
std::shared_ptr<IPCClient> ipc_client;
91-
bool normal_title_tooltips = false;
92-
void enable_normal_tooltips_flag(bool enable);
93-
uint64_t live_window_preview_view_id = 0;
94-
void enable_ipc(bool enable);
95-
bool live_previews_dmabuf = true;
9688

97-
#ifdef HAVE_DMABUF
9889
zwp_linux_dmabuf_feedback_v1 *feedback = nullptr;
9990
zwp_linux_dmabuf_v1 *dmabuf = nullptr;
10091
gbm_device *dmabuf_device = nullptr;
101-
#endif // HAVE_DMABUF
10292

10393
private:
10494
int get_default_button_width();

0 commit comments

Comments
 (0)