Add window resizing for X11
This commit is contained in:
parent
ee156fb884
commit
d61f21666c
|
@ -4,6 +4,7 @@ use raw_window_handle::{HasRawWindowHandle, RawWindowHandle};
|
|||
|
||||
use crate::event::{Event, EventStatus};
|
||||
use crate::window_open_options::WindowOpenOptions;
|
||||
use crate::Size;
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
use crate::macos as platform;
|
||||
|
@ -98,6 +99,16 @@ impl<'a> Window<'a> {
|
|||
self.window.close();
|
||||
}
|
||||
|
||||
/// Resize the window to the given size.
|
||||
///
|
||||
/// # TODO
|
||||
///
|
||||
/// This is currently only supported on Linux.
|
||||
#[cfg(target_os = "linux")]
|
||||
pub fn resize(&mut self, size: Size) {
|
||||
self.window.resize(size);
|
||||
}
|
||||
|
||||
/// If provided, then an OpenGL context will be created for this window. You'll be able to
|
||||
/// access this context through [crate::Window::gl_context].
|
||||
#[cfg(feature = "opengl")]
|
||||
|
|
|
@ -12,7 +12,7 @@ use xcb::StructPtr;
|
|||
|
||||
use super::XcbConnection;
|
||||
use crate::{
|
||||
Event, MouseButton, MouseCursor, MouseEvent, PhyPoint, PhySize, ScrollDelta, WindowEvent,
|
||||
Event, MouseButton, MouseCursor, MouseEvent, PhyPoint, PhySize, ScrollDelta, Size, WindowEvent,
|
||||
WindowHandler, WindowInfo, WindowOpenOptions, WindowScalePolicy,
|
||||
};
|
||||
|
||||
|
@ -389,6 +389,18 @@ impl Window {
|
|||
self.close_requested = true;
|
||||
}
|
||||
|
||||
pub fn resize(&mut self, size: Size) {
|
||||
xcb::configure_window(
|
||||
&self.xcb_connection.conn,
|
||||
self.window_id,
|
||||
&[
|
||||
(xcb::CONFIG_WINDOW_WIDTH as u16, size.width.round() as u32),
|
||||
(xcb::CONFIG_WINDOW_HEIGHT as u16, size.height.round() as u32),
|
||||
],
|
||||
);
|
||||
self.xcb_connection.conn.flush();
|
||||
}
|
||||
|
||||
#[cfg(feature = "opengl")]
|
||||
pub fn gl_context(&self) -> Option<&crate::gl::GlContext> {
|
||||
self.gl_context.as_ref()
|
||||
|
|
Loading…
Reference in a new issue