Skip to content

Commit da55d2e

Browse files
authored
Merge pull request #900 from xStrom/x11-close
X11: Add support for window closing and quitting.
2 parents f9da61c + 887de64 commit da55d2e

File tree

7 files changed

+588
-240
lines changed

7 files changed

+588
-240
lines changed

CHANGELOG.md

+5-2
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ While some features like the clipboard, menus or file dialogs are not yet availa
5555
### Fixed
5656

5757
- GTK: Use the system locale. ([#798] by [@finnerale])
58-
- GTK: Actually close windows ([#797] by [@finnerale])
58+
- GTK: Actually close windows. ([#797] by [@finnerale])
5959
- Windows: Respect the minimum window size. ([#727] by [@teddemunnik])
6060
- Windows: Respect resizability. ([#712] by [@teddemunnik])
6161
- `Event::HotChanged(false)` will be emitted when the cursor leaves the window. ([#821] by [@teddemunnik])
@@ -69,7 +69,9 @@ While some features like the clipboard, menus or file dialogs are not yet availa
6969
- Windows: Termiate app when all windows have closed. ([#763] by [@xStrom])
7070
- macOS: `Application::quit` now quits the run loop instead of killing the process. ([#763] by [@xStrom])
7171
- macOS/GTK/web: `MouseButton::X1` and `MouseButton::X2` clicks are now recognized. ([#843] by [@xStrom])
72-
- GTK: Support disabled menu items ([#897] by [@jneem])
72+
- GTK: Support disabled menu items. ([#897] by [@jneem])
73+
- X11: Support individual window closing. ([#900] by [@xStrom])
74+
- X11: Support `Application::quit`. ([#900] by [@xStrom])
7375

7476
### Visual
7577

@@ -146,6 +148,7 @@ While some features like the clipboard, menus or file dialogs are not yet availa
146148
[#894]: https://github.com/xi-editor/druid/pull/894
147149
[#897]: https://github.com/xi-editor/druid/pull/897
148150
[#898]: https://github.com/xi-editor/druid/pull/898
151+
[#900]: https://github.com/xi-editor/druid/pull/900
149152

150153
## [0.5.0] - 2020-04-01
151154

druid-shell/src/platform/x11/application.rs

+248-61
Large diffs are not rendered by default.

druid-shell/src/platform/x11/error.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ impl fmt::Display for Error {
3131
match self {
3232
Error::Generic(msg) => write!(f, "Error: {}", msg),
3333
Error::ConnectionError(err) => write!(f, "Connection error: {}", err),
34-
Error::BorrowError(msg) => write!(f, "Borrow error: {}", msg),
34+
Error::BorrowError(msg) => write!(f, "Failed to borrow: {}", msg),
3535
}
3636
}
3737
}

druid-shell/src/platform/x11/util.rs

+14-2
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414

1515
//! Miscellaneous utility functions for working with X11.
1616
17-
use xcb::Window;
17+
use xcb::{Connection, Screen, Visualtype, Window};
1818

1919
// See: https://github.com/rtbo/rust-xcb/blob/master/examples/randr_screen_modes.rs
20-
pub fn refresh_rate(conn: &xcb::Connection, window_id: Window) -> Option<f64> {
20+
pub fn refresh_rate(conn: &Connection, window_id: Window) -> Option<f64> {
2121
let cookie = xcb::randr::get_screen_resources(conn, window_id);
2222
let reply = cookie.get_reply().unwrap();
2323
let mut modes = reply.modes();
@@ -48,3 +48,15 @@ pub fn refresh_rate(conn: &xcb::Connection, window_id: Window) -> Option<f64> {
4848

4949
Some(refresh_rate)
5050
}
51+
52+
// Apparently you have to get the visualtype this way :|
53+
pub fn get_visual_from_screen(screen: &Screen<'_>) -> Option<Visualtype> {
54+
for depth in screen.allowed_depths() {
55+
for visual in depth.visuals() {
56+
if visual.visual_id() == screen.root_visual() {
57+
return Some(visual);
58+
}
59+
}
60+
}
61+
None
62+
}

0 commit comments

Comments
 (0)