-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Port swaylock to layer shell #1705
Conversation
fec70c9
to
fc2b037
Compare
@@ -9,6 +9,7 @@ lib_sway_common = static_library( | |||
'pango.c', | |||
'readline.c', | |||
'stringop.c', | |||
'unicode.c', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be possible to use mbrtoc32/c32rtomb from <uchar.h>, instead of doing it ourselves?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it's not portable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They're standard C11 functions. I'm not certain, but they may introduce some locale-specific shit, though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like uchar.h is pretty shit after further research. It doesn't guarantee UTF-8 on the other side, just some locale-specific nonsense. I like my stock functions.
5beea9e
to
e79ef49
Compare
This is ready for review. |
while the inhibitor is active. | ||
|
||
The compositor may continue to send input events to selected clients, | ||
such as an on-screen keyboard (via the input-method protocol). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is the input-method protocol?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's in wayland-protocols
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you could qualify this a bit better.
if (previous) { | ||
wlr_log(L_DEBUG, "Returning focus to %p %s '%s'", previous, | ||
container_type_to_str(previous->type), previous->name); | ||
// Hack to get seat to re-focus the return value of get_focus |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because we handled focus out of the context of the seat's normal focus handling, seat_get_focus still returns what was focused before. Calling seat_set_focus with the return value of seat_get_focus (rightfully) exits early without doing anything, given that the previous focus is still valid. To work around this the hack changes the focus to the parent, then back again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
have you considered using the send_focus
function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it may be better, set focus to NULL
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not 100% on the best way to refactor this, I would appreciate it if you filed a follow-up patch improving it if you're not happy with it
sway/input/seat.c
Outdated
@@ -350,6 +353,11 @@ void seat_configure_xcursor(struct sway_seat *seat) { | |||
seat->cursor->cursor->y); | |||
} | |||
|
|||
bool seat_allow_input(struct sway_seat *seat, struct wlr_surface *surface) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
functions that return bools should be like input_is_allowed
or input_allowed
. This sounds like it makes input allowed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ack
for (int i = 0; i < root_container.children->length; ++i) { | ||
struct sway_container *output = root_container.children->items[i]; | ||
if (!sway_assert(output->type == C_OUTPUT, | ||
"root container has non-output child")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
on i3, the scratchpad is a child of the root container.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
on sway it won't be
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be represented that way in the ipc get_tree
or you'll break people's scripts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Noted
Clients can use this interface to prevent input events from being sent to | ||
any surfaces but its own, which is useful for example in lock screen | ||
software. It is assumed that access to this interface will be locked down | ||
to whitelisted clients by the compositor. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you should specify what happens to input focus of the existing clients when this gets created (and destroyed).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please move protocol feedback to the wlr-protocols thread
seat_set_focus(seat, NULL); | ||
} | ||
} | ||
if (seat->wlr_seat->pointer_state.focused_client) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't want library users to dig into pointer_state
. What about making a getter for this now that it's important?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
wl_list_for_each(point, &seat->wlr_seat->touch_state.touch_points, link) { | ||
if (point->client->client != client) { | ||
wlr_seat_touch_point_clear_focus(seat->wlr_seat, | ||
now.tv_nsec / 1000, point->touch_id); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this way of getting the time compatible with what we get from the real events?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ya
swaylock/render.c
Outdated
wl_surface_attach(surface->surface, surface->current_buffer->buffer, 0, 0); | ||
wl_surface_damage(surface->surface, 0, 0, buffer_width, buffer_height); | ||
wl_surface_commit(surface->surface); | ||
wl_display_roundtrip(state->display); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why are you roundtripping here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lines 102 to 108 in e79ef49
state->auth_state = AUTH_STATE_VALIDATING; | |
render_frames(state); | |
if (attempt_password(&state->password)) { | |
exit(0); | |
} | |
state->auth_state = AUTH_STATE_INVALID; | |
render_frames(state); |
It doesn't compile. I don't have |
I don't have |
4c1deaa
to
cdac5ac
Compare
swaylock/main.c
Outdated
surface->image = background_image; | ||
|
||
assert(surface->surface = | ||
wl_compositor_create_surface(state.compositor)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No side effects in assertions
|
||
static bool backspace(struct swaylock_password *pw) { | ||
if (pw->len != 0) { | ||
pw->buffer[--pw->len] = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Side note: with assignments in if
s, side effects in array brackets are practices I don't like and are error-prone. Especially for a lockscreen.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is error prone, this behavior is well defined
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not saying this is undefined behavior, I'm just saying it's unreadable and thus error-prone, even for people used to these idioms. It's just like if
s without brackets.
Anyway, I don't care too much, this is just a warning to say "if there's a bug because of this, don't blame me for having approved this PR".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know what you're saying. I disagree.
swaylock/password.c
Outdated
render_frames(state); | ||
wl_display_roundtrip(state->display); | ||
if (attempt_password(&state->password)) { | ||
exit(0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should cleanup all resources.
swaylock/render.c
Outdated
struct swaylock_state *state = surface->state; | ||
surface->current_buffer = get_next_buffer(state->shm, | ||
surface->buffers, | ||
surface->width * surface->scale, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Define buffer_width
before this instruction, and replace surface->width * surface->scale
with buffer_width
swaylock/render.c
Outdated
} | ||
cairo_identity_matrix(cairo); | ||
|
||
int ARC_RADIUS = 50 * surface->scale; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are these in all caps?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Used to be constants. Will lowercase them now.
swaylock/render.c
Outdated
|
||
wl_surface_set_buffer_scale(surface->surface, surface->scale); | ||
wl_surface_attach(surface->surface, surface->current_buffer->buffer, 0, 0); | ||
wl_surface_damage(surface->surface, 0, 0, buffer_width, buffer_height); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you want to damage buffer_{width,height}
, use wl_surface_damage_buffer
. Or you could just use surface->{width,height}
.
swaylock will use it too
inb4 acrisci
cdac5ac
to
5d444b3
Compare
Thanks! |
Fixes #1506, fixes #1141, fixes #918, fixes #605, fixes #1072
Ref #797