shell: Add window menu
This commit is contained in:
parent
edfb0edda7
commit
8c4d77e43c
14 changed files with 1591 additions and 32 deletions
|
|
@ -590,6 +590,7 @@ impl CosmicStack {
|
|||
#[derive(Debug, Clone, Copy)]
|
||||
pub enum Message {
|
||||
DragStart,
|
||||
Menu,
|
||||
PotentialTabDragStart(usize),
|
||||
Activate(usize),
|
||||
Close(usize),
|
||||
|
|
@ -684,6 +685,41 @@ impl Program for CosmicStackInternal {
|
|||
Message::Scrolled => {
|
||||
self.scroll_to_focus.store(false, Ordering::SeqCst);
|
||||
}
|
||||
Message::Menu => {
|
||||
if let Some((seat, serial)) = self.last_seat.lock().unwrap().clone() {
|
||||
if let Some(surface) = self.windows.lock().unwrap()
|
||||
[self.active.load(Ordering::SeqCst)]
|
||||
.wl_surface()
|
||||
{
|
||||
loop_handle.insert_idle(move |state| {
|
||||
if let Some(mapped) =
|
||||
state.common.shell.element_for_wl_surface(&surface).cloned()
|
||||
{
|
||||
if let Some(workspace) = state.common.shell.space_for_mut(&mapped) {
|
||||
let position = workspace
|
||||
.element_geometry(&mapped)
|
||||
.unwrap()
|
||||
.loc
|
||||
.to_global(&workspace.output);
|
||||
let mut cursor = seat
|
||||
.get_pointer()
|
||||
.unwrap()
|
||||
.current_location()
|
||||
.to_i32_round();
|
||||
cursor.y -= TAB_HEIGHT;
|
||||
Shell::menu_request(
|
||||
state,
|
||||
&surface,
|
||||
&seat,
|
||||
serial,
|
||||
cursor - position.as_logical(),
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => unreachable!(),
|
||||
}
|
||||
Command::none()
|
||||
|
|
@ -718,6 +754,7 @@ impl Program for CosmicStackInternal {
|
|||
.center_y()
|
||||
.apply(iced_widget::mouse_area)
|
||||
.on_press(Message::DragStart)
|
||||
.on_right_press(Message::Menu)
|
||||
.into(),
|
||||
CosmicElement::new(
|
||||
Tabs::new(
|
||||
|
|
@ -750,6 +787,7 @@ impl Program for CosmicStackInternal {
|
|||
.padding([64, 24])
|
||||
.apply(iced_widget::mouse_area)
|
||||
.on_press(Message::DragStart)
|
||||
.on_right_press(Message::Menu)
|
||||
.into(),
|
||||
];
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ use crate::{
|
|||
wayland::handlers::screencopy::ScreencopySessions,
|
||||
};
|
||||
use calloop::LoopHandle;
|
||||
use cosmic::iced::Command;
|
||||
use cosmic::{iced::Command, widget::mouse_area, Apply};
|
||||
use cosmic_protocols::screencopy::v1::server::zcosmic_screencopy_session_v1::InputType;
|
||||
use smithay::{
|
||||
backend::{
|
||||
|
|
@ -240,6 +240,7 @@ pub enum Message {
|
|||
DragStart,
|
||||
Maximize,
|
||||
Close,
|
||||
Menu,
|
||||
}
|
||||
|
||||
impl Program for CosmicWindowInternal {
|
||||
|
|
@ -284,6 +285,38 @@ impl Program for CosmicWindowInternal {
|
|||
}
|
||||
}
|
||||
Message::Close => self.window.close(),
|
||||
Message::Menu => {
|
||||
if let Some((seat, serial)) = self.last_seat.lock().unwrap().clone() {
|
||||
if let Some(surface) = self.window.wl_surface() {
|
||||
loop_handle.insert_idle(move |state| {
|
||||
if let Some(mapped) =
|
||||
state.common.shell.element_for_wl_surface(&surface).cloned()
|
||||
{
|
||||
if let Some(workspace) = state.common.shell.space_for_mut(&mapped) {
|
||||
let position = workspace
|
||||
.element_geometry(&mapped)
|
||||
.unwrap()
|
||||
.loc
|
||||
.to_global(&workspace.output);
|
||||
let mut cursor = seat
|
||||
.get_pointer()
|
||||
.unwrap()
|
||||
.current_location()
|
||||
.to_i32_round();
|
||||
cursor.y -= SSD_HEIGHT;
|
||||
Shell::menu_request(
|
||||
state,
|
||||
&surface,
|
||||
&seat,
|
||||
serial,
|
||||
cursor - position.as_logical(),
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Command::none()
|
||||
}
|
||||
|
|
@ -355,7 +388,9 @@ impl Program for CosmicWindowInternal {
|
|||
.on_drag(Message::DragStart)
|
||||
.on_maximize(Message::Maximize)
|
||||
.on_close(Message::Close)
|
||||
.into_element()
|
||||
.apply(mouse_area)
|
||||
.on_right_press(Message::Menu)
|
||||
.into()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue