Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 1 addition & 2 deletions src/native/linux_wayland.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1177,8 +1177,7 @@ where
(libegl.eglGetProcAddress)(name.as_ptr() as _)
});

display.decorations =
decorations::Decorations::new(&mut display, conf.platform.wayland_decorations);
display.decorations = decorations::Decorations::new(&mut display, conf);
assert!(!display.xdg_toplevel.is_null());

display.decorations.set_title(
Expand Down
19 changes: 12 additions & 7 deletions src/native/linux_wayland/decorations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,17 @@ unsafe fn create_xdg_toplevel(display: &mut WaylandPayload) {
}

impl Decorations {
pub(super) fn new(
display: &mut WaylandPayload,
fallback: crate::conf::WaylandDecorations,
) -> Self {
pub(super) fn new(display: &mut WaylandPayload, conf: &crate::conf::Conf) -> Self {
use crate::conf::WaylandDecorations::*;
unsafe {
if !display.decoration_manager.is_null() {
Decorations::server(display)
} else {
match fallback {
match conf.platform.wayland_decorations {
ServerOnly => Decorations::none(display),
ServerWithLibDecorFallback => Decorations::try_libdecor(display),
ServerWithLibDecorFallback => {
Decorations::try_libdecor(display, conf.window_resizable)
}
ServerWithMiniquadFallback => Decorations::fallback(display),
}
}
Expand Down Expand Up @@ -140,7 +139,7 @@ impl Decorations {
Decorations::Server
}

unsafe fn try_libdecor(display: &mut WaylandPayload) -> Self {
unsafe fn try_libdecor(display: &mut WaylandPayload, resizable: bool) -> Self {
if let Ok(libdecor) = LibDecor::try_load() {
let context = (libdecor.libdecor_new)(display.display, &mut LIBDECOR_INTERFACE as _);
let frame = (libdecor.libdecor_decorate)(
Expand All @@ -151,6 +150,12 @@ impl Decorations {
);
(libdecor.libdecor_frame_map)(frame);
display.xdg_toplevel = (libdecor.libdecor_frame_get_xdg_toplevel)(frame);
use extensions::libdecor::LIBDECOR_ACTION_RESIZE as RESIZE;
if resizable {
(libdecor.libdecor_frame_set_capabilities)(frame, RESIZE);
} else {
(libdecor.libdecor_frame_unset_capabilities)(frame, RESIZE);
}
Decorations::LibDecor {
libdecor,
context,
Expand Down
4 changes: 4 additions & 0 deletions src/native/linux_wayland/extensions/libdecor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ pub struct libdecor_frame_interface {

use core::ffi::{c_char, c_int, c_void};

pub const LIBDECOR_ACTION_RESIZE: c_int = 1 << 1;

declare_module! {
LibDecor,
"libdecor-0.so",
Expand All @@ -66,6 +68,8 @@ declare_module! {
) -> *mut libdecor_frame,
pub fn libdecor_frame_set_app_id(*mut libdecor_frame, *const c_char),
pub fn libdecor_frame_set_title(*mut libdecor_frame, *const c_char),
pub fn libdecor_frame_set_capabilities(*mut libdecor_frame, c_int),
pub fn libdecor_frame_unset_capabilities(*mut libdecor_frame, c_int),
pub fn libdecor_frame_map(*mut libdecor_frame),
pub fn libdecor_state_new(c_int, c_int) -> *mut libdecor_state,
pub fn libdecor_frame_commit(
Expand Down
Loading