mirror of
https://github.com/Zedfrigg/ironbar.git
synced 2025-08-17 14:51:04 +02:00
Merge pull request #946 from JakeStanger/fix/wayland-panic
fix(wayland): panicking on compositors without protocol support
This commit is contained in:
commit
1e501d99d2
6 changed files with 40 additions and 14 deletions
4
.github/workflows/build.yml
vendored
4
.github/workflows/build.yml
vendored
|
@ -5,13 +5,13 @@ on:
|
||||||
push:
|
push:
|
||||||
branches: [ "master" ]
|
branches: [ "master" ]
|
||||||
paths:
|
paths:
|
||||||
- 'src'
|
- 'src/**/*'
|
||||||
- 'Cargo.*'
|
- 'Cargo.*'
|
||||||
- 'build.rs'
|
- 'build.rs'
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [ "master" ]
|
branches: [ "master" ]
|
||||||
paths:
|
paths:
|
||||||
- 'src'
|
- 'src/**/*'
|
||||||
- 'Cargo.*'
|
- 'Cargo.*'
|
||||||
- 'build.rs'
|
- 'build.rs'
|
||||||
- '.github/workflows/build.yml'
|
- '.github/workflows/build.yml'
|
||||||
|
|
2
.github/workflows/schema.yml
vendored
2
.github/workflows/schema.yml
vendored
|
@ -5,7 +5,7 @@ on:
|
||||||
push:
|
push:
|
||||||
branches: [ "master" ]
|
branches: [ "master" ]
|
||||||
paths:
|
paths:
|
||||||
- 'src'
|
- 'src/**/*'
|
||||||
- 'Cargo.*'
|
- 'Cargo.*'
|
||||||
- 'build.rs'
|
- 'build.rs'
|
||||||
- '.github/workflows/schema.yml'
|
- '.github/workflows/schema.yml'
|
||||||
|
|
2
.github/workflows/wiki.yml
vendored
2
.github/workflows/wiki.yml
vendored
|
@ -4,7 +4,7 @@ on:
|
||||||
push:
|
push:
|
||||||
branches: [ "master" ]
|
branches: [ "master" ]
|
||||||
paths:
|
paths:
|
||||||
- 'docs'
|
- 'docs/**/*'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
|
|
|
@ -9,7 +9,7 @@ use std::sync::{Arc, Mutex};
|
||||||
|
|
||||||
use calloop_channel::Event::Msg;
|
use calloop_channel::Event::Msg;
|
||||||
use cfg_if::cfg_if;
|
use cfg_if::cfg_if;
|
||||||
use color_eyre::Report;
|
use color_eyre::{Help, Report};
|
||||||
use smithay_client_toolkit::output::OutputState;
|
use smithay_client_toolkit::output::OutputState;
|
||||||
use smithay_client_toolkit::reexports::calloop::EventLoop;
|
use smithay_client_toolkit::reexports::calloop::EventLoop;
|
||||||
use smithay_client_toolkit::reexports::calloop::channel as calloop_channel;
|
use smithay_client_toolkit::reexports::calloop::channel as calloop_channel;
|
||||||
|
@ -204,7 +204,7 @@ pub struct Environment {
|
||||||
|
|
||||||
// -- clipboard --
|
// -- clipboard --
|
||||||
#[cfg(feature = "clipboard")]
|
#[cfg(feature = "clipboard")]
|
||||||
data_control_device_manager_state: DataControlDeviceManagerState,
|
data_control_device_manager_state: Option<DataControlDeviceManagerState>,
|
||||||
|
|
||||||
#[cfg(feature = "clipboard")]
|
#[cfg(feature = "clipboard")]
|
||||||
data_control_devices: Vec<DataControlDeviceEntry>,
|
data_control_devices: Vec<DataControlDeviceEntry>,
|
||||||
|
@ -263,12 +263,30 @@ impl Environment {
|
||||||
let output_state = OutputState::new(&globals, &qh);
|
let output_state = OutputState::new(&globals, &qh);
|
||||||
let seat_state = SeatState::new(&globals, &qh);
|
let seat_state = SeatState::new(&globals, &qh);
|
||||||
#[cfg(any(feature = "focused", feature = "launcher"))]
|
#[cfg(any(feature = "focused", feature = "launcher"))]
|
||||||
ToplevelManagerState::bind(&globals, &qh)
|
if let Err(err) = ToplevelManagerState::bind(&globals, &qh) {
|
||||||
.expect("to bind to wlr_foreign_toplevel_manager global");
|
error!("{:?}",
|
||||||
|
Report::new(err)
|
||||||
|
.wrap_err("Failed to bind to wlr_foreign_toplevel_manager global")
|
||||||
|
.note("This is likely a due to the current compositor not supporting the required protocol")
|
||||||
|
.note("launcher and focused modules will not work")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(feature = "clipboard")]
|
#[cfg(feature = "clipboard")]
|
||||||
let data_control_device_manager_state = DataControlDeviceManagerState::bind(&globals, &qh)
|
let data_control_device_manager_state = match DataControlDeviceManagerState::bind(
|
||||||
.expect("to bind to wlr_data_control_device_manager global");
|
&globals, &qh,
|
||||||
|
) {
|
||||||
|
Ok(state) => Some(state),
|
||||||
|
Err(err) => {
|
||||||
|
error!("{:?}",
|
||||||
|
Report::new(err)
|
||||||
|
.wrap_err("Failed to bind to wlr_data_control_device global")
|
||||||
|
.note("This is likely a due to the current compositor not supporting the required protocol")
|
||||||
|
.note("clipboard module will not work")
|
||||||
|
);
|
||||||
|
None
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
let mut env = Self {
|
let mut env = Self {
|
||||||
registry_state,
|
registry_state,
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use super::Environment;
|
use super::Environment;
|
||||||
use smithay_client_toolkit::seat::{Capability, SeatHandler, SeatState};
|
use smithay_client_toolkit::seat::{Capability, SeatHandler, SeatState};
|
||||||
use tracing::debug;
|
use tracing::{debug, error};
|
||||||
use wayland_client::protocol::wl_seat::WlSeat;
|
use wayland_client::protocol::wl_seat::WlSeat;
|
||||||
use wayland_client::{Connection, QueueHandle};
|
use wayland_client::{Connection, QueueHandle};
|
||||||
|
|
||||||
|
@ -37,7 +37,11 @@ impl SeatHandler for Environment {
|
||||||
{
|
{
|
||||||
debug!("Adding new data control device");
|
debug!("Adding new data control device");
|
||||||
// create the data device here for this seat
|
// create the data device here for this seat
|
||||||
let data_control_device_manager = &self.data_control_device_manager_state;
|
let Some(data_control_device_manager) = &self.data_control_device_manager_state else {
|
||||||
|
error!("data_control_device_manager not available, cannot copy");
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
|
||||||
let data_control_device = data_control_device_manager.get_data_device(qh, &seat);
|
let data_control_device = data_control_device_manager.get_data_device(qh, &seat);
|
||||||
self.data_control_devices
|
self.data_control_devices
|
||||||
.push(super::DataControlDeviceEntry {
|
.push(super::DataControlDeviceEntry {
|
||||||
|
|
|
@ -147,6 +147,11 @@ impl Environment {
|
||||||
pub fn copy_to_clipboard(&mut self, item: ClipboardItem) {
|
pub fn copy_to_clipboard(&mut self, item: ClipboardItem) {
|
||||||
debug!("Copying item to clipboard: {item:?}");
|
debug!("Copying item to clipboard: {item:?}");
|
||||||
|
|
||||||
|
let Some(data_control_device_manager) = &self.data_control_device_manager_state else {
|
||||||
|
error!("data_control_device_manager not available, cannot copy");
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
|
||||||
let seat = self.default_seat();
|
let seat = self.default_seat();
|
||||||
let Some(device) = self
|
let Some(device) = self
|
||||||
.data_control_devices
|
.data_control_devices
|
||||||
|
@ -156,8 +161,7 @@ impl Environment {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
let source = self
|
let source = data_control_device_manager
|
||||||
.data_control_device_manager_state
|
|
||||||
.create_copy_paste_source(&self.queue_handle, [&item.mime_type, INTERNAL_MIME_TYPE]);
|
.create_copy_paste_source(&self.queue_handle, [&item.mime_type, INTERNAL_MIME_TYPE]);
|
||||||
|
|
||||||
source.set_selection(&device.device);
|
source.set_selection(&device.device);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue