-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP - move xdg_shell and wl_shell specific code to their own modules
I believe this is mostly implemented however I'm not confident this is the nicest design. I'm unsure how to best modify the `Handler` pattern to handle the different shells. I've changed the Handler::configure method to take a `Configure` enum, which provides the shell-specific data. The example has not yet been updated as I'm unsure how to check whether `xdg_shell` is available and fall back to `wl_shell` otherwise. It seems this process is currently wrapped up by the `wayland_env` macro.
- Loading branch information
1 parent
07aec59
commit ffab320
Showing
6 changed files
with
285 additions
and
127 deletions.
There are no files selected for viewing
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
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 |
---|---|---|
@@ -0,0 +1,54 @@ | ||
use wayland_client::protocol::{wl_shell, wl_shell_surface, wl_surface}; | ||
use wayland_protocols::unstable::xdg_shell; | ||
|
||
#[cfg(feature = "xdg_shell")] | ||
mod xdg; | ||
mod wl; | ||
|
||
pub enum Shell { | ||
#[cfg(feature = "xdg_shell")] | ||
Xdg(xdg_shell::client::zxdg_shell_v6::ZxdgShellV6), | ||
Wl(wl_shell::WlShell), | ||
} | ||
|
||
pub enum Surface { | ||
#[cfg(feature = "xdg_shell")] | ||
Xdg(self::xdg::Surface), | ||
Wl(wl_shell_surface::WlShellSurface), | ||
} | ||
|
||
/// Configure data for a decorated surface handler. | ||
pub enum Configure { | ||
#[cfg(feature = "xdg_shell")] | ||
Xdg, | ||
Wl(wl_shell_surface::Resize), | ||
} | ||
|
||
impl Surface { | ||
|
||
pub fn from_shell(surface: &wl_surface::WlSurface, shell: &Shell) -> Self { | ||
match *shell { | ||
|
||
// Create the `xdg_surface` and assign the `toplevel` role. | ||
#[cfg(feature = "xdg_shell")] | ||
Shell::Xdg(ref shell) => { | ||
let xdg_surface = shell.get_xdg_surface(surface).expect("shell cannot be destroyed"); | ||
let toplevel = xdg_surface.get_toplevel().expect("xdg_surface cannot be destroyed"); | ||
surface.commit(); | ||
Surface::Xdg(self::xdg::Surface { | ||
surface: xdg_surface, | ||
toplevel: toplevel, | ||
}) | ||
}, | ||
|
||
// Create a `wl_shell_surface` and set it as the `toplevel`. | ||
Shell::Wl(ref shell) => { | ||
let shell_surface = shell.get_shell_surface(surface); | ||
shell_surface.set_toplevel(); | ||
Surface::Wl(shell_surface) | ||
}, | ||
|
||
} | ||
} | ||
|
||
} |
Oops, something went wrong.