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

xdg-activation: Add client_id to token data #1203

Merged
merged 1 commit into from
Nov 6, 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
3 changes: 2 additions & 1 deletion src/wayland/xdg_activation/dispatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ where
{
fn request(
state: &mut D,
_: &Client,
client: &Client,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd wonder would the ClientId be preferable or pass a whole Client? You can get the id from a Client but also do lookup on the Client you get.

Copy link
Member Author

@Drakulix Drakulix Nov 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original client could disconnect before the token is used by another client. I didn't want to force the object to keep on living. In that sense it serves as an Option<Client>.

So in token_created this will always be a valid id, but in request_activation it might not be.

token: &xdg_activation_token_v1::XdgActivationTokenV1,
request: xdg_activation_token_v1::Request,
data: &ActivationTokenData,
Expand Down Expand Up @@ -146,6 +146,7 @@ where
let mut guard = data.build.lock().unwrap();

XdgActivationTokenData::new(
client.id(),
guard.serial.take(),
guard.app_id.take(),
guard.surface.take(),
Expand Down
6 changes: 5 additions & 1 deletion src/wayland/xdg_activation/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ use std::{

use wayland_protocols::xdg::activation::v1::server::xdg_activation_v1;
use wayland_server::{
backend::GlobalId,
backend::{ClientId, GlobalId},
protocol::{wl_seat::WlSeat, wl_surface::WlSurface},
Dispatch, DisplayHandle, GlobalDispatch,
};
Expand Down Expand Up @@ -103,6 +103,8 @@ impl From<XdgActivationToken> for String {

#[derive(Debug, Clone)]
pub struct XdgActivationTokenData {
/// Client that requested the token
pub client_id: ClientId,
/// Provides information about the seat and serial event that requested the token.
///
/// The serial can come from an input or focus event.
Expand All @@ -129,13 +131,15 @@ pub struct XdgActivationTokenData {

impl XdgActivationTokenData {
fn new(
client_id: ClientId,
serial: Option<(Serial, WlSeat)>,
app_id: Option<String>,
surface: Option<WlSurface>,
) -> (XdgActivationToken, XdgActivationTokenData) {
(
XdgActivationToken::new(),
XdgActivationTokenData {
client_id,
serial,
app_id,
surface,
Expand Down