Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/stream-chooser/mainlayout.cpp
Original file line number Diff line number Diff line change
@@ -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<Gtk::Widget&>(widget);
Expand All @@ -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,
Expand Down
15 changes: 13 additions & 2 deletions src/stream-chooser/outputwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,16 @@ WayfireChooserOutput::WayfireChooserOutput(std::shared_ptr<Gdk::Monitor> 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<output_buffer>();

Expand Down Expand Up @@ -233,6 +239,11 @@ WayfireChooserOutput::~WayfireChooserOutput()
{
zwp_linux_buffer_params_v1_destroy(buffer->params);
}

for (auto signal : signals)
{
signal.disconnect();
}
}

void WayfireChooserOutput::print()
Expand Down
1 change: 1 addition & 0 deletions src/stream-chooser/outputwidget.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class WayfireChooserOutput : public Gtk::Box
{
Gtk::Label connector, model;
Gtk::Picture contents;
std::vector<sigc::connection> signals;

wl_output *output_handle;
std::shared_ptr<Gdk::Monitor> output;
Expand Down
10 changes: 10 additions & 0 deletions src/stream-chooser/stream-chooser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
7 changes: 7 additions & 0 deletions src/stream-chooser/stream-chooser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#include "outputwidget.hpp"
#include "toplevelwidget.hpp"

using type_signal_resize = sigc::signal<void (int, int)>;


class WayfireStreamChooserApp : public Gtk::Application
{
Expand All @@ -28,6 +30,8 @@ class WayfireStreamChooserApp : public Gtk::Application
ext_foreign_toplevel_list_v1 *list;
Glib::RefPtr<MainLayout> layout;

type_signal_resize resized_signal;

public:
wl_display *display;
bool is_in_use = false;
Expand Down Expand Up @@ -77,4 +81,7 @@ class WayfireStreamChooserApp : public Gtk::Application
close(drm_fd);
}
}

type_signal_resize signal_resize();
void resize(int width, int height);
};
11 changes: 11 additions & 0 deletions src/stream-chooser/toplevelwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,12 @@ WayfireChooserTopLevel::WayfireChooserTopLevel(ext_foreign_toplevel_handle_v1 *h

buffer = std::make_shared<toplevel_buffer>();

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);
Expand Down Expand Up @@ -418,6 +424,11 @@ WayfireChooserTopLevel::~WayfireChooserTopLevel()
{
zwp_linux_buffer_params_v1_destroy(buffer->params);
}

for (auto signal : signals)
{
signal.disconnect();
}
}

void WayfireChooserTopLevel::print()
Expand Down
2 changes: 2 additions & 0 deletions src/stream-chooser/toplevelwidget.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include <gbm.h>
#include <gtkmm.h>
#include <memory>
#include <vector>
#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"
Expand All @@ -21,6 +22,7 @@ struct toplevel_buffer
class WayfireChooserTopLevel : public Gtk::Box
{
private:
std::vector<sigc::connection> signals;
Gtk::Overlay overlay;
Gtk::Image icon;
Gtk::Label label;
Expand Down
Loading