-
Notifications
You must be signed in to change notification settings - Fork 569
wayland: rebased and merge into master #2079
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 28 commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
4ca1fd7
Save empty backend.
richard-uk1 fcfee87
implement druid-shell for wayland.
richard-uk1 32d1e6c
Reduce the number of warnings.
richard-uk1 d8413e9
log -> tracing
maan2003 91b71a8
simulate_input
maan2003 696ae7d
prepare paint
maan2003 81cf390
green CI
maan2003 0662630
wayland fixes and improvements
james-lawrence 88cf58d
wayland: share xkb with x11 backend
maan2003 1194bbe
decouple buffers from surface. (#2032)
james-lawrence 3500e1e
decouple window handles from wayland id. (#2033)
james-lawrence 104579f
remove dead/unused code. (#2035)
james-lawrence ba5f362
update wayland dependencies
james-lawrence 6a9b58d
expose api for display reinitialization support.
james-lawrence c800f00
handle output added/removed events on eventqueue.
james-lawrence a90667e
formatting
james-lawrence 2a3ca49
implement locale detection for wayland. (#2059)
james-lawrence 89412ba
enable buffer recreation to always be allowed. (#2070)
james-lawrence 1186cff
implement repeating keys. (#2058)
james-lawrence 7ad66e7
attempt to create a working clipboard (#2057)
james-lawrence 41471d7
cleanup popup implementation. (#2071)
james-lawrence 804040e
implement screen for wayland. (#2076)
james-lawrence e7d7d31
wayland: CI
maan2003 cff899a
xkb: only include xkbcommon-x11.h if x11 feature is enabled
maan2003 79a0c04
No ApplicationExt on wayland
maan2003 1b51ace
Clippy
maan2003 632c8c5
additional clippy fixes.
james-lawrence c803df8
test fixes
james-lawrence 6e62f5e
cleanup the output detect code.
james-lawrence 409981d
Merge pull request #1 from james-lawrence/wayland-display-refactor
james-lawrence 2451da9
cargo fmt
james-lawrence bdf6792
peer review
james-lawrence File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -0,0 +1,136 @@ | ||
| // Copyright 2018 The Druid Authors. | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| /// An example that is as simple as possible (just throw up an empty window). | ||
| use std::any::Any; | ||
|
|
||
| use druid_shell::kurbo::{Point, Rect, Size}; | ||
| use druid_shell::piet::{Color, FixedLinearGradient, GradientStop, RenderContext}; | ||
|
|
||
| use druid_shell::{ | ||
| Application, Cursor, FileDialogToken, FileInfo, KeyEvent, MouseEvent, Region, TimerToken, | ||
| WinHandler, WindowBuilder, WindowHandle, | ||
| }; | ||
|
|
||
| #[derive(Default)] | ||
| struct HelloState { | ||
| size: Size, | ||
| handle: Option<WindowHandle>, | ||
| } | ||
|
|
||
| impl WinHandler for HelloState { | ||
| fn connect(&mut self, handle: &WindowHandle) { | ||
| self.handle = Some(handle.clone()); | ||
| } | ||
|
|
||
| fn prepare_paint(&mut self) { | ||
| self.handle.as_mut().unwrap().invalidate(); | ||
| } | ||
|
|
||
| fn paint(&mut self, piet: &mut piet_common::Piet, _: &Region) { | ||
| // draw a gradient so we can see what's going on. | ||
| let brush = piet | ||
| .gradient(FixedLinearGradient { | ||
| start: Point::ZERO, | ||
| end: self.size.to_vec2().to_point(), | ||
| stops: vec![ | ||
| GradientStop { | ||
| pos: 0.0, | ||
| color: Color::RED, | ||
| }, | ||
| GradientStop { | ||
| pos: 1.0, | ||
| color: Color::BLUE, | ||
| }, | ||
| ], | ||
| }) | ||
| .unwrap(); | ||
| piet.fill(Rect::ZERO.with_size(self.size), &brush); | ||
| } | ||
|
|
||
| fn command(&mut self, id: u32) { | ||
| println!("command id {}", id); | ||
| } | ||
|
|
||
| fn open_file(&mut self, _token: FileDialogToken, file_info: Option<FileInfo>) { | ||
| println!("open file result: {:?}", file_info); | ||
| } | ||
|
|
||
| fn key_down(&mut self, event: KeyEvent) -> bool { | ||
| println!("keydown: {:?}", event); | ||
| false | ||
| } | ||
|
|
||
| fn key_up(&mut self, event: KeyEvent) { | ||
| println!("keyup: {:?}", event); | ||
| } | ||
|
|
||
| fn wheel(&mut self, event: &MouseEvent) { | ||
| println!("mouse_wheel {:?}", event); | ||
| } | ||
|
|
||
| fn mouse_move(&mut self, event: &MouseEvent) { | ||
| self.handle.as_mut().unwrap().set_cursor(&Cursor::Arrow); | ||
| println!("mouse_move {:?}", event); | ||
| } | ||
|
|
||
| fn mouse_down(&mut self, event: &MouseEvent) { | ||
| println!("mouse_down {:?}", event); | ||
| } | ||
|
|
||
| fn mouse_up(&mut self, event: &MouseEvent) { | ||
| println!("mouse_up {:?}", event); | ||
| } | ||
|
|
||
| fn timer(&mut self, id: TimerToken) { | ||
| println!("timer fired: {:?}", id); | ||
| } | ||
|
|
||
| fn size(&mut self, size: Size) { | ||
| self.size = size; | ||
| } | ||
|
|
||
| fn got_focus(&mut self) { | ||
| println!("Got focus"); | ||
| } | ||
|
|
||
| fn lost_focus(&mut self) { | ||
| println!("Lost focus"); | ||
| } | ||
|
|
||
| fn request_close(&mut self) { | ||
| self.handle.as_ref().unwrap().close(); | ||
| } | ||
|
|
||
| fn destroy(&mut self) { | ||
| Application::global().quit() | ||
| } | ||
|
|
||
| fn as_any(&mut self) -> &mut dyn Any { | ||
| self | ||
| } | ||
| } | ||
|
|
||
| fn main() { | ||
| tracing_subscriber::fmt::init(); | ||
| let app = Application::new().unwrap(); | ||
| let mut builder = WindowBuilder::new(app.clone()); | ||
| builder.set_handler(Box::new(HelloState::default())); | ||
| builder.set_title("Hello example"); | ||
|
|
||
| let window = builder.build().unwrap(); | ||
| window.show(); | ||
|
|
||
| app.run(None); | ||
| } | ||
This file contains hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| pub fn locale() -> String { | ||
| fn locale_env_var(var: &str) -> Option<String> { | ||
| match std::env::var(var) { | ||
| Ok(s) if s.is_empty() => { | ||
| tracing::debug!("locale: ignoring empty env var {}", var); | ||
| None | ||
| } | ||
| Ok(s) => { | ||
| tracing::debug!("locale: env var {} found: {:?}", var, &s); | ||
| Some(s) | ||
| } | ||
| Err(std::env::VarError::NotPresent) => { | ||
| tracing::debug!("locale: env var {} not found", var); | ||
| None | ||
| } | ||
| Err(std::env::VarError::NotUnicode(_)) => { | ||
| tracing::debug!("locale: ignoring invalid unicode env var {}", var); | ||
| None | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // from gettext manual | ||
| // https://www.gnu.org/software/gettext/manual/html_node/Locale-Environment-Variables.html#Locale-Environment-Variables | ||
| let mut locale = locale_env_var("LANGUAGE") | ||
| // the LANGUAGE value is priority list seperated by : | ||
| // See: https://www.gnu.org/software/gettext/manual/html_node/The-LANGUAGE-variable.html#The-LANGUAGE-variable | ||
| .and_then(|locale| locale.split(':').next().map(String::from)) | ||
| .or_else(|| locale_env_var("LC_ALL")) | ||
| .or_else(|| locale_env_var("LC_MESSAGES")) | ||
| .or_else(|| locale_env_var("LANG")) | ||
| .unwrap_or_else(|| "en-US".to_string()); | ||
|
|
||
| // This is done because the locale parsing library we use expects an unicode locale, but these vars have an ISO locale | ||
| if let Some(idx) = locale.chars().position(|c| c == '.' || c == '@') { | ||
| locale.truncate(idx); | ||
| } | ||
| locale | ||
| } |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| // environment based utilities | ||
| pub mod env; |
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.