Skip to content
This repository has been archived by the owner on Jun 8, 2021. It is now read-only.

Commit

Permalink
Merge pull request #127 from EPashkin/window_attr
Browse files Browse the repository at this point in the history
WindowAttr
  • Loading branch information
gkoz committed Jul 25, 2016
2 parents a141255 + eeb581f commit a6f6a67
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/lib.rs
Expand Up @@ -125,6 +125,7 @@ pub use rectangle::Rectangle;
pub use screen::Screen;
pub use visual::Visual;
pub use window::Window;
pub use window::WindowAttr;
#[cfg(feature = "v3_16")]
pub use gl_context::GLContext;

Expand Down
28 changes: 24 additions & 4 deletions src/window.rs
Expand Up @@ -27,7 +27,7 @@ use {
WMFunction,
};

pub struct Attributes {
pub struct WindowAttr {
pub title: Option<String>,
pub event_mask: i32,
pub x: Option<i32>,
Expand All @@ -42,7 +42,27 @@ pub struct Attributes {
pub type_hint: Option<WindowTypeHint>,
}

impl Attributes {
impl Default for WindowAttr {
fn default() -> WindowAttr {
skip_assert_initialized!();
WindowAttr {
title: None,
event_mask: 0,
x: None,
y: None,
width: 400,
height: 300,
wclass: WindowWindowClass::InputOutput,
visual: None,
window_type: WindowType::Toplevel,
cursor: None,
override_redirect: false,
type_hint: None,
}
}
}

impl WindowAttr {
fn get_mask(&self) -> u32 {
let mut mask = ffi::GdkWindowAttributesType::empty();
if self.title.is_some() { mask.insert(ffi::GDK_WA_TITLE); }
Expand All @@ -56,7 +76,7 @@ impl Attributes {
}
}

impl<'a> ToGlibPtr<'a, *mut ffi::GdkWindowAttr> for Attributes {
impl<'a> ToGlibPtr<'a, *mut ffi::GdkWindowAttr> for WindowAttr {
type Storage = (
Box<ffi::GdkWindowAttr>,
Stash<'a, *mut ffi::GdkVisual, Option<Visual>>,
Expand Down Expand Up @@ -99,7 +119,7 @@ glib_wrapper! {
}

impl Window {
pub fn new(parent: Option<&Window>, attributes: &Attributes) -> Window {
pub fn new(parent: Option<&Window>, attributes: &WindowAttr) -> Window {
assert_initialized_main_thread!();
unsafe {
from_glib_full(ffi::gdk_window_new(
Expand Down

0 comments on commit a6f6a67

Please sign in to comment.