Use gdk_screen_get_monitor_plug_name to provide more consistent monitor names on wayland (#1129)
* workaround gdk not providing right monitor informations on wayland * move gdk workaround for plug name into a separate function * adjust changelog
This commit is contained in:
parent
3342234894
commit
510b824e75
4 changed files with 18 additions and 2 deletions
|
@ -11,6 +11,7 @@ All notable changes to eww will be listed here, starting at changes since versio
|
||||||
- Fix the gtk `stack` widget (By: ovalkonia)
|
- Fix the gtk `stack` widget (By: ovalkonia)
|
||||||
- Fix values in the `EWW_NET` variable (By: mario-kr)
|
- Fix values in the `EWW_NET` variable (By: mario-kr)
|
||||||
- Fix the gtk `expander` widget (By: ovalkonia)
|
- Fix the gtk `expander` widget (By: ovalkonia)
|
||||||
|
- Fix wayland monitor names support (By: dragonnn)
|
||||||
|
|
||||||
### Features
|
### Features
|
||||||
- Update rust toolchain to 1.80.1 (By: w-lfchen)
|
- Update rust toolchain to 1.80.1 (By: w-lfchen)
|
||||||
|
|
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -941,6 +941,7 @@ dependencies = [
|
||||||
"eww_shared_util",
|
"eww_shared_util",
|
||||||
"extend",
|
"extend",
|
||||||
"futures",
|
"futures",
|
||||||
|
"gdk-sys",
|
||||||
"gdkx11",
|
"gdkx11",
|
||||||
"grass",
|
"grass",
|
||||||
"gtk",
|
"gtk",
|
||||||
|
|
|
@ -23,9 +23,12 @@ notifier_host.workspace = true
|
||||||
gtk-layer-shell = { version = "0.8.1", optional = true }
|
gtk-layer-shell = { version = "0.8.1", optional = true }
|
||||||
gdkx11 = { version = "0.18", optional = true }
|
gdkx11 = { version = "0.18", optional = true }
|
||||||
x11rb = { version = "0.13.1", features = ["randr"], optional = true }
|
x11rb = { version = "0.13.1", features = ["randr"], optional = true }
|
||||||
|
gdk-sys = "0.18.0"
|
||||||
|
|
||||||
ordered-stream = "0.2.0"
|
ordered-stream = "0.2.0"
|
||||||
|
|
||||||
|
|
||||||
|
grass.workspace = true
|
||||||
anyhow.workspace = true
|
anyhow.workspace = true
|
||||||
bincode.workspace = true
|
bincode.workspace = true
|
||||||
chrono.workspace = true
|
chrono.workspace = true
|
||||||
|
@ -35,7 +38,6 @@ codespan-reporting.workspace = true
|
||||||
derive_more.workspace = true
|
derive_more.workspace = true
|
||||||
extend.workspace = true
|
extend.workspace = true
|
||||||
futures.workspace = true
|
futures.workspace = true
|
||||||
grass.workspace = true
|
|
||||||
gtk.workspace = true
|
gtk.workspace = true
|
||||||
itertools.workspace = true
|
itertools.workspace = true
|
||||||
libc.workspace = true
|
libc.workspace = true
|
||||||
|
|
|
@ -625,6 +625,18 @@ fn get_gdk_monitor(identifier: Option<MonitorIdentifier>) -> Result<Monitor> {
|
||||||
Ok(monitor)
|
Ok(monitor)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Get the name of monitor plug for given monitor number
|
||||||
|
/// workaround gdk not providing this information on wayland in regular calls
|
||||||
|
/// gdk_screen_get_monitor_plug_name is deprecated but works fine for that case
|
||||||
|
fn get_monitor_plug_name(display: &gdk::Display, monitor_num: i32) -> Option<&str> {
|
||||||
|
unsafe {
|
||||||
|
use glib::translate::ToGlibPtr;
|
||||||
|
let plug_name_pointer = gdk_sys::gdk_screen_get_monitor_plug_name(display.default_screen().to_glib_none().0, monitor_num);
|
||||||
|
use std::ffi::CStr;
|
||||||
|
CStr::from_ptr(plug_name_pointer).to_str().ok()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Returns the [Monitor][gdk::Monitor] structure corresponding to the identifer.
|
/// Returns the [Monitor][gdk::Monitor] structure corresponding to the identifer.
|
||||||
/// Outside of x11, only [MonitorIdentifier::Numeric] is supported
|
/// Outside of x11, only [MonitorIdentifier::Numeric] is supported
|
||||||
pub fn get_monitor_from_display(display: &gdk::Display, identifier: &MonitorIdentifier) -> Option<gdk::Monitor> {
|
pub fn get_monitor_from_display(display: &gdk::Display, identifier: &MonitorIdentifier) -> Option<gdk::Monitor> {
|
||||||
|
@ -642,7 +654,7 @@ pub fn get_monitor_from_display(display: &gdk::Display, identifier: &MonitorIden
|
||||||
MonitorIdentifier::Name(name) => {
|
MonitorIdentifier::Name(name) => {
|
||||||
for m in 0..display.n_monitors() {
|
for m in 0..display.n_monitors() {
|
||||||
if let Some(model) = display.monitor(m).and_then(|x| x.model()) {
|
if let Some(model) = display.monitor(m).and_then(|x| x.model()) {
|
||||||
if model == *name {
|
if model == *name || Some(name.as_str()) == get_monitor_plug_name(display, m) {
|
||||||
return display.monitor(m);
|
return display.monitor(m);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue