Compare commits
2 commits
c220ea2a16
...
f8b1ed2ef1
Author | SHA1 | Date | |
---|---|---|---|
f8b1ed2ef1 | |||
5b58d8aef3 |
3 changed files with 40 additions and 5 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -59,7 +59,6 @@ dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"as-raw-xcb-connection",
|
"as-raw-xcb-connection",
|
||||||
"x11rb",
|
"x11rb",
|
||||||
"x11rb-protocol",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
|
@ -8,5 +8,4 @@ edition = "2021"
|
||||||
[dependencies]
|
[dependencies]
|
||||||
as-raw-xcb-connection = "1.0.1"
|
as-raw-xcb-connection = "1.0.1"
|
||||||
x11rb = { version = "0.13.0", features = ["extra-traits", "allow-unsafe-code"] }
|
x11rb = { version = "0.13.0", features = ["extra-traits", "allow-unsafe-code"] }
|
||||||
x11rb-protocol = { version = "0.13.0", features = ["std"] }
|
|
||||||
anyhow = "1.0.79"
|
anyhow = "1.0.79"
|
||||||
|
|
43
src/main.rs
43
src/main.rs
|
@ -3,18 +3,19 @@ use std::process::exit;
|
||||||
use anyhow::anyhow;
|
use anyhow::anyhow;
|
||||||
|
|
||||||
use x11rb::{
|
use x11rb::{
|
||||||
connect, connection::Connection, protocol::xproto::ConnectionExt, xcb_ffi::ReplyError,
|
connect, connection::Connection, protocol::xproto::{ConnectionExt, Screen},
|
||||||
};
|
};
|
||||||
use x11rb_protocol::protocol::xproto::{ChangeWindowAttributesAux, EventMask, Screen};
|
|
||||||
|
|
||||||
fn become_wm<C: Connection>(conn: &C, screen: &Screen) -> anyhow::Result<()> {
|
fn become_wm<C: Connection>(conn: &C, screen: &Screen) -> anyhow::Result<()> {
|
||||||
|
use x11rb::{protocol::xproto::{ChangeWindowAttributesAux, EventMask}, xcb_ffi::ReplyError};
|
||||||
|
|
||||||
let change = ChangeWindowAttributesAux::default()
|
let change = ChangeWindowAttributesAux::default()
|
||||||
.event_mask(EventMask::SUBSTRUCTURE_REDIRECT | EventMask::SUBSTRUCTURE_NOTIFY);
|
.event_mask(EventMask::SUBSTRUCTURE_REDIRECT | EventMask::SUBSTRUCTURE_NOTIFY);
|
||||||
|
|
||||||
let res = conn.change_window_attributes(screen.root, &change)?.check();
|
let res = conn.change_window_attributes(screen.root, &change)?.check();
|
||||||
|
|
||||||
if let Err(ReplyError::X11Error(ref error)) = res {
|
if let Err(ReplyError::X11Error(ref error)) = res {
|
||||||
use x11rb_protocol::protocol::ErrorKind;
|
use x11rb::protocol::ErrorKind;
|
||||||
|
|
||||||
if error.error_kind == ErrorKind::Access {
|
if error.error_kind == ErrorKind::Access {
|
||||||
eprintln!("rswm: another window manager is already running");
|
eprintln!("rswm: another window manager is already running");
|
||||||
|
@ -51,12 +52,48 @@ fn main() -> anyhow::Result<()> {
|
||||||
become_wm(&conn, screen)?;
|
become_wm(&conn, screen)?;
|
||||||
|
|
||||||
// TODO: setup
|
// TODO: setup
|
||||||
|
// Whole bunch to do here
|
||||||
|
// - setting up application state
|
||||||
|
// - in dwm, this is done by assigning pointers
|
||||||
|
// - we'll likely use a top level struct to do the same
|
||||||
|
// - this includes:
|
||||||
|
// - the default screen along with its size
|
||||||
|
// - the root window
|
||||||
|
// - the drawable context (or our equivalent)
|
||||||
|
// - fonts
|
||||||
|
// - bar height and padding derived from fonts
|
||||||
|
// - Xinerama information
|
||||||
|
// - atoms? whatever those are?
|
||||||
|
// - color schemes
|
||||||
|
// - initial bar rendering
|
||||||
|
// - fetch bar status
|
||||||
|
// - creating the dummy window for propriety and specification compliance
|
||||||
|
// - Have to assign a bunch of special properties here
|
||||||
|
// - set the full extent of your event_mask
|
||||||
|
// - We set SUBSTRUCTURE_REDIRECT in become_wm mostly to check for another wm
|
||||||
|
// - we have a bunch more we want, like pointer movement, button press, etc etc
|
||||||
|
// - setup key listeners
|
||||||
|
// - end by focusing the root window
|
||||||
|
// - basically all of dwm's drw.c needs to be accounted for including:
|
||||||
|
// - some utf8 management (we get that for free in Rust)
|
||||||
|
// - an abstraction for drawing over pixel maps
|
||||||
|
// - graphics context management
|
||||||
|
// - font loading and rendering
|
||||||
|
// - we *could* fall back to X core fonts, but I'd prefer not to
|
||||||
|
//
|
||||||
|
|
||||||
// TODO: pledge if on openBSD
|
// TODO: pledge if on openBSD
|
||||||
|
|
||||||
// TODO: dwm scan
|
// TODO: dwm scan
|
||||||
|
// Check for X windows to manage and manage them if needed
|
||||||
|
|
||||||
// TODO: dwm run
|
// TODO: dwm run
|
||||||
|
// event loop moment
|
||||||
|
|
||||||
// TODO: dwm cleanup
|
// TODO: dwm cleanup
|
||||||
|
// if we structure the program well, this will be done
|
||||||
|
// automatically by the borrow checker, and we don't even
|
||||||
|
// need to think about it
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue