-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[update] replace xdg-output-handler with wl_output
* Update some dependencies. * Rewrite output.rs to use wl_output version 4 instead of xdg-output-handler * Sent patch to smithay to update wl_output least supported version Smithay/client-toolkit#259.
- Loading branch information
1 parent
fc90d64
commit 0469431
Showing
6 changed files
with
75 additions
and
103 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,7 @@ uninstall: | |
check: | ||
@cargo fmt | ||
@cargo check | ||
@cargo clippy | ||
|
||
clean: | ||
@cargo clean | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,53 @@ | ||
use smithay_client_toolkit::{ | ||
environment, | ||
environment::Environment, | ||
output::{with_output_info, OutputHandler, OutputInfo, XdgOutputHandler}, | ||
reexports::{ | ||
client::{protocol::wl_output::WlOutput, Display}, | ||
protocols::unstable::xdg_output::v1::client::zxdg_output_manager_v1::ZxdgOutputManagerV1, | ||
}, | ||
use smithay_client_toolkit::reexports::client::{ | ||
protocol::wl_output, protocol::wl_output::WlOutput, Display, GlobalManager, | ||
}; | ||
use std::{cell::RefCell, process::exit, rc::Rc}; | ||
|
||
struct App { | ||
outputs: OutputHandler, | ||
xdg_output: XdgOutputHandler, | ||
#[derive(Debug, Clone)] | ||
pub struct OutputInfo { | ||
pub wl_output: *mut WlOutput, | ||
pub name: String, | ||
} | ||
|
||
environment! {App, | ||
singles = [ | ||
ZxdgOutputManagerV1 => xdg_output, | ||
], | ||
multis = [ | ||
WlOutput => outputs, | ||
] | ||
} | ||
|
||
pub fn get_valid_outputs(display: Display) -> Vec<(WlOutput, OutputInfo)> { | ||
let mut queue = display.create_event_queue(); | ||
let attached_display = display.attach(queue.token()); | ||
|
||
let (outputs, xdg_output) = XdgOutputHandler::new_output_handlers(); | ||
let mut valid_outputs: Vec<(WlOutput, OutputInfo)> = Vec::new(); | ||
pub fn get_all_outputs(display: Display) -> Vec<OutputInfo> { | ||
// Connecting to wayland environment. | ||
let mut event_queue = display.create_event_queue(); | ||
let attached_display = (*display).clone().attach(event_queue.token()); | ||
|
||
let env = Environment::new( | ||
&attached_display, | ||
&mut &mut queue, | ||
App { | ||
outputs, | ||
xdg_output, | ||
}, | ||
) | ||
.unwrap(); | ||
let outputs: Rc<RefCell<Vec<OutputInfo>>> = Rc::new(RefCell::new(Vec::new())); | ||
|
||
queue.sync_roundtrip(&mut (), |_, _, _| {}).unwrap(); | ||
// Instantiating the global manager. | ||
let globals = GlobalManager::new(&attached_display); | ||
event_queue.sync_roundtrip(&mut (), |_, _, _| {}).unwrap(); | ||
|
||
for output in env.get_all_outputs() { | ||
with_output_info(&output, |info| { | ||
if info.obsolete == false { | ||
valid_outputs.push((output.clone(), info.clone())); | ||
} else { | ||
output.release(); | ||
globals | ||
.instantiate_exact::<WlOutput>(4) | ||
.expect("Failed to bind to wl_output global.") | ||
.quick_assign({ | ||
let outputs = outputs.clone(); | ||
move |output, event, _| { | ||
if let wl_output::Event::Name { name } = event { | ||
outputs.borrow_mut().push(OutputInfo { | ||
wl_output: &mut output.detach(), | ||
name, | ||
}); | ||
} | ||
} | ||
}); | ||
event_queue.sync_roundtrip(&mut (), |_, _, _| {}).unwrap(); | ||
let x = outputs.borrow().to_vec(); | ||
x | ||
} | ||
|
||
/// Get a wl_output object from the output name. | ||
pub fn get_wloutput(name: String, outputs: Vec<OutputInfo>) -> &'static WlOutput { | ||
for output in outputs { | ||
if output.name == name { | ||
unsafe { | ||
return &*output.wl_output; | ||
} | ||
} | ||
} | ||
valid_outputs | ||
log::error!("Error: No output of name \"{}\" was found", name); | ||
exit(1); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters