diff --git a/src/background-view.cpp b/src/background-view.cpp index aba056f..81f8e6e 100644 --- a/src/background-view.cpp +++ b/src/background-view.cpp @@ -24,11 +24,14 @@ #include #include +#include +#include +#include #include #include #include #include -#include +#include #include #include #include @@ -129,18 +132,14 @@ class wayfire_background_view : public wf::per_output_plugin_instance_t, } views[output].view = nullptr; - wf::get_core().run(std::string( command) + add_arg_if_not_empty(file)); }; - void set_view_for_output(wayfire_view view, wf::output_t *o) + void set_view_for_output(wayfire_toplevel_view view, wf::output_t *o) { - /* Get rid of decorations */ - view->set_decoration(nullptr); - /* Move to the respective output */ - wf::get_core().move_view_to_output(view, o, false); + wf::move_view_to_output(view, o, false); /* A client should be used that can be resized to any size. * If we set it fullscreen, the screensaver would be inhibited @@ -149,12 +148,10 @@ class wayfire_background_view : public wf::per_output_plugin_instance_t, view->set_geometry(o->get_relative_geometry()); /* Set it as the background */ - o->workspace->add_view(view, wf::LAYER_BACKGROUND); + view->get_wset()->remove_view(view); + wf::scene::readd_front(o->node_for_layer(wf::scene::layer::BACKGROUND), view->get_root_node()); - /* Make it show on all workspaces */ - view->sticky = true; - - /* Set role */ + /* Make it show on all workspaces in Expo, Cube, etc. */ view->role = wf::VIEW_ROLE_DESKTOP_ENVIRONMENT; /* Remember to close it later */ @@ -180,7 +177,7 @@ class wayfire_background_view : public wf::per_output_plugin_instance_t, wf::signal::connection_t view_mapped{[this] (wf::view_mapped_signal *ev) { - auto view = ev->view; + auto view = wf::toplevel_cast(ev->view); if (!view) { diff --git a/src/force-fullscreen.cpp b/src/force-fullscreen.cpp index 4860111..66508d2 100644 --- a/src/force-fullscreen.cpp +++ b/src/force-fullscreen.cpp @@ -27,13 +27,15 @@ #include #include #include +#include #include #include -#include +#include #include #include #include #include +#include namespace wf { @@ -50,7 +52,7 @@ class simple_node_render_instance_t : public render_instance_t }; node_t *self; - wayfire_view view; + wayfire_toplevel_view view; damage_callback push_to_parent; int *x, *y, *w, *h; wf::option_wrapper_t transparent_behind_views{ @@ -58,7 +60,7 @@ class simple_node_render_instance_t : public render_instance_t public: simple_node_render_instance_t(node_t *self, damage_callback push_damage, - wayfire_view view, int *x, int *y, int *w, int *h) + wayfire_toplevel_view view, int *x, int *y, int *w, int *h) { this->x = x; this->y = y; @@ -116,12 +118,12 @@ class simple_node_render_instance_t : public render_instance_t class black_border_node_t : public node_t { - wayfire_view view; + wayfire_toplevel_view view; public: int x, y, w, h; - black_border_node_t(wayfire_view view, int x, int y, int w, + black_border_node_t(wayfire_toplevel_view view, int x, int y, int w, int h) : node_t(false) { this->x = x; @@ -159,7 +161,7 @@ class fullscreen_background bool black_border = false; wlr_box transformed_view_box; - fullscreen_background(wayfire_view view) + fullscreen_background(wayfire_toplevel_view view) {} ~fullscreen_background() @@ -175,7 +177,7 @@ class wayfire_force_fullscreen : public wf::per_output_plugin_instance_t { std::string background_name; bool motion_connected = false; - std::map> backgrounds; + std::map> backgrounds; wf::option_wrapper_t preserve_aspect{"force-fullscreen/preserve_aspect"}; wf::option_wrapper_t constrain_pointer{"force-fullscreen/constrain_pointer"}; wf::option_wrapper_t constraint_area{ @@ -212,7 +214,7 @@ class wayfire_force_fullscreen : public wf::per_output_plugin_instance_t for (auto& b : backgrounds) { int w = (og.width - b.second->transformed_view_box.width) / 2.0f; - auto ws = output->workspace->get_view_main_workspace(b.first); + auto ws = output->wset()->get_view_main_workspace(b.first); auto offset = ws - nvp; int x = offset.x * og.width; int y = offset.y * og.height; @@ -229,7 +231,7 @@ class wayfire_force_fullscreen : public wf::per_output_plugin_instance_t } }; - void ensure_subsurface(wayfire_view view, wlr_box transformed_view_box) + void ensure_subsurface(wayfire_toplevel_view view, wlr_box transformed_view_box) { auto pair = backgrounds.find(view); @@ -257,7 +259,7 @@ class wayfire_force_fullscreen : public wf::per_output_plugin_instance_t } } - void destroy_subsurface(wayfire_view view) + void destroy_subsurface(wayfire_toplevel_view view) { auto pair = backgrounds.find(view); @@ -275,10 +277,10 @@ class wayfire_force_fullscreen : public wf::per_output_plugin_instance_t } } - void setup_transform(wayfire_view view) + void setup_transform(wayfire_toplevel_view view) { auto og = output->get_relative_geometry(); - auto vg = view->get_wm_geometry(); + auto vg = view->get_geometry(); double scale_x = (double)og.width / vg.width; double scale_y = (double)og.height / vg.height; @@ -324,21 +326,22 @@ class wayfire_force_fullscreen : public wf::per_output_plugin_instance_t } } - bool toggle_fullscreen(wayfire_view view) + bool toggle_fullscreen(wayfire_toplevel_view view) { if (!output->can_activate_plugin(&grab_interface)) { return false; } - wlr_box saved_geometry = view->get_wm_geometry(); + wlr_box saved_geometry = view->get_geometry(); auto background = backgrounds.find(view); bool fullscreen = background == backgrounds.end() ? true : false; - view->set_fullscreen(fullscreen); + view->toplevel()->pending().fullscreen = fullscreen; + wf::get_core().tx_manager->schedule_object(view->toplevel()); - wlr_box undecorated_geometry = view->get_wm_geometry(); + wlr_box undecorated_geometry = view->get_geometry(); if (!fullscreen) { @@ -368,7 +371,7 @@ class wayfire_force_fullscreen : public wf::per_output_plugin_instance_t wf::key_callback on_toggle_fullscreen = [=] (auto) { - auto view = output->get_active_view(); + auto view = wf::toplevel_cast(output->get_active_view()); if (!view || (view->role == wf::VIEW_ROLE_DESKTOP_ENVIRONMENT)) { @@ -378,7 +381,7 @@ class wayfire_force_fullscreen : public wf::per_output_plugin_instance_t return toggle_fullscreen(view); }; - void activate(wayfire_view view) + void activate(wayfire_toplevel_view view) { view->move(0, 0); backgrounds[view] = std::make_unique(view); @@ -399,7 +402,7 @@ class wayfire_force_fullscreen : public wf::per_output_plugin_instance_t } } - void deactivate(wayfire_view view) + void deactivate(wayfire_toplevel_view view) { auto background = backgrounds.find(view); @@ -455,7 +458,7 @@ class wayfire_force_fullscreen : public wf::per_output_plugin_instance_t motion_connected = false; } - void update_motion_signal(wayfire_view view) + void update_motion_signal(wayfire_toplevel_view view) { if (view && (view->get_output() == output) && constrain_pointer && (backgrounds.find(view) != backgrounds.end())) @@ -471,8 +474,7 @@ class wayfire_force_fullscreen : public wf::per_output_plugin_instance_t wf::config::option_base_t::updated_callback_t constrain_pointer_option_changed = [=] () { - auto view = output->get_active_view(); - + auto view = wf::toplevel_cast(output->get_active_view()); update_motion_signal(view); }; @@ -548,9 +550,9 @@ class wayfire_force_fullscreen : public wf::per_output_plugin_instance_t } }; - wf::signal::connection_t view_output_changed{[this] (wf:: - view_pre_moved_to_output_signal - *ev) + wf::signal::connection_t view_output_changed{[this] (wf:: + view_pre_moved_to_wset_signal + *ev) { auto view = ev->view; auto background = backgrounds.find(view); @@ -560,24 +562,28 @@ class wayfire_force_fullscreen : public wf::per_output_plugin_instance_t return; } + if (!ev->new_wset->get_attached_output()) + { + return; + } + toggle_fullscreen(view); - auto instance = wayfire_force_fullscreen_instances[ev->new_output]; + auto instance = wayfire_force_fullscreen_instances[ev->new_wset->get_attached_output()]; instance->toggle_fullscreen(view); } }; wf::signal::connection_t view_focused{[this] (wf::focus_view_signal *ev) { - auto view = ev->view; - + auto view = toplevel_cast(ev->view); update_motion_signal(view); } }; wf::signal::connection_t view_unmapped{[this] (wf::view_unmapped_signal *ev) { - auto view = ev->view; + auto view = toplevel_cast(ev->view); auto background = backgrounds.find(view); if (background == backgrounds.end()) diff --git a/src/meson.build b/src/meson.build index d596a13..6177a49 100644 --- a/src/meson.build +++ b/src/meson.build @@ -8,9 +8,9 @@ autorotate = shared_module('autorotate-iio', 'autorotate-iio.cpp', install: true, install_dir: join_paths(get_option('libdir'), 'wayfire')) endif -#background_view = shared_module('background-view', 'background-view.cpp', -# dependencies: [wayfire], -# install: true, install_dir: join_paths(get_option('libdir'), 'wayfire')) +background_view = shared_module('background-view', 'background-view.cpp', + dependencies: [wayfire], + install: true, install_dir: join_paths(get_option('libdir'), 'wayfire')) benchmark = shared_module('bench', 'bench.cpp', dependencies: [wayfire], @@ -28,9 +28,9 @@ follow_focus = shared_module('follow-focus', 'follow-focus.cpp', dependencies: [wayfire], install: true, install_dir: join_paths(get_option('libdir'), 'wayfire')) -#force_fullscreen = shared_module('force-fullscreen', 'force-fullscreen.cpp', -# dependencies: [wayfire], -# install: true, install_dir: join_paths(get_option('libdir'), 'wayfire')) +force_fullscreen = shared_module('force-fullscreen', 'force-fullscreen.cpp', + dependencies: [wayfire], + install: true, install_dir: join_paths(get_option('libdir'), 'wayfire')) if giomm.found() glib_main_loop = shared_module('glib-main-loop', 'glib-main-loop.cpp',