phisch
05/30/2021, 2:41 PMxcb_change_property(
this.connection,
XCB_PROP_MODE_REPLACE.toUByte(),
window,
windowTypeReply.pointed.atom,
XCB_ATOM_ATOM,
32,
2,
windowTypeDockReply.pointed.atom // THIS needs to be a CValuesRef
)
The windowTypeDockReply
is of the type CPointer<xcb_intern_atom_reply_t>
, which has a property atom
of the type xcb_atom_t
which can be accessed through the pointed property.
The function xcb_change_property
in c needs a xcb_atom_t
as its last parameter. In Kotlin however it requires a kotlinx.cinterop.CValuesRef<*>?
.
So i am wondering how i can make windowTypeDockReply.pointed.atom
into a CValuesRef
?msink
05/30/2021, 4:04 PMvoid *
, so probably .pointed.atom.ptr
phisch
05/30/2021, 4:19 PMmsink
05/30/2021, 5:08 PMphisch
05/30/2021, 5:23 PMwindowTypeDockReply.pointed.atom
?msink
05/30/2021, 5:29 PM=
or .value =
phisch
05/30/2021, 5:31 PMmsink
05/30/2021, 5:39 PMval atom = alloc<xcb_atom_t> { value = .....atom.value }
xcb_....(...., atom.ptr)
And similar to get result.
Cannot check from my phone, sorry.phisch
05/30/2021, 5:47 PMvalue
like this either, and the atom doesn`t have .ptr
. Essentially i have no idea what i am doing, i am actually just copy pasting stuff together now in the hopes that something might work. Like i just started learning to code (frustrated).phisch
05/30/2021, 5:48 PMmsink
05/30/2021, 5:52 PMmy issue is that it doesn't let me use alloc like thisDid you wrap it in
memScoped {
}
phisch
05/30/2021, 5:57 PMmsink
05/30/2021, 6:03 PMalloc
does not work inside memScoped
block.phisch
05/30/2021, 6:05 PMmsink
05/30/2021, 6:14 PMalloc<fcb_atom_tVar>
phisch
05/30/2021, 6:20 PMphisch
05/30/2021, 6:27 PMxcb_atom_tVar
(NOT xcb_atom_t
), set its value to the value of the actual thing, and then use that new variables pointer in the function call. So here for completeness the code i used:
val windowTypeReply = xcb_intern_atom_reply(
this.connection,
xcb_intern_atom(connection, 0, "_NET_WM_WINDOW_TYPE".length.toUShort(), "_NET_WM_WINDOW_TYPE"),
null
) ?: error("could not get atom")
val windowTypeDockReply = xcb_intern_atom_reply(
connection,
xcb_intern_atom(connection, 0, "_NET_WM_WINDOW_TYPE_DOCK".length.toUShort(), "_NET_WM_WINDOW_TYPE_DOCK"),
null
) ?: error("could not get atom")
memScoped {
val temporary = alloc<xcb_atom_tVar> {
value = windowTypeDockReply.pointed.atom
}
xcb_change_property(
connection,
XCB_PROP_MODE_REPLACE.toUByte(),
window,
windowTypeReply.pointed.atom,
XCB_ATOM_ATOM,
32,
1,
temporary.ptr
)
}
phisch
05/30/2021, 6:27 PMJoakimForslund
05/31/2021, 9:15 AMmsink
05/31/2021, 9:35 AM&windowTypeDockReply->atom
is legal (and actually pretty common) operation, K/N cinterop does not support it.napperley
06/02/2021, 1:13 AMnapperley
06/02/2021, 1:18 AMxcb_atom_tVar
is allocated then xcb_atom_t
is returned via the value
property.