@@ -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+
182192WayfireChooserOutput::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
213283WayfireChooserOutput::~WayfireChooserOutput ()
@@ -251,6 +321,11 @@ void WayfireChooserOutput::print()
251321
252322void 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__);
0 commit comments