0

I'm trying to create a status bar in rust using xcb. I have written one already in C++ already using a mix of xcb and xlib so I'll be using that as a point of comparison. I'm also testing this on openbox which is a window manager written in xlib if that matters.

I'm currently unable to reserve space for my bar in the rust version. Below is the full output of xprop

WM_CLASS(STRING) = "onyxbar"
WM_NAME(STRING) = "bar"
_NET_WM_STRUT(CARDINAL) = 0, 0, 20, 0
_NET_WM_STRUT_PARTIAL(CARDINAL) = 0, 0, 20, 0, 0, 0, 0, 0, 1920, 3840, 0, 0
_NET_WM_STATE(ATOM) = _NET_WM_STATE_STICKY, _NET_WM_STATE_ABOVE
_NET_WM_WINDOW_TYPE(CARDINAL) = _NET_WM_WINDOW_TYPE_DOCK

you can see that the relevant _NET_WM_STRUT and _NET_WM_STRUT_PARTIAL are the same between this and the xprop output for my working bar in c++:

WM_STATE(WM_STATE):
                window state: Normal
                icon window: 0x0
_NET_WM_ALLOWED_ACTIONS(ATOM) = _NET_WM_ACTION_CHANGE_DESKTOP, _NET_WM_ACTION_BELOW
_KDE_NET_WM_FRAME_STRUT(CARDINAL) = 0, 0, 0, 0
_NET_FRAME_EXTENTS(CARDINAL) = 0, 0, 0, 0
_NET_WM_ICON(CARDINAL) =        Icon (48 x 48):  (some big ascii icon)
_OB_APP_TYPE(UTF8_STRING) = "dock"
_OB_APP_TITLE(UTF8_STRING) = "bar"
_OB_APP_GROUP_CLASS(UTF8_STRING) =
_OB_APP_GROUP_NAME(UTF8_STRING) =
_OB_APP_CLASS(UTF8_STRING) =
_OB_APP_NAME(UTF8_STRING) = "limebar"
_OB_APP_ROLE(UTF8_STRING) =
_NET_WM_VISIBLE_ICON_NAME(UTF8_STRING) = "bar"
_NET_WM_VISIBLE_NAME(UTF8_STRING) = "bar"
WM_CLASS(STRING) = "limebar", "", "", "", "", ""
WM_NAME(STRING) = "bar"
_NET_WM_STRUT(CARDINAL) = 0, 0, 20, 0
_NET_WM_STRUT_PARTIAL(CARDINAL) = 0, 0, 20, 0, 0, 0, 0, 0, 1920, 3840, 0, 0
_NET_WM_DESKTOP(CARDINAL) = 4294967295
_NET_WM_STATE(ATOM) = _NET_WM_STATE_ABOVE
_NET_WM_WINDOW_TYPE(ATOM) = _NET_WM_WINDOW_TYPE_DOCK

Now of course there's some extra info in the C++ version's output but it is my understanding that it's only _NET_WM_STRUT and _NET_WM_STRUT_PARTIAL that matter when it comes to reserving space. What am I missing here?

Keltek
  • 460
  • 3
  • 14

1 Answers1

1

Your working example has a WM_STATE property. The non-working does not.

This property is set by the window manager when it manages a window. Are you perhaps creating an override-redirect window in the Rust version, but not in the C++ version?

Uli Schlachter
  • 9,337
  • 1
  • 23
  • 39
  • I can't say for sure because my knowledge of all things X11 is limited but I've basically replicated the calls to xcb_change_property in rust as they are in my c++ version. Not sure what I'd be doing differently. I can post the exact code if it would help. – Keltek Mar 01 '21 at 00:47
  • 1
    In the call to `xcb_create_window`, you are likely not setting `XCB_CW_OVERRIDE_REDIRECT` to `1`. In the Rust version, you are somehow setting this override redirect flag. This is my guess. If you do not see such a difference, then yes, I'd need to see some code. – Uli Schlachter Mar 01 '21 at 06:37
  • Okay so I'm an idiot and I actually was setting override redirect to 1. I find it odd though that this project seems to do the same yet it works: https://github.com/drscream/lemonbar-xft/blob/xft-port/lemonbar.c#L922 – Keltek Mar 01 '21 at 23:36
  • 1
    They set `XCB_CW_OVERRIDE_REDIRECT` to the value of `dock` which defaults to `false` (line 115). That variable is set by the `-d` command line argument, which is documented as "Force docking (use this if your WM isn't EWMH compliant)". So, I guess that if you start lemnobar-xft with `-d`, it will also not reserve space at the edge of the screen. – Uli Schlachter Mar 02 '21 at 07:20
  • 1
    (OverrideRedirect defaults to 0/false when not explicitly set and the code you linked to just explicitly sets this implicit default.) – Uli Schlachter Mar 02 '21 at 07:20