-
Notifications
You must be signed in to change notification settings - Fork 179
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement the session lock protocol (#2162)
* Make wlr_{surface,subsurface}_controller_t common utilities. These classes are useful and needed by any code that deals with surfaces, because such code usually needs to deal with subsurfaces as well. Move the include files into api/wayfire/unstable so they can be used by code all over the tree, and rename them to reflect the utility classes that they contain. * Add a public API to inhibit/uninhibit outputs. This will allow lockscreens to be implemented in plugins. * Factor the text label rendering out of wset into a utility class. This adds a simple node that can display text. * Add a LOCK scenegraph layer. This will be used by the upcoming implementation of the ext-session-lock protocol. * Implement the session lock protocol Currently implemented: - Locking and unlocking. - Display above all desktop layers, including OVERLAY (but below DWIDGET). - Waiting for the client to display locked surfaces before declaring the screen to be locked. If the client does not display all surfaces, locks anyway after a timeout. - Multiple outputs, including outputs being added/removed while locking or locked. - Leaving the screen locked if the client crashes (but allows a new client to come in and lock the screen). TODO: - Deal with outputs being resized. - Properly display text if the screenlocker crashes. Currently it just displays two a big "explosion" emoji. - Use a view instead of a plain wlr_surface_node? Tested with swaylock. Fixes #1494 Fixes #1358
- Loading branch information
Showing
28 changed files
with
561 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0"?> | ||
<wayfire> | ||
<plugin name="session-lock"> | ||
<_short>Session Lock Protocol</_short> | ||
<_long>An implementation of the ext-session-lock-v1 protocol. Provides more secure screen locking.</_long> | ||
<category>Utility</category> | ||
</plugin> | ||
</wayfire> |
72 changes: 72 additions & 0 deletions
72
plugins/common/wayfire/plugins/common/simple-text-node.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
#include "wayfire/opengl.hpp" | ||
#include "wayfire/output.hpp" | ||
#include "wayfire/scene.hpp" | ||
#include <wayfire/plugins/common/cairo-util.hpp> | ||
|
||
class simple_text_node_t : public wf::scene::node_t | ||
{ | ||
class render_instance_t : public wf::scene::simple_render_instance_t<simple_text_node_t> | ||
{ | ||
public: | ||
using simple_render_instance_t::simple_render_instance_t; | ||
|
||
void render(const wf::render_target_t& target, const wf::region_t& region) | ||
{ | ||
OpenGL::render_begin(target); | ||
|
||
auto g = self->get_bounding_box(); | ||
for (auto box : region) | ||
{ | ||
target.logic_scissor(wlr_box_from_pixman_box(box)); | ||
OpenGL::render_texture(self->cr_text.tex.tex, target, g, glm::vec4(1.0f), | ||
OpenGL::TEXTURE_TRANSFORM_INVERT_Y); | ||
} | ||
|
||
OpenGL::render_end(); | ||
} | ||
}; | ||
|
||
wf::cairo_text_t cr_text; | ||
|
||
public: | ||
simple_text_node_t() : node_t(false) | ||
{} | ||
|
||
void gen_render_instances(std::vector<wf::scene::render_instance_uptr>& instances, | ||
wf::scene::damage_callback push_damage, wf::output_t *output) override | ||
{ | ||
instances.push_back(std::make_unique<render_instance_t>(this, push_damage, output)); | ||
} | ||
|
||
wf::geometry_t get_bounding_box() override | ||
{ | ||
return wf::construct_box(position, size.value_or(cr_text.get_size())); | ||
} | ||
|
||
void set_position(wf::point_t position) | ||
{ | ||
this->position = position; | ||
} | ||
|
||
void set_size(wf::dimensions_t size) | ||
{ | ||
this->size = size; | ||
} | ||
|
||
void set_text_params(wf::cairo_text_t::params params) | ||
{ | ||
this->params = params; | ||
} | ||
|
||
void set_text(std::string text) | ||
{ | ||
wf::scene::damage_node(this->shared_from_this(), get_bounding_box()); | ||
cr_text.render_text(text, params); | ||
wf::scene::damage_node(this->shared_from_this(), get_bounding_box()); | ||
} | ||
|
||
private: | ||
wf::cairo_text_t::params params; | ||
std::optional<wf::dimensions_t> size; | ||
wf::point_t position; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.