Skip to content

Commit 7f8e19f

Browse files
authored
feat(layershellev): replace use_last_output with output_option in NewInputPanelSettings (#355)
Signed-off-by: fortime <palfortime@gmail.com>
1 parent 38102de commit 7f8e19f

File tree

2 files changed

+34
-20
lines changed

2 files changed

+34
-20
lines changed

layershellev/src/events.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,15 +120,15 @@ pub struct NewXdgWindowSettings {
120120
}
121121

122122
/// input panel settings to create a new input panel surface
123-
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
123+
#[derive(Debug, Clone, PartialEq, Eq)]
124124
pub struct NewInputPanelSettings {
125125
pub size: (u32, u32),
126126
/// set the surface type as a keyboard
127127
pub keyboard: bool,
128128
/// follow the last output of the activated surface, used to create some thing like mako, who
129129
/// will show on the same window, only when the notifications is cleared, it will change the
130130
/// wl_output.
131-
pub use_last_output: bool,
131+
pub output_option: OutputOption,
132132
}
133133

134134
impl Default for NewLayerShellSettings {

layershellev/src/lib.rs

Lines changed: 32 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3209,31 +3209,45 @@ impl<T: 'static> WindowState<T> {
32093209
NewInputPanelSettings {
32103210
size: (width, height),
32113211
keyboard,
3212-
use_last_output,
3212+
output_option: output_type,
32133213
},
32143214
id,
32153215
info,
32163216
)) => {
3217-
let pos = window_state.surface_pos();
3217+
let output = match output_type {
3218+
OutputOption::Output(output) => Some(output),
3219+
OutputOption::OutputName(name) => window_state
3220+
.xdg_info_cache
3221+
.iter()
3222+
.find(|(_, info)| info.name == *name)
3223+
.map(|(output, _)| output.clone()),
3224+
_ => {
3225+
let pos = window_state.surface_pos();
32183226

3219-
let mut output =
3220-
pos.and_then(|p| window_state.units[p].wl_output.as_ref());
3227+
let mut output =
3228+
pos.and_then(|p| window_state.units[p].wl_output.as_ref());
32213229

3222-
if window_state.last_wloutput.is_none()
3223-
&& window_state.outputs.len() > window_state.last_unit_index
3224-
{
3225-
window_state.last_wloutput = Some(
3226-
window_state.outputs[window_state.last_unit_index].1.clone(),
3227-
);
3228-
}
3230+
if window_state.last_wloutput.is_none()
3231+
&& window_state.outputs.len() > window_state.last_unit_index
3232+
{
3233+
window_state.last_wloutput = Some(
3234+
window_state.outputs[window_state.last_unit_index]
3235+
.1
3236+
.clone(),
3237+
);
3238+
}
32293239

3230-
if use_last_output {
3231-
output = window_state.last_wloutput.as_ref();
3232-
}
3240+
if matches!(output_type, events::OutputOption::LastOutput) {
3241+
output = window_state.last_wloutput.as_ref();
3242+
}
32333243

3234-
if output.is_none() {
3235-
output = window_state.outputs.first().map(|(_, o)| o);
3236-
}
3244+
if output.is_none() {
3245+
output = window_state.outputs.first().map(|(_, o)| o);
3246+
}
3247+
3248+
output.cloned()
3249+
}
3250+
};
32373251

32383252
let Some(output) = output else {
32393253
log::warn!("no WlOutput, skip creating input panel");
@@ -3248,7 +3262,7 @@ impl<T: 'static> WindowState<T> {
32483262
input_panel.get_input_panel_surface(&wl_surface, &qh, ());
32493263
if keyboard {
32503264
input_panel_surface.set_toplevel(
3251-
output,
3265+
&output,
32523266
ZwpInputPanelPosition::CenterBottom as u32,
32533267
);
32543268
} else {

0 commit comments

Comments
 (0)