Commit Graph

70 Commits

Author SHA1 Message Date
Uli Schlachter 2023ed187a Add xcb-xfixes as a new dependency and initialise it
This commit prepares changes in the following commits

Signed-off-by: Uli Schlachter <psychon@znc.in>
2019-02-06 09:21:26 +01:00
Uli Schlachter 9f3a6757e9 Asynchronously update the keyboard state
When the keyboard layout is modified via xmodmap, each single "change"
(line of input to xmodmap) causes an "the keyboard configuration
changed"-event to be sent. Awesome reacted to each of these events by
reloading the keyboard layout. Thus, awesome reloaded the keyboard
layout a lot and appeared to freeze.

Fix this by asynchronously update the keyboard state: When such an event
comes in, instead of reloading things immediately, we set a flag which
makes us update the state at the end of the main loop iteration. This
means that many events still cause only a single (or at least few)
re-quering of the layout. Thus, a lot of time is saved.

This commit removes the argument to the (undocumented!) signal
xkb::group_changed. Previously, the argument was the active group
number. Since this argument was unused and I'm lazy, I just removed it.
The alternative would be that it might be visible to Lua that some "the
active group changed"-events are dropped.

Fixes: https://github.com/awesomeWM/awesome/issues/1494
Signed-off-by: Uli Schlachter <psychon@znc.in>
2017-03-28 15:21:01 +02: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 a4748164ab Add fallbacks for when XKB is unavailable
Fixes: https://github.com/awesomeWM/awesome/issues/1205
       (for master, dunno about 3.5)
Signed-off-by: Uli Schlachter <psychon@znc.in>
2016-11-04 17:26:28 +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 06f02f6004 Delay client frame window destruction (#1148)
Daniel sees a short flicker of his wallpaper when he closes a client.
This happens because the window is destroyed immediately, but other
clients are re-arranged only shortly later. In the mean time, the X
server updates the display and repaints the root window (= wallpaper
becomes visible).

Work around this by delaying the destruction of frame windows to the end
of the current main loop iteration. This means that we first update the
position of all other windows and later destroy the window that was
actually closed.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2016-10-07 00:46:57 +02:00
Uli Schlachter 19094de661 Speed up client_ignore_enterleave_events()
There are some situations where we do things that can make the mouse pointer
enter another window. We do not want to react to these "self inflicted" mouse
enter and leave events, because they aren't "real" (= generated by the user).

Before this commit, this is done by going through all windows and toggling the
"please send us enter and leave events"-bit on them. This becomes slower when
many windows are visible and floods the server with requests.

This commit changes this to a constant-time logic. Each event contains the
sequence number of the last request that the X11 server handled. Thus, we just
remember the right sequence numbers and ignore any events that comes in whose
sequence number falls into the ignored range.

In detail, we keep a list of "begin" and "end" sequence numbers and ignore any
enter and leave events that fall in this range. If we get any event with a
sequence number higher than "end", we remove this pair from the list, since it
is no longer needed.

To generate these pairs, we use a GrabServer request in
client_ignore_enterleave_events(). This gives us a sequence number and makes
sure that nothing else besides us can cause events. The server is ours! In
client_restore_enterleave_events(), we first do a NoOperation request to
generate the sequence number for the end of the pair and then do UngrabServer.
Any event that is generated after UngrabServer will have at least the sequence
number of the UngrabServer request and thus no longer fails between begin and
end.

Fixes: https://github.com/awesomeWM/awesome/issues/1107
Signed-off-by: Uli Schlachter <psychon@znc.in>
2016-09-30 09:37:55 +02:00
Uli Schlachter b651373cda Stop restarting on RandR changes
This commit adds a "removed" signal to screens. Together with the "added" signal
that we have since a while, this allows the C code to update the list of
available screens dynamically without needing to restart.

So far, this code received only minimal testing. So far, I don't have a nice
idea on how to easily test this...

Closes: https://github.com/awesomeWM/awesome/issues/672
Signed-off-by: Uli Schlachter <psychon@znc.in>
2016-05-01 10:09:26 +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 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 2027dd8b02 Correctly set globalconf.primary_screen under RandR
Signed-off-by: Uli Schlachter <psychon@znc.in>
2016-02-27 16:45:35 +01:00
Uli Schlachter 110893d9cb Add screen.primary
Right now this just always returns the first screens, but this can easily be
implemented properly later.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2016-02-27 15:44:25 +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 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
Uli Schlachter 42e0081958 Fix enter/leave events on titlebars
This adds a global variable that tracks the drawable that is currently under the
mouse cursor. This new variable is then used so that we get consistent behavior
for enter/leave signals. Such signals are now also generated when a MotionNotify
event tells us that the pointer is now in a different titlebar.

Before this, it was possible that we did not generate a leave event on a
titlebar since the LeaveNotify contains the cursor position after the leave and
we did not manage to figure out which titlebar was left.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2015-09-19 12:00:58 +02:00
Uli Schlachter f79b083e97 Force systray redraw on BG color change
This commit makes awesome track the current background color of the systray
window. When Lua applies another color, a redraw of all icons is forced.

Fixes: https://github.com/awesomeWM/awesome/issues/359
Closes: https://github.com/awesomeWM/awesome/pull/402

Signed-off-by: Uli Schlachter <psychon@znc.in>
2015-08-12 19:44:54 +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
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
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 0face4fea7 systray: Only register/unregister when needed
Signed-off-by: Uli Schlachter <psychon@znc.in>
2014-08-20 11:47:47 +02:00
Uli Schlachter df3e89ad5c systray: Only intern the atom once
Let's just save the systray atom and keep it around. Why should we redo this
every time this atom is needed?

Signed-off-by: Uli Schlachter <psychon@znc.in>
2014-08-20 11:40:50 +02: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
Uli Schlachter 271f084735 screen: Turn into proper lua object
This makes the screen objects use our existing infrastructure for implementing
classes and objects with lua instead of hand-rolling an own version.

This results in some small API change: Screen objects no longer have an
add_signal() function and instead this function exists on the parent screen
class.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2014-03-30 16:37:19 +02:00
Uli Schlachter 62e2dee4ba 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>
2014-03-07 16:17:40 +01:00
Uli Schlachter 56c5797905 Finish C-side support for window shapes (FS#1051)
A drawin's and a client's bounding and clip shape can now be queried and is
returned as a cairo surface.  Also, a client window's shape (e.g. xeyes setting
its own shape) can be queried via c.shape_client_bounding and
c.shape_client_clip.  All of these properties now emit signals when changed.

(This also silently fixes a bug in luaA_drawin_set_shape_bounding() which forgot
to include the drawin's border in its size calculation)

Signed-off-by: Uli Schlachter <psychon@znc.in>
2014-01-03 17:01:43 +01:00
Uli Schlachter aaa771f887 Switch from libXcursor to libxcb-cursor
Thanks to Michael Stapelberg, there is now a xcb-only port of libXcursor which
does everything we need. This patch switches awesome over to that new library.

Since the only reason for using XOpenDisplay() instead of xcb_connect() was so
that we can use libXcursor, we can get back to that older state again. This
means that this effectively reverts the following commits:

531f8b415c "Added initial support for Xlib cursor themes"
77243cd09a "Add x11-xcb to the pkg-config checks"
779d43fc46 "Don't let Xlib own the event queue"
03759b4847 "Fix keyboard layouts"

Signed-off-by: Uli Schlachter <psychon@znc.in>
2013-09-19 16:48:10 +02:00
Uli Schlachter ee1fe4dd59 Revert "Support more than 5 mouse buttons" (FS#1082)
This reverts commit bd8158495e.

The idea was to track the current list of pressed and depressed mouse buttons,
because we get button events for more than 5 buttons, but can only query the
state of the first 5 buttons.

However, there are cases where we see button presses, but won't see the
corresponding release event. This is quite bad.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2013-03-29 16:07:13 +01:00
Uli Schlachter ea30119410 Use glib instead of libev
This commit ports awesome from libev to the glib main loop. This means that
awesome has fewer dependencies, because we were already depending on glib before
and now no longer need glib.

However, the main reason for this change is that, thanks to lgi, we have glib
bindings for lua. This means that lua code can add all kinds of event sources to
the main loop (timeouts, fd watchers, SIGCHLD watchers, ....). Yay

Signed-off-by: Uli Schlachter <psychon@znc.in>
2012-11-21 21:01:12 +01:00
Uli Schlachter 8348d44444 Tags: Remove screen property
A tag's screen is now implemented purely in lua and it is no longer C's
business.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2012-10-23 10:05:34 +02:00
Uli Schlachter f0512eeaab Introduce drawables
A drawable is something that you can draw to, just like a drawin. However, a
drawable isn't necessarily its own windows. This will later on be used to
implement titlebars where the titlebars are drawables.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2012-10-14 17:30:54 +02:00
Tumin Alexander 531f8b415c Added initial support for Xlib cursor themes
I hope this time i got all right with git format-patch.

Signed-off-by: Tumin Alexander <iamtakingiteasy@eientei.org>
Signed-off-by: Uli Schlachter <psychon@znc.in>
2012-10-07 12:39:56 +02:00
Uli Schlachter 2bd29f2ab4 Add a wallpaper_changed signal
This signal fires whenever the, well, wallpaper changes. Who would have guessed?

Signed-off-by: Uli Schlachter <psychon@znc.in>
2012-04-07 21:52:24 +02:00
Uli Schlachter f9d7ac595c Add root.wallpaper() for querying the wallpaper
Signed-off-by: Uli Schlachter <psychon@znc.in>
2012-04-07 21:32:45 +02:00
Uli Schlachter 2354c6a623 Signal config errors via a naughty popup
If loading of any config file fails, awesome will now remember the error message
and make it available to lua. The default config is modified to open a naughty
popup on errors.

This should help all those people who modify their config and then wonder why
there change is ignored, not noticing awesome's error message on stderr.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-10-23 17:36:19 +02:00
Uli Schlachter 1801a8be46 Add a define for the root window's event mask
Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-10-19 15:08:54 +02:00
Gregor Best c2ea920ca0 remove encoding=utf-8 from modelines
This option is no longer valid in modelines, so it has been removed from
all modelines using the following shellscript:

    #!/bin/ksh

    git ls-tree -r HEAD | cut -f2 | while read f; do
        egrep -e '^(//|--) vim: .*encoding=' $f >/dev/null || continue
        sed -E -e '/^(\/\/|--) vim:/s/:encoding=utf-8//' $f > /tmp/foo
        mv /tmp/foo $f
    done

Signed-off-by: Gregor Best <gbe@ring0.de>
Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-09-11 17:34:09 +02:00
Uli Schlachter bd8158495e Support more than 5 mouse buttons
X11 only let's you query the state of mouse button 1 to 5. However, it can
generate ButtonPress and ButtonRelease events for up to 256 mouse buttons.

Instead of asking the server which buttons are pressed, we will now remember
the button state from those ButtonPress and ButtonRelease events. Currently
this let's us keep track of up to 32 mouse buttons.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-08-20 15:39:49 +02:00
Uli Schlachter 244d19fd0e Stop doing per-screen banning
Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-03-27 20:01:05 +02:00
Uli Schlachter 3dbf89c990 Lazyle set the input focus (FS#804)
Instead of immediately setting the X11 input focus when client.focus is assigned
something, we now just remember that we'll have to do something later. The focus
is then set in the next prepare call by libev (= after the current main loop run
is done).

Signed-off-by: Uli Schlachter <psychon@znc.in>
2010-10-10 14:57:14 +02:00
Uli Schlachter f931af7ce1 Rename globalconf.client_focus to focus.client
Signed-off-by: Uli Schlachter <psychon@znc.in>
2010-10-10 14:46:56 +02:00
Julien Danjou fe43b99a2a client: remove prev_client_focus
Not sure it's good however.

Signed-off-by: Julien Danjou <julien@danjou.info>
2010-10-10 14:05:52 +02:00
Uli Schlachter 9deafe68c8 Font: Remove, oopango took over the job
Signed-off-by: Uli Schlachter <psychon@znc.in>
2010-10-06 20:09:17 +02:00
Uli Schlachter 6826e5dfc4 Remove globalconf.colors
Signed-off-by: Uli Schlachter <psychon@znc.in>
2010-10-06 20:01:44 +02:00
Uli Schlachter 742c0dead0 Systray: Fix
Signed-off-by: Uli Schlachter <psychon@znc.in>
2010-10-06 15:38:44 +02:00
Uli Schlachter 5f5787d97b Wibox: Rename to drawin
Signed-off-by: Uli Schlachter <psychon@znc.in>
2010-10-06 13:36:02 +02:00