added window name event
This commit is contained in:
parent
0dd42a7039
commit
ac433847c5
|
@ -17,6 +17,7 @@ pub enum WindowEvent<Window> {
|
||||||
EnterEvent(EnterEvent<Window>),
|
EnterEvent(EnterEvent<Window>),
|
||||||
ConfigureEvent(ConfigureEvent<Window>),
|
ConfigureEvent(ConfigureEvent<Window>),
|
||||||
FullscreenEvent(FullscreenEvent<Window>), //1 { window: Window, event: 1 },
|
FullscreenEvent(FullscreenEvent<Window>), //1 { window: Window, event: 1 },
|
||||||
|
WindowNameEvent(WindowNameEvent<Window>),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Eq, Copy, Clone)]
|
#[derive(Debug, PartialEq, Eq, Copy, Clone)]
|
||||||
|
@ -257,6 +258,18 @@ impl<Window> FullscreenEvent<Window> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct WindowNameEvent<Window> {
|
||||||
|
pub window: Window,
|
||||||
|
pub name: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<Window> WindowNameEvent<Window> {
|
||||||
|
pub fn new(window: Window, name: String) -> Self {
|
||||||
|
Self { window, name }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
|
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
|
||||||
pub struct KeyBind {
|
pub struct KeyBind {
|
||||||
pub key: VirtualKeyCode,
|
pub key: VirtualKeyCode,
|
||||||
|
|
|
@ -1,22 +1,10 @@
|
||||||
use log::{debug, error, warn};
|
use log::{debug, error, warn};
|
||||||
use num_traits::Zero;
|
use num_traits::Zero;
|
||||||
<<<<<<< HEAD
|
use std::{ptr::NonNull, rc::Rc};
|
||||||
use std::{ffi::CString, mem::MaybeUninit, ptr::NonNull, rc::Rc};
|
|
||||||
use std::{ffi::CString, rc::Rc};
|
|
||||||
>>>>>>> variant B
|
|
||||||
use std::{ffi::CString, mem::MaybeUninit, ptr::NonNull, rc::Rc};
|
|
||||||
======= end
|
|
||||||
|
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|
||||||
use x11::xlib::{self, Atom, Success, Window, XEvent, XInternAtom, XKeyEvent};
|
use x11::xlib::{self, Atom, Success, XEvent, XKeyEvent};
|
||||||
=======
|
|
||||||
use std::{mem::MaybeUninit, ptr::NonNull, rc::Rc};
|
|
||||||
|
|
||||||
use thiserror::Error;
|
|
||||||
|
|
||||||
use x11::xlib::{self, Atom, XEvent, XKeyEvent};
|
|
||||||
>>>>>>> ab99fdd (refactored atoms)
|
|
||||||
|
|
||||||
use crate::backends::{
|
use crate::backends::{
|
||||||
keycodes::KeyOrButton, xlib::keysym::mouse_button_to_xbutton,
|
keycodes::KeyOrButton, xlib::keysym::mouse_button_to_xbutton,
|
||||||
|
@ -37,7 +25,7 @@ use super::{
|
||||||
window_event::{
|
window_event::{
|
||||||
ButtonEvent, ConfigureEvent, DestroyEvent, EnterEvent, FullscreenEvent,
|
ButtonEvent, ConfigureEvent, DestroyEvent, EnterEvent, FullscreenEvent,
|
||||||
FullscreenState, KeyEvent, KeyOrMouseBind, KeyState, MapEvent,
|
FullscreenState, KeyEvent, KeyOrMouseBind, KeyState, MapEvent,
|
||||||
ModifierState, MotionEvent, UnmapEvent, WindowEvent,
|
ModifierState, MotionEvent, UnmapEvent, WindowEvent, WindowNameEvent,
|
||||||
},
|
},
|
||||||
WindowServerBackend,
|
WindowServerBackend,
|
||||||
};
|
};
|
||||||
|
@ -787,14 +775,27 @@ impl XLib {
|
||||||
let ev = unsafe { &event.property };
|
let ev = unsafe { &event.property };
|
||||||
|
|
||||||
match ev.atom {
|
match ev.atom {
|
||||||
atom if atom == self.ewmh_atoms[EWMHAtom::NetWmWindowType] => {
|
atom if atom == self.ewmh_atoms[EWMHAtom::NetWmName]
|
||||||
|
|| atom == self.atoms[ICCCMAtom::WmName] =>
|
||||||
|
{
|
||||||
|
self.get_window_name(ev.window).map(|name| {
|
||||||
|
XLibWindowEvent::WindowNameEvent(
|
||||||
|
WindowNameEvent::new(ev.window, name),
|
||||||
|
)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
atom if atom
|
||||||
|
== self.ewmh_atoms[EWMHAtom::NetWmWindowType] =>
|
||||||
|
{
|
||||||
if self
|
if self
|
||||||
.get_atom_property(
|
.get_atom_property(
|
||||||
ev.window,
|
ev.window,
|
||||||
ewmh_atoms[EWMHAtom::NetWmState],
|
self.ewmh_atoms[EWMHAtom::NetWmState],
|
||||||
)
|
)
|
||||||
.map(|atom| {
|
.map(|atom| {
|
||||||
*atom == self.ewmh_atoms[EWMHAtom::NetWmStateFullscreen]
|
*atom
|
||||||
|
== self.ewmh_atoms
|
||||||
|
[EWMHAtom::NetWmStateFullscreen]
|
||||||
})
|
})
|
||||||
.unwrap_or(false)
|
.unwrap_or(false)
|
||||||
{
|
{
|
||||||
|
@ -816,11 +817,16 @@ impl XLib {
|
||||||
let ev = unsafe { &event.client_message };
|
let ev = unsafe { &event.client_message };
|
||||||
|
|
||||||
match ev.message_type {
|
match ev.message_type {
|
||||||
message_type if message_type == self.ewmh_atoms[EWMHAtom::NetWmState] => {
|
message_type
|
||||||
|
if message_type
|
||||||
|
== self.ewmh_atoms[EWMHAtom::NetWmState] =>
|
||||||
|
{
|
||||||
let data = ev.data.as_longs();
|
let data = ev.data.as_longs();
|
||||||
if data[1] as u64 == self.ewmh_atoms[EWMHAtom::NetWmStateFullScreen]
|
if data[1] as u64
|
||||||
|
== self.ewmh_atoms[EWMHAtom::NetWmStateFullscreen]
|
||||||
|| data[2] as u64
|
|| data[2] as u64
|
||||||
== self.ewmh_atoms[EWMHAtom::NetWmStateFullscreen]
|
== self.ewmh_atoms
|
||||||
|
[EWMHAtom::NetWmStateFullscreen]
|
||||||
{
|
{
|
||||||
debug!("fullscreen event");
|
debug!("fullscreen event");
|
||||||
Some(XLibWindowEvent::FullscreenEvent(
|
Some(XLibWindowEvent::FullscreenEvent(
|
||||||
|
@ -891,7 +897,7 @@ impl XLib {
|
||||||
&mut dl0,
|
&mut dl0,
|
||||||
&mut dl1,
|
&mut dl1,
|
||||||
ptr as *mut _ as *mut _,
|
ptr as *mut _ as *mut _,
|
||||||
) == Success.into()
|
) == i32::from(Success)
|
||||||
});
|
});
|
||||||
|
|
||||||
debug!("get_atom_property: {} {:?}", success, atom_out);
|
debug!("get_atom_property: {} {:?}", success, atom_out);
|
||||||
|
|
|
@ -4,7 +4,9 @@ use log::{error, info};
|
||||||
|
|
||||||
use x11::xlib::{self, Window};
|
use x11::xlib::{self, Window};
|
||||||
|
|
||||||
use crate::backends::window_event::{FullscreenEvent, FullscreenState};
|
use crate::backends::window_event::{
|
||||||
|
FullscreenEvent, FullscreenState, WindowNameEvent,
|
||||||
|
};
|
||||||
use crate::util::{Point, Size};
|
use crate::util::{Point, Size};
|
||||||
use crate::{
|
use crate::{
|
||||||
backends::{
|
backends::{
|
||||||
|
@ -500,6 +502,9 @@ where
|
||||||
self.arrange_clients();
|
self.arrange_clients();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
WindowEvent::WindowNameEvent(WindowNameEvent { .. }) => {
|
||||||
|
info!("{:#?}", event);
|
||||||
|
}
|
||||||
|
|
||||||
// i dont think i actually have to handle destroy notify events.
|
// i dont think i actually have to handle destroy notify events.
|
||||||
// every window should be unmapped regardless
|
// every window should be unmapped regardless
|
||||||
|
|
Loading…
Reference in a new issue