Commit Graph

592 Commits

Author SHA1 Message Date
Uli Schlachter 2d8421730b Fix stack handling on errors for the mouse grabber
This one actually uses the return value from the function (where's the
consistency?!), so the code is fixed to only pop the return value if there is
actually one.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2016-03-06 10:52:58 +01:00
Uli Schlachter b59b28f716 Fix error handling in the keygrabber
We called the keygrabber and told Lua we are expecting one return value, so Lua
will always get us one return value on the Lua stack. However, when an error
happens, nothing is pushed on the stack, but we still tried to pop the return
value. This corrupted the Lua stack.

The easiest fix is to just not ask for a return value that is not used anyway.

Not adding a test for this, because the test has to cause a Lua error which the
C code will then log to stderr and the test runner considers this a test
failure...

Fixes: https://github.com/awesomeWM/awesome/issues/735
Signed-off-by: Uli Schlachter <psychon@znc.in>
2016-03-06 10:52:16 +01:00
Daniel Hahler 87a3233be8 Merge pull request #713 from psychon/no_focus_window
Make client key bindings for e.g. xeyes work again
2016-02-28 22:16:22 +01:00
Uli Schlachter aae960e99e Make client key bindings for e.g. xeyes work again
Instead of focusing the root window, we now create a "focus window" inside of
our frame window. This window is placed so that it is not visible, but we can
grab key bindings on it to simulate the window having the input focus.

Fixes: https://github.com/awesomeWM/awesome/issues/699
Signed-off-by: Uli Schlachter <psychon@znc.in>
2016-02-28 13:29:25 +01: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 9eab892124 Fix unbalance Lua stack usage in event_handle_leavenotify()
Commit 42e0081958 removed a call to lua_pop(L,1) that was still necessary.
This commit adds that call again.

Fixes: https://github.com/awesomeWM/awesome/issues/703
Signed-off-by: Uli Schlachter <psychon@znc.in>
2016-02-17 18:52:35 +01:00
Uli Schlachter 051d0de85f Replace many pushnumber calls with pushinteger
The only remaining calls are for a window's opacity and in the DBus type
handling. Everything else wants integers, not something with a comma.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2016-02-06 13:46:46 +01:00
Cory Burgett 5d27aa812c Add signal emission for monitor connect/disconnect 2016-01-30 12:22:03 -05:00
Uli Schlachter a98fc92b81 Move handling of MappingNotify to xkb.c
A quote from the XKeyboard specification:

  The server notifies interested clients of keyboard map changes in one of two
  ways. It sends XkbMapNotify to clients that have explicitly selected them and
  core protocol MappingNotify events to clients that have not. Once a client
  requests XkbMapNotify events, the server stops sending it MappingNotify events
  to inform it of keyboard changes.

This commit moves the code that we had for handling MappingNotify events to the
place where we handle XkbMapNotify events. This might even fix some bugs where
parts of awesome continued to use old key binding "stuff"!

Signed-off-by: Uli Schlachter <psychon@znc.in>
2016-01-23 17:03:29 +01:00
Uli Schlachter 430f4fab15 Leave titlebars early
When a client is unmanaged, we know emit mouse::leave on its titlebar before the
client object is invalidated, so that Lua can still work with it. Before, this
event was emitted only when we got a LeaveNotify from the X11 server.

Fixes: #620
Signed-off-by: Uli Schlachter <psychon@znc.in>
2016-01-10 19:27:55 +01:00
Kimball Thurston fc8c91c075 Fix focus handling with multiple awesome instances
When there are multiple X11 screens (i.e. :0.0 and :0.1) for zaphod mode
style X setups, this triggers a refresh of focus when the instance
running on a particular root receives the mouse

Fixes https://github.com/awesomeWM/awesome/issues/599.
2015-12-31 15:37:38 +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
Uli Schlachter b70af4cf2b Fix regrabbing of keys on layout change
In commit 532ec0cd, we started grabbing keys on the client window directly
instead of its parent window (the frame window). This commit fixes one place
which was overlooked back then.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2015-12-22 17:24:01 +01:00
Uli Schlachter 532ec0cd90 Grab client keys on the client window (#496)
Before this, we grabbed the keys on the frame window. That meant we only got key
events for things that nothing else grabbed directly on the key window.

After this, we grab directly on the client window itself and so we "fight" with
everything else which wants to grab keys. I don't actually know how the winner
is decided... First come, first serve, the rest gets an error?

Signed-off-by: Uli Schlachter <psychon@znc.in>
2015-10-16 17:30:46 +02:00
Daniel Hahler 208db47b2d Merge pull request #505 from psychon/fix_window_gravities
Fix window gravities
2015-10-13 11:34:37 +02:00
Daniel Hahler 75aea6086d Merge pull request #509 from psychon/systray_substructure_redirect
Select SubstructureRedirect on our systray window
2015-10-13 11:34:12 +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 4daa6e8bef Select SubstructureRedirect on our systray window
This ensures that systray icons cannot resize themselves. We assign them some
size and they have to deal with what they get!

Fixes: https://github.com/awesomeWM/awesome/issues/487

Signed-off-by: Uli Schlachter <psychon@znc.in>
2015-10-10 20:34:43 +02:00
Uli Schlachter e73335d52d Refactor code a little
The previous commit added some variables and this commit makes the surrounding
code use these new variables as well.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2015-10-10 17:42:25 +02:00
Uli Schlachter 367c3acbcd Apply window gravity when a window moves itself
This just makes us do what ICCCM requires us to do. Tested via metacity's
test-gravity.c.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2015-10-10 17:41:05 +02:00
Uli Schlachter 5760e536f9 Revert "Apply left/top titlebars in event_handle_configurerequest"
This reverts commit ecddee44cb. The commit broke
window gravities as can be reproduced with metacity's test-gravity.c.
2015-10-10 16:03:16 +02:00
Daniel Hahler 5431b18f33 Rename client_maybevisible to client_on_selected_tags
This makes it more clear what it is about, and also fixes its
documentation.
2015-09-25 00:43:52 +02:00
Uli Schlachter d96c4d61a9 Handle enter/leave events with detail=Inferior correctly
There is a client window C. Around this window, awesome adds a frame window F.
When the pointer is inside of C and then moves inside of F, we get a LeaveNotify
with detail=Inferior, but from our point of view, the pointer is still inside of
C, because F is contained in C.

Similarly, if the pointer is in F and moves to C, we get an EnterNotify with
detail=Inferior that we should ignore. However, for an EnterNotify the pointer
can now be inside of a titlebar, so this case has to be handled now.

The above explains the enter/leave behavior for clients. Let's now think about
titlebars: When the pointer moves from C to F, it cannot be in any titlebar any
more, so we must generate a leave event on that titlebar. Similar when the
pointer moves from F to C, but in this case we also have to figure out which
titlebar now contains the pointer.

This patch makes the code handle these events with detail=Inferior correctly.

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

Signed-off-by: Uli Schlachter <psychon@znc.in>
2015-09-19 12:01:10 +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
Daniel Hahler ecddee44cb Apply left/top titlebars in event_handle_configurerequest
I have noticed that the HeidiSQL session manager window/dialog will be
moved down by the height of the top titlebar when selecting an entry
from the server list.

Closes https://github.com/awesomeWM/awesome/pull/385.
2015-08-02 18:00:52 +02:00
Daniel Hahler 1118ec4439 Do not call `xcb_ungrab_key` twice (before `xwindow_grabkeys`)
It gets called in `xwindow_grabkeys` always:

    xwindow_grabkeys(xcb_window_t win, key_array_t *keys)
    {
        /* Ungrab everything first */
        xcb_ungrab_key(globalconf.connection, XCB_GRAB_ANY, win, XCB_BUTTON_MASK_ANY);

Closes https://github.com/awesomeWM/awesome/pull/366.
2015-08-01 14:16:06 +02:00
Daniel Hahler d08e82d4c8 Use luaA_dofunction with key- and mousegrabber 2015-07-22 13:52:47 +02:00
Uli Schlachter 18f6ab107f Mousegrabber: Correctly handle press/release events
When you run a mousegrabber, the C code calls this callback when the pointer is
moved or when a button is pressed/released. However, the button state is totally
bogus on press/release events, always claiming that the button that was
pressed/released is the only button that is pressed (even for release events!).

This commit fixes up the code so that the button state after the press/release
event is passed to the mousegrabber callback function.

Fixes: #280
Signed-off-by: Uli Schlachter <psychon@znc.in>
2015-07-05 16:14:41 +02:00
Peter Junos 372d12ee31 Fix incorrect behavior when modkey is pressed 2015-05-28 23:20:17 +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 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 f0ab2aebeb Don't move clients on ConfigureRequests (FS#1030)
I never saw a single program that set a border on its own windows. However,
awesome commonly sets borders on its clients and the position of a client is the
part outside of the border. So when processing a position request from a client,
we also have to include this border and fix things up correspondingly.

However, the same isn't needed for the client size, because the size does not
include the borders, but just the titlebar plus the "real" client content.

Thanks to Daniel Hahler for providing a simple test case based on urxvt for
debugging this!

Signed-off-by: Uli Schlachter <psychon@znc.in>
2014-12-05 18:40:06 +01:00
Uli Schlachter a90f0c9775 Call AllowEvents after grabbed events on a drawin
When we get an event due to a previous GrabButtons call, we have to continue
normal event processing again, because the server froze the input device for us.
Without this, everything appears to freeze.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2014-04-21 10:41:07 +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 d8b73de739 screen.[ch]: Move into objects/
Signed-off-by: Uli Schlachter <psychon@znc.in>
2014-03-30 15:12:47 +02:00
Uli Schlachter fed803a6bc client manage signal: Remove startup argument
We now have awesome.startup which does the same thing in better.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2014-03-16 20:15:02 +01:00
Uli Schlachter 6b8bd49c0b Redraw titlebars more intelligently
Whenever a titlebar of a client needed to be refreshed, all (possibly) four
titlebars would get completely refreshed. So if someone actually added more than
one titlebar to a client, awesome would copy each titlebar's content to the
window four times. Fix this by introducing more fine-grined functions for
uploads.

This also makes awesome only update the affected area when it gets an expose
event for a titlebar instead of all four titlebars completely.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2014-03-16 15:29:11 +01:00
Uli Schlachter ef27189ffe Client: Add (and use) visualtype member to client_t objects
Signed-off-by: Uli Schlachter <psychon@znc.in>
2014-03-15 11:56:57 +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 2d3103345e Implement window gravity in ConfigureRequests (FS#1137)
Previously, awesome didn't move windows when they sent a ConfigureRequest (and
it also shrunk them by the size of titlebars, before it forgot to add these).
This commit adds proper gravity support to ConfigureRequest handling.

This was tested with test-gravity from metacity (in src/wm-tester).

Signed-off-by: Uli Schlachter <psychon@znc.in>
2013-04-07 11:57:40 +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 23b30be106 Move size hints handling back into C (FS#1117)
Having this in lua means that size hints are only applied after the client got
resized. The bad side effect of this is some flickering if awesome is being
slow. And apparently, it is slow for way too many people...

Signed-off-by: Uli Schlachter <psychon@znc.in>
2013-03-10 12:13:32 +01:00
Uli Schlachter bf72cf71ea Refresh focus on FocusIn events
To avoid some oddities, awesome sets the input focus lazily. Instead of
immediately sending everything to the X11 server, awesome just sets a flag "have
to update the focus later".

However, this can cause problems. As Stefan noticed, awesome can forget about
focus changes on FocusIn events when such an event comes in while we still have
a pending focus change.

The fix here is to send out the pending focus change before we record the fact
that another client now acquired the input focus.

Reported-By: Stefan Haller <haliner@googlemail.com>
Signed-off-by: Uli Schlachter <psychon@znc.in>
2013-02-11 16:19:28 +01:00
Uli Schlachter 6a39fa46c1 wibox button: Fix the x/y position in button events
The coordinates as used by X11 place (0, 0) at the top-left corner of the
window, including its border. However, this code wants the position relative to
the drawin's content, thus we also need to substract the border width.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2012-12-16 18:17:03 +01:00
Uli Schlachter 10d48e1fc8 Send correct geometry in ConfigureNotifies
The code was sending out ConfigureNotify events which contained the size of the
frame window. Thus, the client assumed that it is was larger than it actually
was.

Fix this by subtracting the size of the titlebars from the geometry for the
event.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2012-10-29 10:20:03 +01:00
Uli Schlachter 41ef107b88 Add titlebars on the C side
This commit makes it possible to add titlebars to a client. These titlebars are
drawables.

The drawin's input handling is moved to the drawable. This allows it to use the
same code for drawin and titlebar input handling, although there are lots of
differences between the two on the C side.

On the lua side, a new wibox.drawable module is created which handles all the
drawable-specific magic and which can also be used for titlebars.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2012-10-14 17:30:59 +02:00
Uli Schlachter 10fa808a5a Ignore (Un)Grab focus notifies
When a keyboard grab activate/deactives, the input focus jumps to the window
which does the grab. These FocusIn events sometimes managed to confuse awesome.
The symptom was that a newly mapped/started client didn't receive the input
focus:

- You press your key-combo to start a terminal. This activates a passive grab
  and the input focus jumps to the root window
- The terminal opens and the "manage" rule does client.focus = c
- This doesn't set the focus yet, but instead causes
  globalconf.focus.need_update = true and .client = new_terminal
- Before the focus is updated, the key combo is released and the focus jumps
  back to the previously focused client
- The FocusIn with mode == Ungrab causes awesome to think that the previously
  focused client got focused again and thus globalconf.client.focus gets re-set
  to what it was before
- Finally the focus is refreshed and the previously focused client gets focused

The fix is simple: We don't need the FocusIn events which are generated when a
grab activates or deactivates, so we can just ignore them.

Thanks to Majic for reporting this to me.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2012-07-08 15:41:16 +02:00
Uli Schlachter d54d3840da xerror: Print numeric infos about the error
xcb_event_get_{request,error}_label() return NULL for non-core requests and
error codes. Obviously, that's not really helpful at all, so also print the
numeric information about what failed.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2012-06-15 10:02:25 +02:00
Uli Schlachter 7c7ceb1444 event: Properly ignore the "send event" flag
Thanks to muni who managed to crash his WM with conky. When conky runs in its
own window, clicking on it will sometimes (depending on the conkyrc) use
XSendEvent() to forward the event to the WM.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2012-05-19 20:20:46 +02:00