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

View file

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

View file

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

View file

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

View file

@ -5,6 +5,7 @@ use cctk::{
output::{OutputHandler, OutputState},
reexports::{
calloop,
calloop_wayland_source::WaylandSource,
client::{self as wayland_client},
},
registry::{ProvidesRegistryState, RegistryState},
@ -18,7 +19,7 @@ use wayland_client::backend::ObjectId;
use wayland_client::{
globals::registry_queue_init,
protocol::wl_output::{self, WlOutput},
ConnectError, Proxy, WaylandSource,
ConnectError, Proxy,
};
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 qhandle = event_queue.handle();
WaylandSource::new(event_queue)
.expect("Failed to create wayland source")
WaylandSource::new(conn, event_queue)
.insert(loop_handle)
.unwrap();