c - How to draw titlebar with XCB -
i working on simple window manager in c libxcb
, trying decorate window titlebar, icon , min/max/close buttons.
i test wm in xephyr. can spawn new xterm window, move around , resize it. decorate new xterm window (or other app matter), has titlebar, icon , min/max/close buttons.
on linux machine i've installed gtk theme, , if launch firefox example, window gets decorated after set theme in settings. in case think it's gtk applies window decorations. how work?
i read ewmh window property, _net_wm_window_type
, can used determine how handle decorating window. think check if window type _net_wm_window_type_normal
, wm_name
app , manually draw titlebar on top of it.
is how should draw window decorations normally? or can use gtk (or else) this?
so in case think it's gtk applies window decorations. how work?
correct. gtk apps tell window manager not decorate them setting border width 0. suggestion implement that: if window sets border width of 0, ignore decorations it. wouldn't bother else in beginning. in fact ignore hint now.
i read ewmh window property […]
don't bother ewmh now. decorate managed windows don't set border 0. besides, don't see reason why other window types dialogs shouldn't decorated; don't think window managers use property determine that, can sure couple.
is how should draw window decorations normally? or can use gtk (or else) this?
while didn't explicitly ask this, last sentence in quote tells me might not understand how decorations work. common way, , recommend this, called reparenting.
reparenting means when manage window, create new window (which of course should not manage normal client window) called frame window , reparent client window frame window. actual top-level window frame window owned window manager; client window (the window user interacts with) direct child of it.
now make frame window larger client window , position client window correctly within it. of course need track resizes of client window , act upon them.
so why did create frame window? simple! because can create pixmap use , on draw titlebar. better drawing directly onto child window because don't mess window don't own.
drawing can done "raw" , simple calls xcb_poly_fill_rectangle
or can use more sophisticated approach by, e.g., using library cairo (which recommend). i3 window manager, example, uses simple abstraction supports both via compile flag (libi3/draw_util.c).
this reparenting approach reason why tools such xwininfo
or xprop
have -frame
option. default, these tools ignore frame window , descend client window, pretty hiding fact there frame window. try xprop
, xprop -frame
on same window , you'll see frame window has less information attached it.
once have reparenting , drawing in place can think more cases don't need / want decorate window. given there's quite bit keep track of here think implementing @ first keep busy while. recommend studying code of other simple window managers reparent.
Comments
Post a Comment