Skip to content
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

X11 implementation of druid-shell #599

Merged
merged 36 commits into from
Apr 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
650c23b
Skeleton X11 backend; everything is unimplemented!()
crsaracco Feb 13, 2020
661111b
Compiles and runs, but does nothing.
crsaracco Feb 16, 2020
cfd1b5a
Huge hacks to try to get X11 window painting working
crsaracco Feb 17, 2020
3dce469
It draws stuff!
crsaracco Feb 17, 2020
2d39f48
Schedule redraws by sleeping (TODO: fix later)
crsaracco Feb 29, 2020
3f51c1d
Make menu functions no-ops so the 'shello' example doesn't crash
crsaracco Feb 29, 2020
7d2c053
Make TODOs easier to grep
crsaracco Feb 29, 2020
f3b3994
Knock out a bunch of the easier 'initial_pr' TODOs
crsaracco Feb 29, 2020
179f781
implement WindowHandle::close and WindowHandle::bring_to_front_and_focus
crsaracco Mar 1, 2020
c6f43ce
Run github workflows for druid_shell_x11 branch; fix workflow errors
crsaracco Mar 1, 2020
4b3889c
keycodes
perlindgren Mar 1, 2020
a004f8e
mouse down
perlindgren Mar 1, 2020
835ebd4
review updates
Mar 2, 2020
13dbbc6
Merge pull request #1 from perlindgren/druid_shell_x11_pln
crsaracco Mar 2, 2020
ed0d646
Quick cleanup of X11 platform code before PR
crsaracco Mar 4, 2020
99b7188
Merge remote-tracking branch 'origin/master' into rebase-x11
cmyr Mar 5, 2020
d357581
[ci] Run x11 backend in ci
cmyr Mar 5, 2020
f185e7a
Post merge fixes
cmyr Mar 5, 2020
be56617
Merge pull request #2 from cmyr/update-to-master
crsaracco Mar 5, 2020
d910860
s/use_x11/x11
crsaracco Mar 8, 2020
6967fcc
Fix X11 hackery in examples
crsaracco Mar 8, 2020
5622ac0
Update copyright year in druid-shell/src/platform/x11 files
crsaracco Mar 8, 2020
f32c1c2
Delete runloop.rs
crsaracco Mar 8, 2020
a71e593
Turn all unimplemented!() calls into log::warn!() calls
crsaracco Mar 8, 2020
566e3c5
Return unknown keycode directly instead of using unreachable!()
crsaracco Mar 8, 2020
f9c6b82
Update visibility on XWindow to pub(crate) instead of pub
crsaracco Mar 8, 2020
49d7670
Fix clippy warnings for X11 implementation
crsaracco Mar 8, 2020
d1ebf76
Small PR review cleanups
crsaracco Mar 14, 2020
9abe0d2
update README with X11 info
crsaracco Mar 16, 2020
47905b0
Re-create X11 piet context every redraw
crsaracco Mar 29, 2020
743afe6
Communicate window size back to Druid
crsaracco Apr 5, 2020
080fc9d
handle mouse_up and mouse_move
crsaracco Apr 5, 2020
f1a40af
Make X11 window respond to window resize events.
crsaracco Apr 5, 2020
bb407d3
Flush XCB event queue when requesting redraw
crsaracco Apr 5, 2020
fe1405d
Code review fixes
crsaracco Apr 5, 2020
c641a99
Merge master into druid_shell_x11
crsaracco Apr 5, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 64 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,40 +78,47 @@ jobs:
profile: minimal
override: true

- name: cargo clippy (no-svg)
- name: cargo clippy (druid)
uses: actions-rs/cargo@v1
with:
command: clippy
args: --all -- -D warnings
if: contains(matrix.os, 'ubuntu') != true
args: --manifest-path=druid/Cargo.toml --features=svg,image -- -D warnings

- name: cargo clippy (svg)
- name: cargo clippy (druid-shell)
uses: actions-rs/cargo@v1
with:
command: clippy
args: --all --all-features -- -D warnings
if: contains(matrix.os, 'ubuntu')
args: --manifest-path=druid-shell/Cargo.toml -- -D warnings

- name: cargo clippy (druid-derive)
uses: actions-rs/cargo@v1
with:
command: clippy
args: --manifest-path=druid-derive/Cargo.toml -- -D warnings

- name: cargo test --all
- name: cargo test (druid)
uses: actions-rs/cargo@v1
with:
command: test
args: --all
if: contains(matrix.os, 'ubuntu') != true
args: --manifest-path=druid/Cargo.toml --features=svg,image

- name: cargo test --all --all-features
- name: cargo test (druid-shell)
uses: actions-rs/cargo@v1
with:
command: test
args: --all --all-features
if: contains(matrix.os, 'ubuntu')
args: --manifest-path=druid-shell/Cargo.toml

- name: cargo test (druid-derive)
uses: actions-rs/cargo@v1
with:
command: test
args: --manifest-path=druid-shell/Cargo.toml

- name: Run rustc -D warnings in druid/
uses: actions-rs/cargo@v1
with:
command: rustc
args: --manifest-path=druid/Cargo.toml -- -D warnings
args: --manifest-path=druid/Cargo.toml --features=svg,image -- -D warnings

- name: Run rustc -d warnings in druid/druid-shell
uses: actions-rs/cargo@v1
Expand Down Expand Up @@ -188,3 +195,47 @@ jobs:
with:
command: doc
args: --document-private-items

# by default on linux we test gtk; to test x11 we need a separate job.
test-stable-x11:
runs-on: ubuntu-latest
name: cargo test stable (x11)
steps:
- uses: actions/checkout@v1

- name: install deps
run: |
sudo apt update
sudo apt install libx11-dev libgtk-3-dev

- name: install stable toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
components: clippy
profile: minimal
override: true

- name: cargo clippy (x11)
uses: actions-rs/cargo@v1
with:
command: clippy
args: --manifest-path=druid-shell/Cargo.toml --features=x11 -- -D warnings

- name: cargo test druid-shell
uses: actions-rs/cargo@v1
with:
command: test
args: --manifest-path=druid-shell/Cargo.toml --features=x11

- name: cargo test druid
uses: actions-rs/cargo@v1
with:
command: test
args: --manifest-path=druid/Cargo.toml --features=x11

- name: Run rustc -d warnings in druid/druid-shell
uses: actions-rs/cargo@v1
with:
command: rustc
args: --manifest-path=druid-shell/Cargo.toml --features=x11 -- -D warnings
23 changes: 23 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,10 @@ should be sufficient. Removing this dependency is on the roadmap.
On Linux, druid requires gtk+3; see [gtk-rs dependencies] for installation
instructions.

Alternatively, there is an X11 backend available, although it is currently
[missing quite a few features](https://github.com/xi-editor/druid/issues/475).
You can try it out with `--features=x11`.

## Alternatives

Druid is only one of many ongoing [Rust-native GUI experiments]. To mention a
Expand Down
6 changes: 5 additions & 1 deletion druid-shell/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ edition = "2018"

[features]
use_gtk = ["gtk", "gtk-sys", "gio", "gdk", "gdk-sys", "glib", "glib-sys", "cairo-rs"]
x11 = ["xcb", "cairo-sys-rs"]

[package.metadata.docs.rs]
default-target = "x86_64-pc-windows-msvc"
Expand All @@ -25,13 +26,15 @@ cfg-if = "0.1.10"
kurbo = "0.5.11"

cairo-rs = { version = "0.8.1", default_features = false, optional = true }
cairo-sys-rs = { version = "0.9.2", default_features = false, optional = true }
gio = { version = "0.8.1", optional = true }
gdk = { version = "0.12.1", optional = true }
gdk-sys = { version = "0.9.0", optional = true }
gtk = { version = "0.8.1", optional = true }
glib = { version = "0.9.3", optional = true }
glib-sys = { version = "0.9.0", optional = true }
gtk-sys = { version = "0.9.0", optional = true }
xcb = { version = "0.9.0", features = ["thread", "xlib_xcb", "randr"], optional = true }

[target.'cfg(target_os="windows")'.dependencies]
wio = "0.2"
Expand All @@ -45,8 +48,9 @@ cocoa = "0.20.0"
objc = "0.2.5"
cairo-rs = { version = "0.8.1", default_features = false }

# TODO(x11/dependencies): only use feature "xcb" if using XCB
[target.'cfg(target_os="linux")'.dependencies]
cairo-rs = { version = "0.8.1", default_features = false }
cairo-rs = { version = "0.8.1", default_features = false, features = ["xcb"] }
gio = "0.8.1"
gdk = "0.12.1"
gdk-sys = "0.9.0"
Expand Down
1 change: 1 addition & 0 deletions druid-shell/examples/perftest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,5 +121,6 @@ fn main() {

let window = builder.build().unwrap();
window.show();

app.run();
}
4 changes: 3 additions & 1 deletion druid-shell/examples/shello.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ impl WinHandler for HelloState {
let deadline = std::time::Instant::now() + std::time::Duration::from_millis(500);
let id = self.handle.request_timer(deadline);
println!("keydown: {:?}, timer id = {:?}", event, id);

false
}

Expand Down Expand Up @@ -133,8 +134,9 @@ fn main() {
builder.set_handler(Box::new(HelloState::default()));
builder.set_title("Hello example");
builder.set_menu(menubar);
let window = builder.build().unwrap();

let window = builder.build().unwrap();
window.show();

app.run();
}
1 change: 1 addition & 0 deletions druid-shell/src/common_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ use std::sync::atomic::{AtomicU64, Ordering};
/// Strip the access keys from the menu string.
///
/// Changes "E&xit" to "Exit". Actual ampersands are escaped as "&&".
#[cfg(not(feature = "x11"))]
#[cfg(any(target_os = "macos", target_os = "linux"))]
pub fn strip_access_key(raw_menu_text: &str) -> String {
let mut saw_ampersand = false;
Expand Down
1 change: 1 addition & 0 deletions druid-shell/src/dialog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ pub struct FileInfo {
}

/// Type of file dialog.
#[cfg(not(feature = "x11"))]
pub enum FileDialogType {
/// File open dialog.
Open,
Expand Down
4 changes: 4 additions & 0 deletions druid-shell/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ extern crate objc;
#[macro_use]
extern crate lazy_static;

#[cfg(all(target_os = "linux", feature = "x11"))]
#[macro_use]
extern crate lazy_static;

mod application;
mod clipboard;
mod common_util;
Expand Down
3 changes: 3 additions & 0 deletions druid-shell/src/platform/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ cfg_if::cfg_if! {
} else if #[cfg(all(target_os = "macos", not(feature = "use_gtk")))] {
mod mac;
pub use mac::*;
} else if #[cfg(all(feature = "x11", target_os = "linux"))] {
mod x11;
pub use x11::*;
} else if #[cfg(any(feature = "use_gtk", target_os = "linux"))] {
mod gtk;
pub use self::gtk::*;
Expand Down
Loading