Improve the check for another window manager

We detect other WMs when we fail to request SubstructureRedirect on the root
window. Previously, the code used an unchecked request and then tried to
cleverly detect if an error occurred. This isn't needed.

Instead, we now use a checked request and use xcb_request_check() to see if any
errors were generated. This also gets rid of a round-trip to the server (one is
still implicitly done by xcb_request_check()).

Signed-off-by: Uli Schlachter <psychon@znc.in>
Update the luadoc for the C API

Thanks to blueyed for noticing that awesome.font doesn't exist any more!

Signed-off-by: Uli Schlachter <psychon@znc.in>
client: Add request::activate signal (FS#848)

When we receive a _NET_ACTIVE_WINDOW request on the root window, we used to just
focus and raise the window. This didn't do much for clients which are on
non-selected tags.

Thus, this commit makes awesome emit request::activate on the client instead.
This is used in awful.ewmh to implement the old behavior again, but with
additionally marking the client as urgent if it isn't visible.

People who don't like this behavior can use client.disconnect_signal to disable
this behavior again. To make this really possible, awful.ewmh becomes a
"non-nil" module.

Signed-off-by: Uli Schlachter <psychon@znc.in>
awful.ewmh: Correctly handle bw change for maximized clients

Due to a copy&paste error, maximized_vertical and maximized_horizontal were
handled the same. Of course, vertical and horizontal aren't the same direction.

Signed-off-by: Uli Schlachter <psychon@znc.in>
client: Emit property::screen after geometry

Signed-off-by: Uli Schlachter <psychon@znc.in>
awful.ewmh: Enforce client geometry (FS#764,FS#1216)

When a client's geometry changes (and I consider the border width to be part of
the geometry here) and that client is one of fullscreen or
maximized_{horizontally,vertically}, make sure that the geometry as specified by
the state is still obeyed.

This also (accidentally) fixes things when a client gets moved to another
screen!

Signed-off-by: Uli Schlachter <psychon@znc.in>
root.wallpaper: Cleanup and correctness fixes

Turns out that my rant about "we can't query the pixmap's values" was wrong.
This commit makes awesome use a GetGeometry request to get the properties of the
(old) root window's back pixmap.

This also converts code to p_delete() instead of free() for consistency. Bad me
for doing multiple things in one commit...

Signed-off-by: Uli Schlachter <psychon@znc.in>
Revert "awful.ewmh: Enforce client geometry (FS#764,FS#1216)"

This reverts commit 20afb26080cd34691c67720fef396bed5a0be237.

The commit caused endless loops with tracebacks like this (shortened):

        lib/awful/ewmh.lua.in:122: in function <lib/awful/ewmh.lua.in:117>
        [C]: in function 'geometry'
        lib/awful/ewmh.lua.in:122: in function <lib/awful/ewmh.lua.in:117>
        [C]: in function 'geometry'
        lib/awful/ewmh.lua.in:122: in function <lib/awful/ewmh.lua.in:117>
        [C]: in function 'geometry'
mouse.screen: Lie when we have no clue where the pointer is

Signed-off-by: Uli Schlachter <psychon@znc.in>
Measure the time a main loop iteration takes

This commit makes awesome measure how long all the event handling takes. That
is, this measure the time between waking up from poll and going to sleep again.
If that time is above 0.1 seconds, we print a warning and increase the limit for
this warning to the last duration to avoid flooding messages.

This should help figuring out cases were people do stupid things in their
config, like synchronously contacting an IMAP server and getting the number of
unread mails.

Signed-off-by: Uli Schlachter <psychon@znc.in>
Update fields for capi.awesome in C comment

This should have been part of commit 2f39986, sorry!

Signed-off-by: Uli Schlachter <psychon@znc.in>
Improve fatal signal handling

First, we reset the signal handler back to the default one when a fatal signal
is received. This should make sure that we never get into an endless loop where
the signal handler causes the signal to happen again.

Then this commit also makes awesome print a backtrace on more signals than
before. Crashing with a backtrace is always better than without. ;-)

Signed-off-by: Uli Schlachter <psychon@znc.in>
awful.util.spawn*: Remove obsolete screen argument

Ever since commit 6b2e4352b (from 2010!), awesome.spawn() doesn't have a screen
argument anymore and the extra argument from util.spawn was just ignored. Fix
the code and the luadoc for these functions.

Thanks to blueyed for noticing this.

Signed-off-by: Uli Schlachter <psychon@znc.in>
Make objects properly inherit signals from classes

Signed-off-by: Uli Schlachter <psychon@znc.in>
Add awesome.register_xproperty (FS#1212)

This commits adds awesome.register_xproperty(). This allows lua code to register
arbitrary X11 properties with awesome which will then watch these properties.
Whenever such a property is changed on a client or drawin, we will emit the
xproperty::name signal.

This also adds window:get_xproperty(name) and window:set_xproperty(name, value)
which allows to mess with properties.

Signed-off-by: Uli Schlachter <psychon@znc.in>
Revert "client: Add c.blob property"

This reverts commit a54636751bef17ad6bbde266ab1d35ad0ad36c0d.

We now have the new xproperty API which does the same thing in a much nicer way.
Thanks to Elv13 for the idea!

Signed-off-by: Uli Schlachter <psychon@znc.in>
Fix handling of _NET_CURRENT_DESKTOP messages (FS#1219,FS#1217)

Instead of having the C code mess with which tags are selected, we now emit a
signal on the tag that says that something requested it to be selected. Lua can
then handle this by only switching tags on the correct monitor and by updating
the focus history correctly.

Signed-off-by: Uli Schlachter <psychon@znc.in>
xproperty: Don't limit property lengths

All that I can say is "oops, I blame copy&paste".

Thanks to Elv13 for noticing this.

Signed-off-by: Uli Schlachter <psychon@znc.in>