fix: app-list panic on activate and build

This commit is contained in:
Ashley Wulber 2023-10-10 19:26:27 -04:00 committed by Ashley Wulber
parent 486eff3eb3
commit 4107f18d81
5 changed files with 19 additions and 16 deletions

View file

@ -452,9 +452,11 @@ impl cosmic::Application for CosmicAppList {
} }
} }
Message::Favorite(id) => { Message::Favorite(id) => {
if let Some(i) = self.active_list.iter().position(|t| { if let Some(i) = self
t.desktop_info.id == id .active_list
}) { .iter()
.position(|t| t.desktop_info.id == id)
{
let entry = self.active_list.remove(i); let entry = self.active_list.remove(i);
self.favorite_list.push(entry); self.favorite_list.push(entry);
} }
@ -488,9 +490,8 @@ impl cosmic::Application for CosmicAppList {
if let Some(p) = self.popup.take() { if let Some(p) = self.popup.take() {
return destroy_popup(p.0); return destroy_popup(p.0);
} }
if let (Some(tx), Some(seat)) = (self.toplevel_sender.as_ref(), self.seat.as_ref()) if let Some(tx) = self.toplevel_sender.as_ref() {
{ let _ = tx.send(ToplevelRequest::Activate(handle));
let _ = tx.send(ToplevelRequest::Activate(handle, seat.clone()));
} }
} }
Message::Quit(id) => { Message::Quit(id) => {

View file

@ -3,8 +3,7 @@ use cctk::{
sctk::{ sctk::{
self, self,
reexports::{ reexports::{
calloop, calloop, calloop_wayland_source::WaylandSource, client::protocol::wl_seat::WlSeat,
client::{protocol::wl_seat::WlSeat, WaylandSource},
}, },
seat::{SeatHandler, SeatState}, seat::{SeatHandler, SeatState},
}, },
@ -132,7 +131,7 @@ pub(crate) fn toplevel_handler(
let (globals, event_queue) = registry_queue_init(&conn).unwrap(); let (globals, event_queue) = registry_queue_init(&conn).unwrap();
let mut event_loop = calloop::EventLoop::<AppData>::try_new().unwrap(); let mut event_loop = calloop::EventLoop::<AppData>::try_new().unwrap();
let qh = event_queue.handle(); let qh = event_queue.handle();
let wayland_source = WaylandSource::new(event_queue).unwrap(); let wayland_source = WaylandSource::new(conn, event_queue);
let handle = event_loop.handle(); let handle = event_loop.handle();
wayland_source wayland_source
.insert(handle.clone()) .insert(handle.clone())
@ -141,9 +140,11 @@ pub(crate) fn toplevel_handler(
if handle if handle
.insert_source(rx, |event, _, state| match event { .insert_source(rx, |event, _, state| match event {
calloop::channel::Event::Msg(req) => match req { calloop::channel::Event::Msg(req) => match req {
ToplevelRequest::Activate(handle, seat) => { ToplevelRequest::Activate(handle) => {
let manager = &state.toplevel_manager_state.manager; if let Some(seat) = state.seat_state.seats().next() {
manager.activate(&handle, &seat); let manager = &state.toplevel_manager_state.manager;
manager.activate(&handle, &seat);
}
} }
ToplevelRequest::Quit(handle) => { ToplevelRequest::Quit(handle) => {
let manager = &state.toplevel_manager_state.manager; let manager = &state.toplevel_manager_state.manager;

View file

@ -83,7 +83,7 @@ pub enum ToplevelUpdate {
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub enum ToplevelRequest { pub enum ToplevelRequest {
Activate(ZcosmicToplevelHandleV1, WlSeat), Activate(ZcosmicToplevelHandleV1),
Quit(ZcosmicToplevelHandleV1), Quit(ZcosmicToplevelHandleV1),
Exit, Exit,
} }

View file

@ -5,6 +5,7 @@ use cosmic::iced::{
window, Alignment, Length, Rectangle, Subscription, window, Alignment, Length, Rectangle, Subscription,
}; };
use cosmic::iced_style::application; use cosmic::iced_style::application;
use cosmic::theme;
use cosmic::{app, applet::cosmic_panel_config::PanelAnchor, Command}; use cosmic::{app, applet::cosmic_panel_config::PanelAnchor, Command};
use cosmic::{ use cosmic::{
widget::{icon, rectangle_tracker::*}, widget::{icon, rectangle_tracker::*},

View file

@ -5,6 +5,7 @@ use cctk::{
output::{OutputHandler, OutputState}, output::{OutputHandler, OutputState},
reexports::{ reexports::{
calloop, calloop,
calloop_wayland_source::WaylandSource,
client::{self as wayland_client}, client::{self as wayland_client},
}, },
registry::{ProvidesRegistryState, RegistryState}, registry::{ProvidesRegistryState, RegistryState},
@ -18,7 +19,7 @@ use wayland_client::backend::ObjectId;
use wayland_client::{ use wayland_client::{
globals::registry_queue_init, globals::registry_queue_init,
protocol::wl_output::{self, WlOutput}, protocol::wl_output::{self, WlOutput},
ConnectError, Proxy, WaylandSource, ConnectError, Proxy,
}; };
use wayland_client::{Connection, QueueHandle, WEnum}; use wayland_client::{Connection, QueueHandle, WEnum};
@ -53,8 +54,7 @@ pub fn spawn_workspaces(tx: mpsc::Sender<WorkspaceList>) -> SyncSender<Workspace
let (globals, event_queue) = registry_queue_init(&conn).unwrap(); let (globals, event_queue) = registry_queue_init(&conn).unwrap();
let qhandle = event_queue.handle(); let qhandle = event_queue.handle();
WaylandSource::new(event_queue) WaylandSource::new(conn, event_queue)
.expect("Failed to create wayland source")
.insert(loop_handle) .insert(loop_handle)
.unwrap(); .unwrap();