Skip to content

Commit 29a0a5a

Browse files
soreautrigg
authored andcommitted
stream-chooser: Implement stream/pause for outputs as well
1 parent 8396773 commit 29a0a5a

2 files changed

Lines changed: 81 additions & 1 deletion

File tree

src/stream-chooser/outputwidget.cpp

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,16 @@ void WayfireChooserOutput::start_output_source_ssession()
179179
ext_image_copy_capture_session_v1_add_listener(recording_session, &recording_session_listener, this);
180180
}
181181

182+
void WayfireChooserOutput::stream()
183+
{
184+
streaming = true;
185+
}
186+
187+
void WayfireChooserOutput::pause()
188+
{
189+
streaming = false;
190+
}
191+
182192
WayfireChooserOutput::WayfireChooserOutput(std::shared_ptr<Gdk::Monitor> output) : output(output)
183193
{
184194
append(contents);
@@ -208,6 +218,66 @@ WayfireChooserOutput::WayfireChooserOutput(std::shared_ptr<Gdk::Monitor> output)
208218
buffer = std::make_shared<output_buffer>();
209219

210220
start_output_source_ssession();
221+
222+
initial_timeout = Glib::signal_timeout().connect(
223+
[this] ()
224+
{
225+
this->pause();
226+
return G_SOURCE_REMOVE;
227+
}, 2000);
228+
229+
signals.push_back(
230+
WayfireStreamChooserApp::getInstance().screen_list.signal_selected_children_changed().connect(
231+
[=] ()
232+
{
233+
if (WayfireStreamChooserApp::getInstance().screen_list.get_selected_children()[0]->get_children()[0]
234+
==
235+
this)
236+
{
237+
this->initial_timeout.disconnect();
238+
this->pause_timeout.disconnect();
239+
this->stream();
240+
return;
241+
}
242+
243+
this->pause_timeout.disconnect();
244+
this->pause_timeout = Glib::signal_timeout().connect(
245+
[this] ()
246+
{
247+
this->pause();
248+
return G_SOURCE_REMOVE;
249+
}, 2000);
250+
}));
251+
252+
auto motion_controller = Gtk::EventControllerMotion::create();
253+
signals.push_back(motion_controller->signal_enter().connect(
254+
[this] (double, double)
255+
{
256+
this->initial_timeout.disconnect();
257+
this->pause_timeout.disconnect();
258+
this->stream();
259+
}));
260+
add_controller(motion_controller);
261+
262+
motion_controller = Gtk::EventControllerMotion::create();
263+
signals.push_back(motion_controller->signal_leave().connect(
264+
[this] ()
265+
{
266+
this->pause_timeout.disconnect();
267+
this->pause_timeout = Glib::signal_timeout().connect(
268+
[this] ()
269+
{
270+
if (WayfireStreamChooserApp::getInstance().screen_list.get_selected_children()[0]->get_children()[
271+
0] == this)
272+
{
273+
return G_SOURCE_REMOVE;
274+
}
275+
276+
this->pause();
277+
return G_SOURCE_REMOVE;
278+
}, 2000);
279+
}));
280+
add_controller(motion_controller);
211281
}
212282

213283
WayfireChooserOutput::~WayfireChooserOutput()
@@ -251,6 +321,11 @@ void WayfireChooserOutput::print()
251321

252322
void WayfireChooserOutput::frame_request()
253323
{
324+
if (!streaming)
325+
{
326+
return;
327+
}
328+
254329
if ((current_buffer_width <= 0) || (current_buffer_height <= 0))
255330
{
256331
printf("%s invalid size\n", __func__);

src/stream-chooser/outputwidget.hpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,14 @@ class WayfireChooserOutput : public Gtk::Box
2929
ext_image_capture_source_v1 *copy_capture_source = NULL;
3030
void start_output_source_ssession();
3131

32+
void pause();
33+
void stream();
34+
bool streaming = true;
35+
sigc::connection pause_timeout, initial_timeout;
36+
3237
public:
3338
ext_image_copy_capture_session_v1 *recording_session = NULL;
34-
std::shared_ptr<output_buffer> buffer = nullptr;
39+
std::shared_ptr<output_buffer> buffer = nullptr;
3540
ext_image_copy_capture_frame_v1 *frame = NULL;
3641
bool frame_in_flight = false;
3742
void print();

0 commit comments

Comments
 (0)