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

pub type Window = c_void;

#[repr(C)]
pub struct FakeGroupLeader {
    identifier: *mut c_char,
    leader: x11::xlib::Window,
    orig_leader: x11::xlib::Window,
    retain_count: c_int,
}

pub type WindowAttributes = c_void;

pub mod ffi {
    use std::ffi::{c_char, c_int};

    use super::{FakeGroupLeader, Window, WindowAttributes};

    unsafe extern "C" {
        pub fn wWindowGetFakeGroup(window: *mut Window) -> *mut FakeGroupLeader;
        pub fn wWindowSetFakeGroup(winow: *mut Window, fake_group: *mut FakeGroupLeader);

        pub fn wWindowGetMainWindow(window: *mut Window) -> x11::xlib::Window;
        pub fn wWindowSetMainWindow(win: *mut Window, window: x11::xlib::Window);

        pub fn wWindowGetNetIconImage(window: *mut Window) -> *mut crate::wrlib::Image;
        pub fn wWindowSetNetIconImage(window: *mut Window, image: *mut crate::wrlib::Image);

        pub fn wWindowGetClientWin(window: *mut Window) -> x11::xlib::Window;

        pub fn wWindowGetScreenPtr(window: *mut Window) -> *mut crate::screen::Screen;
        pub fn wWindowSetScreenPtr(window: *mut Window, scr: *mut crate::screen::Screen);

        pub fn wWindowSetWmHints(win: *mut Window, wm_hints: *mut x11::xlib::XWMHints);

        pub fn wWindowSetWmClass(window: *mut Window, wm_class: *mut c_char);

        pub fn wWindowSetWmInstance(window: *mut Window, wm_instance: *mut c_char);

        pub fn wWindowGetUserFlags(window: *mut Window) -> *const WindowAttributes;
        pub fn wWindowGetUserFlagsMut(window: *mut Window) -> *mut WindowAttributes;

        pub fn wWindowGetDefinedUserFlags(window: *mut Window) -> *const WindowAttributes;
        pub fn wWindowGetDefinedUserFlagsMut(window: *mut Window) -> *mut WindowAttributes;

        pub fn wWindowGetClientFlags(window: *mut Window) -> *const WindowAttributes;


        pub fn wWindowAttributesGetStartHidden(attrs: *const WindowAttributes) -> c_int;
        pub fn wWindowAttributesGetEmulated(attrs: *const WindowAttributes) -> c_int;

        pub fn wWindowFor(window: x11::xlib::Window) -> *mut Window;

        pub fn wWindowCreate() -> *mut Window;

        pub fn wWindowDestroy(main_window_desc: *mut Window);
    }
}
