Skip to content

Commit

Permalink
go back to CString everywhere, but it doesn't seem to help
Browse files Browse the repository at this point in the history
this did make a difference in donkey (I think), so I thought it might help here,
but the window names are still "broken"
  • Loading branch information
ntBre committed Jan 14, 2024
1 parent 47b767b commit 0b6ec4b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
3 changes: 2 additions & 1 deletion src/drw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@ impl Drw {
ty = y as usize
+ (h - (*usedfont).h) / 2
+ (*(*usedfont).xfont).ascent as usize;
let s = CString::new(utf8str).unwrap();
XftDrawStringUtf8(
d,
self.scheme.offset(if invert != 0 {
Expand All @@ -370,7 +371,7 @@ impl Drw {
(*usedfont).xfont,
x,
ty as i32,
utf8str.as_ptr(),
s.as_ptr().cast(),
utf8strlen as i32,
);
}
Expand Down
18 changes: 11 additions & 7 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -539,16 +539,17 @@ fn setup(dpy: &mut Display) {
updategeom(dpy);

// init atoms - I really hope these CStrings live long enough.
let utf8string =
XInternAtom(dpy.inner, "UTF8_STRING".as_ptr().cast(), False);
let utf8_string: CString = CString::new("UTF8_STRING").unwrap();
let utf8string = XInternAtom(dpy.inner, utf8_string.as_ptr(), False);

for (k, s) in [
(WM::Protocols, "WM_PROTOCOLS"),
(WM::Delete, "WM_DELETE_WINDOW"),
(WM::State, "WM_STATE"),
(WM::TakeFocus, "WM_TAKE_FOCUS"),
] {
let v = XInternAtom(dpy.inner, s.as_ptr().cast(), False);
let s = CString::new(s).unwrap();
let v = XInternAtom(dpy.inner, s.as_ptr(), False);
if v == BadAlloc as u64 || v == BadValue as u64 {
panic!("XInternAtom failed with {v}");
}
Expand All @@ -566,7 +567,8 @@ fn setup(dpy: &mut Display) {
(Net::WMWindowTypeDialog, "_NET_WM_WINDOW_TYPE_DIALOG"),
(Net::ClientList, "_NET_CLIENT_LIST"),
] {
let v = XInternAtom(dpy.inner, s.as_ptr().cast(), False);
let s = CString::new(s).unwrap();
let v = XInternAtom(dpy.inner, s.as_ptr(), False);
if v == BadAlloc as u64 || v == BadValue as u64 {
panic!("XInternAtom failed with {v}");
}
Expand Down Expand Up @@ -601,14 +603,15 @@ fn setup(dpy: &mut Display) {
&mut (WMCHECKWIN as u8),
1,
);
let rwm = CString::new("rwm").unwrap();
xchangeproperty(
dpy,
WMCHECKWIN,
NETATOM[Net::WMName as usize],
utf8string,
8,
PropModeReplace,
"rwm".as_ptr() as *mut _,
rwm.as_ptr().cast_mut().cast(),
3,
);
xchangeproperty(
Expand Down Expand Up @@ -2013,9 +2016,10 @@ fn updatebars(dpy: &Display) {
colormap: 0,
cursor: 0,
};
let rwm = CString::new("rwm").unwrap();
let mut ch = XClassHint {
res_name: "rwm".as_ptr() as *mut _,
res_class: "rwm".as_ptr() as *mut _,
res_name: rwm.as_ptr().cast_mut(),
res_class: rwm.as_ptr().cast_mut(),
};

unsafe {
Expand Down

0 comments on commit 0b6ec4b

Please sign in to comment.