Commit Graph

521 Commits

Author SHA1 Message Date
Emmanuel Lepage Vallée cbd22eea50 Merge pull request #1475 from psychon/input-shape-support
Input shape support
2017-02-03 12:25:56 -05:00
Uli Schlachter 64e05c236f xwindow: Add support for input shape from SHAPE 1.1
Signed-off-by: Uli Schlachter <psychon@znc.in>
2017-01-26 10:45:24 +01:00
Uli Schlachter b4b007796c Initialise Lua later
This moves Lua initialisation to the latest possible point, just before
loading the configuration file. This requires to also move screen
initialisation and parts of EWMH initialisation to a later point.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2017-01-25 14:55:27 +01:00
Uli Schlachter 95b1305613 Refactor config fallback
Before this, there was a function which attempted to load different
configuration files in the right order. There was a boolean argument
that decided if we are actually loading it or just checking for syntax
error (for the --check argument of awesome). This lead to some
not-so-nice code since we do not want to fall-back to another config
when checking for syntax errors.

Refactor this so that there is now a function which calls a callback
function with the different paths that should be tried. This function
returns as soon as the callback function returns true.

Since just checking if the config syntax is ok does not depend on any
Lua state, an empty Lua state is now used for this.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2017-01-25 14:10:19 +01:00
Uli Schlachter 89202529ea Move some code from luaa.c to awesome.c
It makes more sense to append the xdg config dirs to our list of
searchpath in awesome.c than in luaa.c. Plus, it simplifies some of the
following work.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2017-01-25 13:50:52 +01:00
Uli Schlachter 4c322a613f Ignore SIGPIPE
When the child process in tests/_client.lua breaks and exits (for
example: Remove the call to Gtk.main), we get a broken pipe. When trying
to write to the pipe that connects awesome to the child process, we get
a SIGPIPE signal that causes awesome to exit without any good error
message.

Fix this by ignoring SIGPIPE. We do not want to be killed by it anyway.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2017-01-02 16:06:04 +01:00
Uli Schlachter 13e8088d62 Handle unexpected XCB failures (#1260)
We have many places where we are sending an XCB request and expect an
answer where the protocol guarantees that no error can occur and we are
sure to get an answer. However, for example if the X11 server crashes,
these places can still fail. This commit tries to handle failures at all
these places.

I went through the code and tried to add missing error checking (well,
NULL-pointer-checking) to all affected places.

In most cases these errors are just silently ignored. The exception is
in screen querying during startup. If, for example, querying RandR info
fails, we will fall back to Xinerama or zaphod mode. This is serious
enough that it warrants a warning. In most cases, we should exit shortly
afterwards anyway, because, as explained above, these requests should
only fail when our connection to the X11 server breaks.

References: https://github.com/awesomeWM/awesome/issues/1205#issuecomment-265869874
Signed-off-by: Uli Schlachter <psychon@znc.in>
2016-12-10 00:48:53 +01:00
Uli Schlachter c7423fe79e Really stop using Xlib
Apparently I forgot some part...?

Signed-off-by: Uli Schlachter <psychon@znc.in>
2016-11-04 17:21:06 +01:00
Uli Schlachter 0e81479a3f Use xcb-util-xrm
Instead of using Xlib for parsing resource files, this now uses the
dedicated xcb-based library that is meant for exactly this task.

Fixes: https://github.com/awesomeWM/awesome/issues/1176
Signed-off-by: Uli Schlachter <psychon@znc.in>
2016-11-03 13:34:43 +01:00
Uli Schlachter d71bb665d1 awesome.quit(): Add exit code argument (#1192)
Fixes: https://github.com/awesomeWM/awesome/issues/1184
Signed-off-by: Uli Schlachter <psychon@znc.in>
2016-10-27 10:40:53 +02:00
Uli Schlachter 3bd045b57c Check for pending events after the main loop (#1163)
At the beginning of every main loop iteration, we check for new events
from the X11 server. However, it's theoretically possible that during a
main loop iteration new events arrive and are read by libxcb into its
internal buffer. This would mean that the fd connected to the X11 server
is not readable and thus we do not wake up to handle these events.

Handle this by checking for pending events before calling poll(). If a
new events appears, we set the timeout for poll() to zero and will then
handle the new event in the following iteration of the main loop.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2016-10-22 10:46:49 +02:00
Uli Schlachter e1d5c0c925 Do not allow multiple --config arguments
Otherwise there is a small, unimportant memory leak. More important is the fact
that later such flags overwrite earlier flags.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2016-08-31 13:31:16 +02:00
Uli Schlachter 4cbf87b441 Remove empty-argument checks
This code removes code which could only be hit be running awesome --search '' or
awesome -c ''. In both cases there are many possibilities for weird/invalid
arguments and I don't see why the empty string deserves special treatment.

Note that awesome --search does NOT hit this code, because getopt_long handles
the case of "completely missing" arguments itself.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2016-08-31 13:27:07 +02:00
Uli Schlachter fd90061c24 Make argument parsing errors fatal
When you run "awesome --foobar", a warning will be printed (by getopt_long())
and awesome just ignores the invalid argument. That's unusual and weird.

This commit produces an error instead.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2016-08-31 13:26:28 +02:00
Uli Schlachter 24bb38969d Add an option to add a path to $LUA_PATH
The same effect could be achieved by modifying $LUA_PATH or with symlinks, but
having a special option to do this seems easier.

Note that the man page translations were generated via Google translate. I'm
looking forward to people submitting correct translations...

Inspired-by: https://github.com/awesomeWM/awesome/pull/485
Signed-off-by: Uli Schlachter <psychon@znc.in>
2016-08-20 16:04:11 +02:00
Uli Schlachter 80a6f2f510 Clean up static variables in event_handle
This function needs the event numbers for events from some extensions. These are
assigned dynamically by the server. Right now, this is done by having a bunch of
static variables that are initialized when needed.

Refactor this to have a function event_init() instead that sets variable in
globalconf (where all of our state should be saved). Also, a preprocessor macro
is introduced to handle event dispatch which also looks a bit nicer.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2016-04-09 15:44:54 +02:00
Uli Schlachter 9ea207afaa Revert "Only define screens after the config is loaded"
This reverts commit e6037b4738. It causes many
issues with non-trivial solutions that we first need to come up with. As a
middle ground, we will for now only emit signals if something changes after the
config is loaded.

See https://github.com/awesomeWM/awesome/issues/799.
2016-04-05 08:53:14 +02:00
Daniel Hahler 3e5b1b3ba9 Merge pull request #782 from psychon/wallpaper-change
Changes to wallpaper change
2016-04-03 18:35:27 +02:00
Uli Schlachter 3117b439a2 Cache the wallpaper
Instead of querying the wallpaper every time that root.wallpaper() is called, we
just remember it in globalconf.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2016-03-27 11:45:08 +02:00
Uli Schlachter e6037b4738 Only define screens after the config is loaded
This gives us the worst of both worlds: We still restart on RandR screen changes
and the information about screens isn't available during startup. However, it's
a step in the right direction, because all Lua code will now have to handle
kind-of-dynamic screen changes.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2016-03-27 10:51:28 +02:00
Emmanuel Lepage Vallee 03f5f5b7f9 cmd: Document --no-argb in --help 2016-03-22 03:27:59 -04:00
Uli Schlachter 68691ff818 Check that the Lua stack is empty in the main loop
The Lua stack is a finite resource and everything that pushes something there
should also clean up. This is not a problem for functions that are called by
Lua, because their "stack frame" is freed when they return. However, in global
context, Lua does not and cannot automatically clean up for us. Thus, it makes
sense to print a warning in this case.

(Additionally, this cleans up the stack if something is left)

Signed-off-by: Uli Schlachter <psychon@znc.in>
2016-02-17 18:40:01 +01:00
Uli Schlachter 4ad516c63a Remove some unused fields from globalconf
These fields were only ever written to since commit 19137a55c3.
This commit removes the fields and the code that sets them.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2015-12-22 17:25:45 +01:00
Lukáš Hrázký ea94f7f7e6 add an option to set the preferred client icon size
_NET_WM_ICON contains a list of icons and until now, the first one was
picked without regard to it's size. This adds a global option to set
the preferred icon size. When getting the client icon, the best size
match is picked. The size can be set via
awesome.set_preferred_icon_size() and the default is 0, which will pick
the smallest non-zero size icon available.

Signed-off-by: Lukáš Hrázký <lukkash@email.cz>
2015-12-07 22:59:32 +01:00
Uli Schlachter 6ca85af53b Set WM_CLASS and WM_NAME on all our windows (#551)
The only exception is the window for _NET_SUPPORTING_WM_CHECK. That window
already had a _NET_WM_NAME property before and doesn't get a WM_NAME property in
this commit. I just decided for myself that it doesn't need one. :-)

Right after startup with the default config we now have the following situation:

$ xwininfo -root -tree

xwininfo: Window id: 0x2d7 (the root window) (has no name)

  Root window id: 0x2d7 (the root window) (has no name)
  Parent window id: 0x0 (none)
     7 children:
     0x200011 "Awesome drawin": ("awesome" "awesome")  1500x20+0+0  +0+0
     0x200010 "Awesome drawin": ("awesome" "awesome")  1x1+0+0  +0+0
     0x20000d "Awesome drawin": ("awesome" "awesome")  100x30+0+0  +0+0
     0x20000a "Awesome no input window": ("awesome" "awesome")  1x1+-1+-1  +-1+-1
     0x200009 "Awesome systray window": ("awesome" "awesome")  1x1+-1+-1  +-1+-1
     0x200008 "awesome": ("awesome" "awesome")  1x1+-1+-1  +-1+-1
     0x200007 "Awesome WM_Sn selection owner window": ("awesome" "awesome")  1x1+-1+-1  +-1+-1

One of those drawin is the awful.wibox. Another drawin is created by awful.menu.
I guess that the third one is created by awful.tooltip, but I'm not sure. Wow,
so many windows...

Closes https://github.com/awesomeWM/awesome/pull/556.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2015-11-19 22:23:25 +01:00
Uli Schlachter 33f8a06594 Document "--replace" better
This adds it to the output of "awesome -h" and translates the version in the man
page to italian. Thanks, eri_trabiccolo for the translation!

Signed-off-by: Uli Schlachter <psychon@znc.in>
2015-10-11 15:00:08 +02:00
Daniel Hahler 0478b946fb Merge pull request #513 from psychon/WM_Sn_selection
Various selection stuff that ICCCM requires us to do.

Fixes https://awesome.naquadah.org/bugs/index.php?do=details&task_id=782.
Fixes https://github.com/awesomeWM/awesome/issues/292.
Closes https://github.com/awesomeWM/awesome/pull/513.
2015-10-11 13:30:32 +02:00
Uli Schlachter 7ed29196bb Make awesome.quit() during startup work
Signed-off-by: Uli Schlachter <psychon@znc.in>
2015-10-10 22:25:56 +02:00
Uli Schlachter f6e633eee4 Add a --replace argument
Signed-off-by: Uli Schlachter <psychon@znc.in>
2015-10-10 22:19:22 +02:00
Uli Schlachter 19111121ce Check if WM_Sn is already owned before acquiring it
Signed-off-by: Uli Schlachter <psychon@znc.in>
2015-10-10 22:12:25 +02:00
Uli Schlachter 86313e0afd Send an event after we acquired the WM_Sn selection
Signed-off-by: Uli Schlachter <psychon@znc.in>
2015-10-10 22:06:41 +02:00
Uli Schlachter e824f8f30d Exit when we loose the WM_Sn selection
Signed-off-by: Uli Schlachter <psychon@znc.in>
2015-10-10 21:59:12 +02:00
Uli Schlachter 5a17b3978c Acquire the WM_Sn selection during startup
Signed-off-by: Uli Schlachter <psychon@znc.in>
2015-10-10 21:51:04 +02:00
Uli Schlachter 2f78ec5b30 Never explicitly focus the root window
Whenever client.focus == nil, we set the input focus to the root window to
express "nothing has the input focus". However, thanks to the way X11 input
works, this means that whatever is under the mouse cursor gets keyboard input
events. This can easily be reproduced with urxvt and some small addition to the
config to unfocus things.

This commit changes things. Instead of focusing the root window, we create a
special "no focus" window that gets focused if we want nothing to have the
focus.

Closes https://github.com/awesomeWM/awesome/pull/470.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2015-09-28 23:36:23 +02:00
Daniel Hahler 4aa6c33951 awesome_atexit: keep client order always
This is not only useful for soft restarts, but also when TERMinating
awesome during development/testing.

The drawback appears to be that it would leak a property on the root
window in case it is really meant to be quit.

Closes https://github.com/awesomeWM/awesome/pull/374.
2015-07-30 01:04:05 +02:00
Uli Schlachter c945492176 Keep client order across restarts
This saves the order of clients in a property called AWESOME_CLIENT_ORDER on the
root window during shutdown. During startup, after managing all existing
windows, we force the client list into the order described by this property
(overwriting any changes that Lua possibly did).

This code should safely handle cases where the property doesn't contain all
existing clients or contains a client which doesn't exist anymore.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2015-07-27 13:47:09 +02:00
Uli Schlachter 86e242b983 Keep stacking order across restarts
ReparentWindow puts the window at the top of the stacking order. Thus, we have
to reparent clients back to the root window in the stacking order.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2015-07-27 13:47:09 +02:00
actionless cec04b2684 Add DPI support and 'xresources' theme
This makes awesome respect DPI settings, and adds a new theme based on
xrdb and xsettingsd color settings ("xresources").

Closes https://github.com/awesomeWM/awesome/pull/229
2015-06-25 06:40:38 +02:00
Daniel Hahler 3b366f993c Make stdout/stderr line buffered
This improves the behaviour with print()ing for debugging, when the
output is redirected to a file.

I was using `setbuf(…, 0)` initially, but it makes sense to buffer it
per line.  This uses `setvbuf` instead of `setlinebuf`, which might not
be available everywhere.

Closes https://github.com/awesomeWM/awesome/pull/267
2015-06-20 13:05:25 +02:00
Peter Junos 19137a55c3 Support for XKB - changing keyboard layouts
This commit adds support for writing in prompt (<Super>+R by default)
while different keymap is selected

Signed-off-by: Peter Júnoš <petoju@gmail.com>
2015-05-28 23:20:17 +02:00
Aleksey Fedotov 996f6785a8 xkb: implementation of keyboard layout switched
This patch provides functions to get/set current keyboard layout.

Current implementation doesn't support any configuration of layout,
it's a merely a layout indicator and switcher, however layout
configuration can be set by tools like setxkbmap or by any third-party
tools.
2015-03-03 00:33:16 +03:00
Uli Schlachter 6adeafdec3 Test if cairo-xcb is usable during startup
Create a pixmap of size 1x1 and a cairo-xcb surface for this pixmap. If the
surface ends up in an error state, awesome will refuse to start.

This turns a "awesome is unusable and prints lots of errors on X11 servers where
the root window has a depth of 8bpp and no one knows where exactly the problem
is" into "awesome refuses to start on such X11 servers and prints an error that
helps Uli to say immediately what the problem is".

Signed-off-by: Uli Schlachter <psychon@znc.in>
2015-02-18 21:23:47 +01:00
Daniel Hahler 6183d8587a Merge pull request #118 from blueyed/fix-proper-activate-via-rules
Properly fix activating an "invisible" client via rules
2015-02-14 20:55:04 +01:00
Uli Schlachter fd1b6b15cc Remove superflous xcb_flush() call (Issue #108)
Some lines down we are calling awesome_refresh(). That function already calls
xcb_flush() for us.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2015-02-14 15:43:00 +01:00
Uli Schlachter 006b43cb6f awesome: Add startup signal
Signed-off-by: Uli Schlachter <psychon@znc.in>
2015-02-14 15:41:11 +01:00
Daniel Hahler 76ede0ef45 Revert "awful.rules.execute: use delayed_call for emitting request::activate"
The 'request::activate' signal should be sent and handled immediately,
and not delayed.  It was too much of a hack to work around the client
not being visible.

Instead, the "is visible" constraint on `capi.client.focus` will be
removed.

This reverts commit 6963ede3dc.
2015-02-14 14:30:04 +01:00
Daniel Hahler 6963ede3dc awful.rules.execute: use delayed_call for emitting request::activate
This is a followup to commit 90fde13, which caused the client not to be
visible during the request::activate callback.

This requires an initial call to `awesome_refresh` before the main loop
to get `awesome.startup` right.

Ref: https://github.com/awesomeWM/awesome/commit/90fde139#commitcomment-9308225
2015-02-10 09:35:53 +01:00
Uli Schlachter 27988ecdde Remove titlebars from clients during shutdown (FS#1159)
This reparents all clients back to their proper position during shutdown, so
that their top-left corner is now where their titlebar's top-left corner was.
Hopefully, this fixes floating clients moving around across a restart.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2015-01-11 10:42:45 +01:00
Uli Schlachter e5120e1bec Hide globalconf.L
Everything that needs the lua_State should create a local variable like this:

  lua_State *L = globalconf_get_lua_State();

This ensures that the compiler warns if there are two variables with name "L" in
scope. The idea here is that it should become harder to accidentally use the
global lua state instead of the state of the current state.

While writing this commit, I found another place that gets its wrong: Reading
client.focus from a coroutine was broken, since it was returning the result on
the main thread instead of the current one.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2014-12-06 11:56:58 +01:00
Uli Schlachter d2b1e92f9e Clean up header includes
Every .c file has to include the corresponding .h file first to make sure the
headers are self-contained. Additionally, this moves some unneeded includes
around.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2014-03-30 20:07:48 +02:00