Skip to content

Commit 1ebc4e0

Browse files
triggsoreau
andauthored
xdpw: added a screencast chooser (#396)
* xdpw: added a screencast chooser * xdpw: output screenshots * xdpw: toplevel screenshots (by @soreau) --------- Co-authored-by: Scott Moreau <oreaus@gmail.com>
1 parent f8d1c42 commit 1ebc4e0

15 files changed

Lines changed: 1322 additions & 12 deletions

data/meson.build

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,6 @@ install_data(join_paths('icons', 'scalable', 'wayfire.svg'), install_dir: join_p
1515

1616
install_data('wf-locker', install_dir:'/etc/pam.d/')
1717

18+
install_data('xdpw/wayfire', install_dir: '/etc/xdg/xdg-desktop-portal-wlr/')
19+
1820
subdir('css')

data/xdpw/wayfire

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[screencast]
2+
chooser_cmd=wf-stream-chooser
3+
chooser_type=simple

proto/meson.build

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
wl_protocol_dir = wayland_protos.get_pkgconfig_variable('pkgdatadir')
2-
1+
wl_protocol_dir = wayland_protos.get_variable(pkgconfig: 'pkgdatadir', internal: 'pkgdatadir')
32
wayland_scanner = find_program('wayland-scanner')
43

54
wayland_scanner_code = generator(
@@ -15,25 +14,26 @@ wayland_scanner_client = generator(
1514
)
1615

1716
client_protocols = [
18-
'wlr-foreign-toplevel-management-unstable-v1.xml',
19-
'wlr-screencopy.xml',
20-
wayfire.get_pkgconfig_variable('pkgdatadir') / 'unstable' / 'wayfire-shell-unstable-v2.xml',
17+
[wl_protocol_dir, 'unstable/xdg-output/xdg-output-unstable-v1.xml'],
18+
[wl_protocol_dir, 'unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml'],
19+
[wl_protocol_dir, 'staging/ext-foreign-toplevel-list/ext-foreign-toplevel-list-v1.xml'],
20+
[wl_protocol_dir, 'staging/ext-image-capture-source/ext-image-capture-source-v1.xml'],
21+
[wl_protocol_dir, 'staging/ext-image-copy-capture/ext-image-copy-capture-v1.xml'],
22+
'wlr-foreign-toplevel-management-unstable-v1.xml',
23+
'wlr-screencopy.xml',
24+
wayfire.get_pkgconfig_variable('pkgdatadir') / 'unstable' / 'wayfire-shell-unstable-v2.xml',
2125
]
2226

23-
if gbm.found() and drm.found() and not get_option('live-previews-dmabuf').disabled()
24-
client_protocols += [join_paths(wl_protocol_dir, 'unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml')]
25-
endif
26-
27-
wl_protos_src = []
27+
wl_protos_client_src = []
2828
wl_protos_headers = []
2929

3030
foreach p : client_protocols
3131
xml = join_paths(p)
32+
wl_protos_client_src += wayland_scanner_code.process(xml)
3233
wl_protos_headers += wayland_scanner_client.process(xml)
33-
wl_protos_src += wayland_scanner_code.process(xml)
3434
endforeach
3535

36-
lib_wl_protos = static_library('wl_protos', wl_protos_src + wl_protos_headers,
36+
lib_wl_protos = static_library('wl_protos', wl_protos_client_src + wl_protos_headers,
3737
dependencies: [wayland_client]) # for the include directory
3838

3939
wf_protos = declare_dependency(

src/meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ subdir('background')
44
subdir('dock')
55
subdir('locker')
66
subdir('locker-pin')
7+
subdir('stream-chooser')
78

89
pkgconfig = import('pkgconfig')
910
pkgconfig.generate(

src/stream-chooser/mainlayout.cpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#include "mainlayout.hpp"
2+
void MainLayout::allocate_vfunc(const Gtk::Widget& widget, int width, int height, int baseline)
3+
{
4+
Gtk::Widget& widget_not_const = const_cast<Gtk::Widget&>(widget);
5+
6+
auto inner = widget_not_const.get_children()[0];
7+
auto alloc = Gtk::Allocation();
8+
alloc.set_height(height / 2);
9+
alloc.set_width(width / 2);
10+
alloc.set_y(height / 4);
11+
alloc.set_x(width / 4);
12+
inner->size_allocate(alloc, -1);
13+
}
14+
15+
void MainLayout::measure_vfunc(const Gtk::Widget& widget, Gtk::Orientation orientation,
16+
int for_size, int& minimum, int& natural, int& minimum_baseline,
17+
int& natural_baseline) const
18+
{
19+
// Answer 1:1 aspect ratio
20+
minimum = std::min(for_size, 300);
21+
natural = std::min(for_size, 2000);
22+
minimum_baseline = -1;
23+
natural_baseline = -1;
24+
}
25+
26+
Gtk::SizeRequestMode MainLayout::get_request_mode_vfunc(const Gtk::Widget& widget) const
27+
{
28+
return Gtk::SizeRequestMode::WIDTH_FOR_HEIGHT;
29+
}

src/stream-chooser/mainlayout.hpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#pragma once
2+
3+
#include <gtkmm.h>
4+
#include <wf-option-wrap.hpp>
5+
6+
7+
class MainLayout : public Gtk::LayoutManager
8+
{
9+
protected:
10+
void allocate_vfunc(const Gtk::Widget& widget, int width, int height, int baseline) override;
11+
void measure_vfunc(const Gtk::Widget& widget, Gtk::Orientation orientation, int for_size, int& minimum,
12+
int& natural, int& minimum_baseline, int& natural_baseline) const override;
13+
Gtk::SizeRequestMode get_request_mode_vfunc(const Gtk::Widget& widget) const override;
14+
std::shared_ptr<Gtk::LayoutManager> layout;
15+
16+
public:
17+
MainLayout()
18+
{}
19+
};

src/stream-chooser/meson.build

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
deps = [
2+
gtkmm,
3+
wf_protos,
4+
wfconfig,
5+
libutil,
6+
gtklayershell,
7+
]
8+
9+
executable(
10+
'wf-stream-chooser',
11+
[
12+
'stream-chooser.cpp',
13+
'toplevelwidget.cpp',
14+
'outputwidget.cpp',
15+
'toplevellayout.cpp',
16+
'mainlayout.cpp',
17+
],
18+
dependencies: deps,
19+
install: true,
20+
)

0 commit comments

Comments
 (0)