Skip to content

Commit 977e201

Browse files
soreautrigg
authored andcommitted
stream-chooser: Select output tab if no toplevels found
1 parent cf2b179 commit 977e201

2 files changed

Lines changed: 18 additions & 12 deletions

File tree

src/stream-chooser/stream-chooser.cpp

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@ static void registry_add_object(void *data, wl_registry *registry, uint32_t name
124124
WayfireStreamChooserApp::getInstance().set_toplevel_list(list);
125125
ext_foreign_toplevel_list_v1_add_listener(list,
126126
&toplevel_list_v1_impl, NULL);
127-
wl_display_flush(WayfireStreamChooserApp::getInstance().display);
128127
} else if (strcmp(interface, ext_image_copy_capture_manager_v1_interface.name) == 0)
129128
{
130129
auto manager = (ext_image_copy_capture_manager_v1*)wl_registry_bind(registry, name,
@@ -282,31 +281,24 @@ void WayfireStreamChooserApp::activate()
282281
wl_display_roundtrip(display);
283282
wl_registry_destroy(registry);
284283

285-
bool failed = false;
286284
if (!has_image_copy_capture)
287285
{
288-
failed = true;
289286
std::cerr << "Compositor has not advertised ext-image-copy-capture-v1" << std::endl;
290287
}
291288

292289
if (!has_foreign_toplevel_list)
293290
{
294-
failed = true;
295291
std::cerr << "Compositor has not advertised ext-foreign-toplevel-list-v1" << std::endl;
296292
}
297293

298294
if (!has_image_capture_source)
299295
{
300-
failed = true;
301296
std::cerr << "Compositor has not advertised ext-image-capture-source-v1" << std::endl;
302297
}
303298

304-
if (failed)
305-
{
306-
window_label.set_sensitive(false);
307-
window_label.set_tooltip_text("This compositor does not currently support sharing individual windows");
308-
notebook.set_current_page(1);
309-
}
299+
window_label.set_sensitive(false);
300+
window_label.set_tooltip_text("This compositor does not currently support sharing individual windows");
301+
notebook.set_current_page(1);
310302

311303
/* Get output list */
312304
auto gtkdisplay = Gdk::Display::get_default();
@@ -365,6 +357,7 @@ void WayfireStreamChooserApp::activate()
365357
window.present();
366358
}
367359

360+
static bool first_toplevel = true;
368361
void WayfireStreamChooserApp::add_toplevel(ext_foreign_toplevel_handle_v1 *handle)
369362
{
370363
toplevels.emplace(handle, new WayfireChooserTopLevel(handle));
@@ -374,6 +367,14 @@ void WayfireStreamChooserApp::add_toplevel(ext_foreign_toplevel_handle_v1 *handl
374367
auto child = window_list.get_child_at_index(0);
375368
window_list.select_child(*child);
376369
}
370+
371+
window_label.set_sensitive(true);
372+
window_label.set_tooltip_text("");
373+
if (first_toplevel)
374+
{
375+
first_toplevel = false;
376+
notebook.set_current_page(0);
377+
}
377378
}
378379

379380
void WayfireStreamChooserApp::remove_toplevel(WayfireChooserTopLevel *toplevel)
@@ -385,6 +386,11 @@ void WayfireStreamChooserApp::remove_toplevel(WayfireChooserTopLevel *toplevel)
385386

386387
window_list.remove(*toplevel);
387388
toplevels.erase(toplevel->handle);
389+
if (toplevels.empty())
390+
{
391+
window_label.set_sensitive(false);
392+
window_label.set_tooltip_text("No windows open");
393+
}
388394
}
389395

390396
void WayfireStreamChooserApp::add_output(std::shared_ptr<Gdk::Monitor> monitor)

src/stream-chooser/stream-chooser.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ using type_signal_resize = sigc::signal<void (int, int)>;
1515
class WayfireStreamChooserApp : public Gtk::Application
1616
{
1717
private:
18+
wl_display *display;
1819
Gtk::Window window;
1920

2021
Gtk::Box main, buttons;
@@ -31,7 +32,6 @@ class WayfireStreamChooserApp : public Gtk::Application
3132
type_signal_resize resized_signal;
3233

3334
public:
34-
wl_display *display;
3535
Gtk::Notebook notebook;
3636
Gtk::FlowBox window_list, screen_list;
3737
bool has_foreign_toplevel_list = false;

0 commit comments

Comments
 (0)