Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update remaining plugins for wayfire-git #182

Merged
merged 3 commits into from
Jul 31, 2023
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
23 changes: 10 additions & 13 deletions src/background-view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,14 @@

#include <signal.h>
#include <wayfire/core.hpp>
#include <wayfire/scene-operations.hpp>
#include <wayfire/scene.hpp>
#include <wayfire/toplevel-view.hpp>
#include <wayfire/view.hpp>
#include <wayfire/plugin.hpp>
#include <wayfire/output.hpp>
#include <wayfire/signal-definitions.hpp>
#include <wayfire/workspace-manager.hpp>
#include <wayfire/workspace-set.hpp>
#include <wayfire/output-layout.hpp>
#include <wayfire/per-output-plugin.hpp>
#include <wayfire/plugins/common/input-grab.hpp>
Expand Down Expand Up @@ -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
Expand All @@ -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 */
Expand All @@ -180,7 +177,7 @@ class wayfire_background_view : public wf::per_output_plugin_instance_t,

wf::signal::connection_t<wf::view_mapped_signal> view_mapped{[this] (wf::view_mapped_signal *ev)
{
auto view = ev->view;
auto view = wf::toplevel_cast(ev->view);

if (!view)
{
Expand Down
64 changes: 35 additions & 29 deletions src/force-fullscreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,15 @@
#include <wayfire/core.hpp>
#include <wayfire/plugin.hpp>
#include <wayfire/output.hpp>
#include <wayfire/toplevel-view.hpp>
#include <wayfire/view-transform.hpp>
#include <wayfire/compositor-view.hpp>
#include <wayfire/workspace-manager.hpp>
#include <wayfire/workspace-set.hpp>
#include <wayfire/signal-definitions.hpp>
#include <wayfire/scene-operations.hpp>
#include <wayfire/render-manager.hpp>
#include <wayfire/per-output-plugin.hpp>
#include <wayfire/txn/transaction-manager.hpp>

namespace wf
{
Expand All @@ -50,15 +52,15 @@ 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<bool> transparent_behind_views{
"force-fullscreen/transparent_behind_views"};

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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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()
Expand All @@ -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<wayfire_view, std::unique_ptr<fullscreen_background>> backgrounds;
std::map<wayfire_toplevel_view, std::unique_ptr<fullscreen_background>> backgrounds;
wf::option_wrapper_t<bool> preserve_aspect{"force-fullscreen/preserve_aspect"};
wf::option_wrapper_t<bool> constrain_pointer{"force-fullscreen/constrain_pointer"};
wf::option_wrapper_t<std::string> constraint_area{
Expand Down Expand Up @@ -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;
Expand All @@ -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);

Expand Down Expand Up @@ -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);

Expand All @@ -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;
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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))
{
Expand All @@ -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<fullscreen_background>(view);
Expand All @@ -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);

Expand Down Expand Up @@ -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()))
Expand All @@ -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);
};

Expand Down Expand Up @@ -548,9 +550,9 @@ class wayfire_force_fullscreen : public wf::per_output_plugin_instance_t
}
};

wf::signal::connection_t<wf::view_pre_moved_to_output_signal> view_output_changed{[this] (wf::
view_pre_moved_to_output_signal
*ev)
wf::signal::connection_t<wf::view_pre_moved_to_wset_signal> view_output_changed{[this] (wf::
view_pre_moved_to_wset_signal
*ev)
{
auto view = ev->view;
auto background = backgrounds.find(view);
Expand All @@ -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<wf::focus_view_signal> 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<wf::view_unmapped_signal> 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())
Expand Down
12 changes: 6 additions & 6 deletions src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand All @@ -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',
Expand Down
Loading