From 45a14c47ffbba0f9e26e9e6ebb5bb6aa07de6cd6 Mon Sep 17 00:00:00 2001 From: trigg Date: Mon, 8 Jun 2026 11:01:49 +0100 Subject: [PATCH] xdpw: stream chooser signal resizes to widgets --- src/stream-chooser/mainlayout.cpp | 3 +++ src/stream-chooser/outputwidget.cpp | 15 +++++++++++++-- src/stream-chooser/outputwidget.hpp | 1 + src/stream-chooser/stream-chooser.cpp | 10 ++++++++++ src/stream-chooser/stream-chooser.hpp | 7 +++++++ src/stream-chooser/toplevelwidget.cpp | 11 +++++++++++ src/stream-chooser/toplevelwidget.hpp | 2 ++ 7 files changed, 47 insertions(+), 2 deletions(-) diff --git a/src/stream-chooser/mainlayout.cpp b/src/stream-chooser/mainlayout.cpp index 9e62ca32..eb863ade 100644 --- a/src/stream-chooser/mainlayout.cpp +++ b/src/stream-chooser/mainlayout.cpp @@ -1,4 +1,5 @@ #include "mainlayout.hpp" +#include "stream-chooser.hpp" void MainLayout::allocate_vfunc(const Gtk::Widget& widget, int width, int height, int baseline) { Gtk::Widget& widget_not_const = const_cast(widget); @@ -10,6 +11,8 @@ void MainLayout::allocate_vfunc(const Gtk::Widget& widget, int width, int height alloc.set_y(height / 4); alloc.set_x(width / 4); inner->size_allocate(alloc, -1); + + WayfireStreamChooserApp::getInstance().resize(width, height); } void MainLayout::measure_vfunc(const Gtk::Widget& widget, Gtk::Orientation orientation, diff --git a/src/stream-chooser/outputwidget.cpp b/src/stream-chooser/outputwidget.cpp index 174bf0f0..95cdb0cf 100644 --- a/src/stream-chooser/outputwidget.cpp +++ b/src/stream-chooser/outputwidget.cpp @@ -197,10 +197,16 @@ WayfireChooserOutput::WayfireChooserOutput(std::shared_ptr output) set_orientation(Gtk::Orientation::VERTICAL); - output->signal_invalidate().connect([=] + signals.push_back(output->signal_invalidate().connect([=] { WayfireStreamChooserApp::getInstance().remove_output(output->get_connector()); - }); + })); + + signals.push_back(WayfireStreamChooserApp::getInstance().signal_resize().connect( + [=] (int width, int height) + { + std::cout << "Entire width " << width << " height " << height << std::endl; + })); buffer = std::make_shared(); @@ -233,6 +239,11 @@ WayfireChooserOutput::~WayfireChooserOutput() { zwp_linux_buffer_params_v1_destroy(buffer->params); } + + for (auto signal : signals) + { + signal.disconnect(); + } } void WayfireChooserOutput::print() diff --git a/src/stream-chooser/outputwidget.hpp b/src/stream-chooser/outputwidget.hpp index 4f61ef92..bf90c0dd 100644 --- a/src/stream-chooser/outputwidget.hpp +++ b/src/stream-chooser/outputwidget.hpp @@ -22,6 +22,7 @@ class WayfireChooserOutput : public Gtk::Box { Gtk::Label connector, model; Gtk::Picture contents; + std::vector signals; wl_output *output_handle; std::shared_ptr output; diff --git a/src/stream-chooser/stream-chooser.cpp b/src/stream-chooser/stream-chooser.cpp index e7535784..fbfb3fd6 100644 --- a/src/stream-chooser/stream-chooser.cpp +++ b/src/stream-chooser/stream-chooser.cpp @@ -429,6 +429,16 @@ void WayfireStreamChooserApp::set_output_capture_manager( this->output_capture_manager = output_capture_manager; } +type_signal_resize WayfireStreamChooserApp::signal_resize() +{ + return resized_signal; +} + +void WayfireStreamChooserApp::resize(int width, int height) +{ + resized_signal.emit(width, height); +} + /* Starting point */ int main(int argc, char **argv) { diff --git a/src/stream-chooser/stream-chooser.hpp b/src/stream-chooser/stream-chooser.hpp index 54f3595f..1ae485b7 100644 --- a/src/stream-chooser/stream-chooser.hpp +++ b/src/stream-chooser/stream-chooser.hpp @@ -9,6 +9,8 @@ #include "outputwidget.hpp" #include "toplevelwidget.hpp" +using type_signal_resize = sigc::signal; + class WayfireStreamChooserApp : public Gtk::Application { @@ -28,6 +30,8 @@ class WayfireStreamChooserApp : public Gtk::Application ext_foreign_toplevel_list_v1 *list; Glib::RefPtr layout; + type_signal_resize resized_signal; + public: wl_display *display; bool is_in_use = false; @@ -77,4 +81,7 @@ class WayfireStreamChooserApp : public Gtk::Application close(drm_fd); } } + + type_signal_resize signal_resize(); + void resize(int width, int height); }; diff --git a/src/stream-chooser/toplevelwidget.cpp b/src/stream-chooser/toplevelwidget.cpp index 9a33022d..9963d21e 100644 --- a/src/stream-chooser/toplevelwidget.cpp +++ b/src/stream-chooser/toplevelwidget.cpp @@ -349,6 +349,12 @@ WayfireChooserTopLevel::WayfireChooserTopLevel(ext_foreign_toplevel_handle_v1 *h buffer = std::make_shared(); + signals.push_back(WayfireStreamChooserApp::getInstance().signal_resize().connect( + [=] (int width, int height) + { + std::cout << "Entire width " << width << " height " << height << std::endl; + })); + start_toplevel_source_ssession(); ext_foreign_toplevel_handle_v1_add_listener(handle, &listener, this); @@ -418,6 +424,11 @@ WayfireChooserTopLevel::~WayfireChooserTopLevel() { zwp_linux_buffer_params_v1_destroy(buffer->params); } + + for (auto signal : signals) + { + signal.disconnect(); + } } void WayfireChooserTopLevel::print() diff --git a/src/stream-chooser/toplevelwidget.hpp b/src/stream-chooser/toplevelwidget.hpp index 46115f32..ace805e3 100644 --- a/src/stream-chooser/toplevelwidget.hpp +++ b/src/stream-chooser/toplevelwidget.hpp @@ -2,6 +2,7 @@ #include #include #include +#include #include "ext-foreign-toplevel-list-v1-client-protocol.h" #include "ext-image-copy-capture-v1-client-protocol.h" #include "linux-dmabuf-unstable-v1-client-protocol.h" @@ -21,6 +22,7 @@ struct toplevel_buffer class WayfireChooserTopLevel : public Gtk::Box { private: + std::vector signals; Gtk::Overlay overlay; Gtk::Image icon; Gtk::Label label;