This removes our last dependency on Xlib! :)
(Okay, an Xlib dependency still comes in through other libraries that we
link against, but it’s not us. Our code is simpler by this change and
uses one less connection to X11.)
See also:
http://article.gmane.org/gmane.linux.kernel/1268792
The C compiler will handle (void) as "no arguments" and () as "variadic
function" (equivalent to (...)) which might lead to subtle errors, such
as the one which was fixed with commit 0ea64ae4.
These errors can happen because a DestroyWindow request by a client will
trigger an UnmapNotify, then a DestroyNotify. We cannot distinguish this
UnmapNotify from an UnmapNotify not followed by a DestroyNotify, so we just try
to send the ReparentWindow / ChangeProperty and ignore the errors, if any.
Actually, commit 1c5adc6c35 commented out code
without ever fixing it. I think this was responsible for the 'workspace
switching sometimes does not work' bug. My observations:
Had it again today and analyzed a log of it. Looks like after unmapping the
windows on one workspace (in my case: chromium, eclipse, urxvt, focus on
eclipse) we get UnmapNotify events for chromium and eclipse, but then we get an
EnterNotify for the terminal (due to unmapping the other windows and therefore
mapping the terminal under the cursor), only afterwards the UnmapNotify
follows.
So, there are two things wrong with that:
• We handle EnterNotifys for unmapped windows
• Unmapping windows sometimes works in a sequence, sometimes the sequence gets
split. Not sure why (if unmapping can take longer for some windows or if our
syncing is wrong -- but i checked the latter briefly and it looks correct).
Maybe GrabServer helps?
• We don’t ignore EnterNotify events caused by UnmapNotifies. We used to, but
then there was a different problem and we decided to solve the EnterNotify
problem in another way, which actually never happened (commit
1c5adc6c35).
This involves:
• Compiling with xcb-util instead of xcb-{atom,aux} (they merged the libraries)
• Not using xcb-{event,property} anymore (code removed upstream)
• Not using the predefined WINDOW, CARDINEL, … atoms (removed upstream)
• Using the new xcb_icccm_* data types/functions instead of just xcb_*
(for example xcb_icccm_get_wm_hints instead of xcb_get_wm_hints)
Also I refactored the atoms to use x-macros.
This helps for windows which are immediately destroyed instead of
unmapped, like when starting i3status | ./foobar | dzen2 -dock
and foobar does not exist (i3status and dzen2 will get a SIGPIPE).
Before this commit, i3 used key bindings in SYNC mode for bindings
like Mode_switch + <a> and replayed the key if the current state
did not include Mode_switch. This had some problems:
1) The WM needed to acknowledge much more key presses than you
actually had bindings for, thus making the system a bit laggy
sometimes.
2) Users of layouts who constantly type in the third level (like
russian layouts) did not get their cyrillic symbols correctly
(they were not replayed right), neither did the keybindings
work in both modes.
So, the current implementation uses the following approach: XKB
provides an event which contains the current state (including
the current level). i3 signs up for this event and upon receival,
it re-maps the bindings using Mode_switch (enables them when the
level goes to the third level and disables them as soon as the
level goes back to normal). This fixes both problems.
Thanks to Merovius for doing a proof of concept on this one and
being a driving force behind the idea.
Using RandR instead of Xinerama means that we are now able to use
the full potential of the modern way of configuring screens. That
means, i3 now has an idea of the outputs your graphic driver
provides, which allowed us to get rid of the ugly way of detecting
changes in the screen configuration which we used before. Now, your
workspaces should not be confused when changing output modes anymore.
Also, instead of having ugly heuristics to assign your workspaces
to (the screen at position X or the second screen in the list of
screens) you will be able to just specify an output name.
As this change basically touches everything, you should be prepared
for bugs. Please test and report them!
Thanks to Mikael for bringing it to my mind. This change introduces
two new color classes, client.urgent and bar.urgent. By default,
urgent clients are drawn in red (colors by Atsutane).
Use "bindsym" instead of "bind". You have to use the names of keys
as in xmodmap. To get a list of currently bounud symbols, use
xmodmap -pke
Technical quirk: Xlib generated MappingNotify events upon
XkbMapNotify events (from XKB, as the name says). XCB does not yet
have support for XKB, thus we need to select and handle the event
by ourself. Hopefully, this will change in the future.
Thanks to psychoschlumpf for the hint. Having comments in the headers
makes it easier to get the big picture when not being interested in the
source.
The doxygen file extracts as much as it can into HTML files. Please note
that this is not official/supported documentation, but rather being nice
to people who have to/want to use doxygen (I don’t).
Let me paste the header of the doxygen file:
You can use this file with doxygen to create a pseudo-documentation
automatically from source. doxygen-comments are not used very extensively
in i3, mostly for the reason that it clutters the source code and has no
real use (doxygen’s output looks really ugly).
So, if you want to use it, here you go. This is however not a supported
document, and I recommend you have a look at the docs/ folder or at
http://i3.zekjur.net/ for more, real documentation.
There was a race condition when mapping a window and not setting the event mask
before. Therefore, the ReparentNotify and (more important) the UnmapNotify generated
by reparenting were not received, thus leaving the awaiting_useless_unmap variable
of the client "true". To just make it work, in previous commits the DestroyNotify
handler was introduced. Fortunately, with fixing this race condition by first
setting the event mask and mapping the window afterwards, we can remove this handler.
As for the dock windows, there were quite some occurences were client->container
was used without checking if the client is inside a container at all.
Furthermore, the client’s strut containing the space to reserve at the screen edge
is now checked and the desired height is set to the window’s height if the strut
contains 0 or if no strut was specified at all.
By specifying XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT, the window manager
will get map request events instead of map notify events, and therefore
can act sooner (the window won’t be positioned on the screen and moved
afterwards).
Furthermore, this fixes some problems with GIMP/VLC (and probably others)
which caused endless loops.
Also, events which should be ignored are now saved in a queue rather than
saving just the last event. This should eliminate race conditions.
Note that there is a new FIXME in src/handlers.c. Some windows generate
unmap notify events when reparenting while others don’t. We need to
understand, document and implement a more correct way to handle this.