Commit Graph

52 Commits

Author SHA1 Message Date
Uli Schlachter a86d1137ee Select button press/release events on drawins
Some words about X11 event handling: Every X11 client can select input on any
window. For this, inside the X11 server each window has for each client a
bitmask for the kind of events that this client is interested in. When a mouse
button is pressed inside of a window, a corresponding event is generated for
that window and sent to all X11 clients which asked for
XCB_EVENT_MASK_BUTTON_PRESS. When no client is interested in this event, the
event is propagated to the parent window and the same procedure is done again
here. This continues up until the root window is reached.

Some words about the event masks that awesome uses: For clients, we ask for
button press events on the frame window that we reparent the client window into
so that we get any kind of press on the titlebar (and also events inside of the
client window if the client itself doesn't care for click events?). We are also
interested in button presses / releases on the root window. However, before this
commit, we didn't actually ask for button events on drawins (e.g. the wibox).
This worked fine, because no one asked for these events and the event propagated
to the root window where it was then sent to awesome.

However, newer Qt versions do something weird and the above broke. I don't
actually know what is going on. I know about the above propagation rules, but
looking at protocol traces of what Qt does, awesome should still get the button
events. During startup, Qt asks for button events on its own windows. After a
hotplug event, it asks the same again, but now also includes the root window.
So... how can Qt asking for button events on the root window cause awesome not
to get them? I have no idea.

(And yes, I guess that Qt asking for mouse events on the root window is a bug,
but I have no idea how exactly this happens nor about any other side effects of
it).

This commit makes us ask for button events on our drawins so that the server
will send them to us. This is the right thing to do anyway and it was reported
to have some positive effects.

Ref: https://github.com/awesomeWM/awesome/issues/415
Signed-off-by: Uli Schlachter <psychon@znc.in>
2015-12-13 18:10:29 +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 085bc00a24 Emit property::geometry only if something changed
Signed-off-by: Uli Schlachter <psychon@znc.in>
2015-10-14 19:40:18 +02:00
Uli Schlachter 438a10973b Add property::geometry to drawin/drawable [#411]
Signed-off-by: Uli Schlachter <psychon@znc.in>
2015-10-14 19:39:27 +02:00
Uli Schlachter 9408b61a97 drawin: lazily configure drawin windows
Ref: https://github.com/awesomeWM/awesome/issues/411.
Source: https://github.com/awesomeWM/awesome/pull/174#commitcomment-12708326.
(With some minor changes)
2015-08-23 15:25:23 +02:00
Daniel Hahler 178f479d15 drawin.c: check for integer for x, y, width, height
This adds luaA_getopt_integer, luaA_optinteger and luaA_checkinteger.

Lua 5.2 does not have support for this, but it would be available in Lua
5.3.

Closes https://github.com/awesomeWM/awesome/pull/320.
2015-08-12 14:07:22 +02:00
Julian Wollrath 26f15a13f3 Document C API directly in the C source code
v2: Add available signals to the docs.

Signed-off-by: Julian Wollrath <jwollrath@web.de>
2015-06-19 23:13:31 +02:00
Emmanuel Lepage Vallee e8fb93d2b6 lua: Use pushinteger for int type
Attempt to fix #238
2015-05-26 01:09:12 -04:00
Uli Schlachter 4cfea189f0 drawin: Use the correct lua_State for the stack index
This just pushed the drawin onto the stack L, but then tries to access it via
globalconf.L. This just calls for problems...

Signed-off-by: Uli Schlachter <psychon@znc.in>
2014-12-06 10:55:21 +01:00
Uli Schlachter f957764e52 drawable/drawin: Pass both lua_State and stack index around
A stack index without the corresponding lua_State pointer is useless, because it
could reference another coroutine than the main thread and thus just assuming
globalconf.L is wrong. Fix this by also passing around the corresponding
lua_State pointer.

This improves the result for the following test:

  coroutine.resume(coroutine.create(function()
      drawin({}).visible = true
  end))

Signed-off-by: Uli Schlachter <psychon@znc.in>
2014-12-06 10:46:45 +01:00
Uli Schlachter d76e20bbce drawin_update_drawing: Remove optimization for invisible drawins
This fixes the following code:

   local d = drawin({})
   d.visible = true

The drawin now has a cairo surface assigned

   d.visible = false
   d.width = 1234
   d.visible = true

The width change while the drawin was not visible would not get propagated to
the drawable because of the code that this patch removes. The expectation was
that drawin_map() would update the drawable later.

However, because the drawin was already visible, its drawable also already has
a surface assigned. Thus, drawin_map() wouldn't update the drawable either.

Fix this by just removing this optimizations.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2014-10-11 13:27:29 +02:00
Uli Schlachter 70fef83e50 drawin: Don't special-case moves
The code in drawin_moveresize() tries to be clever and only updates the drawing
state of the drawable when it is resized, not when it is moved around. This used
to be necessary because once upon a time, drawin_update_drawing() threw away all
of the drawing state and thus forcing a repaint. These days it just calls
drawable_set_geometry() as well and that function special-cases moves.

So this old code in drawin_moveresize() is no longer necessary and actually
caused problems.

These problems occurred because drawin_update_drawing() is being clever and
doesn't do anything for .visible = false drawins, because their drawing state
will be updated once they become visible. However, not skipping
drawable_set_geometry() means that this broke, because drawin_map() thought that
the drawing state was up to date while in reality it wasn't.

References: http://article.gmane.org/gmane.comp.window-managers.awesome/10852
Signed-off-by: Uli Schlachter <psychon@znc.in>
2014-10-11 13:12:57 +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 76bbf61201 drawin: Remove dead code
The only caller for drawin_unref_simplified() is in ARRAY_FUNCS() and here it is
only used in the implementation of drawin_array_wipe(). However, this function
is unused and thus we don't need drawin_unref_simplified() either.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2014-03-30 18:08:21 +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 d8b73de739 screen.[ch]: Move into objects/
Signed-off-by: Uli Schlachter <psychon@znc.in>
2014-03-30 15:12:47 +02:00
Uli Schlachter e13d848914 drawin: Correctly add property::shape_* signals
Signed-off-by: Uli Schlachter <psychon@znc.in>
2014-03-23 22:43:30 +01:00
Uli Schlachter 86f3b7f11f Drawable: Ignore exposes when we have nothing to draw
The X11 server tells us about things that need to be redrawn via expose events.
When we get such an expose event before lua drew the drawable, we just fill the
exposed area with old data (which is black for newly-created drawables).

Fix this by tracking if we have any usable data in a drawable's double buffering
pixmap. This flag is unset whenever we throw away the old content (e.g. due to a
resize) and is set when lua gave us some new content to display.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2014-03-17 16:27:10 +01:00
Uli Schlachter 794318c1a0 drawable: Add pixmap member
Previously, ownership of the pixmaps that we are using for double buffering was
a little weird. The pixmap belonged to the drawin/titlebar, but the
corresponding cairo surface was owned by the drawable. Clean this up by moving
the pixmap to the drawable.

This cleans up lots of ugly code and also fixes a crash: When a drawable was
garbage collected before its drawin, drawin_wipe() would crash accessing the
drawable. This was needed to make it forget about the cairo surface we gave to
it for the pixmap that is being destroyed.

By moving the pixmap to the drawable, this whole issues goes away.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2014-03-16 17:08:36 +01:00
Uli Schlachter 1da87eca3c Fix cairo surface memory leak
Signed-off-by: Uli Schlachter <psychon@znc.in>
2014-03-16 16:06:18 +01:00
Uli Schlachter 346034c6b6 drawin: Don't unconditionally redraw when made visible
Before this commit, we always threw away the drawin's cairo surface whenever it
was made visible and thus forced a redraw.

This commit changes this so that we only force a redraw if the drawin was
resized why it wasn't visible. To remember when this happens, we free the
drawin's cairo surface without allocating a new one when the drawin is resized
while not being visible. Thus, we then only have to allocate a new surface if
the drawin doesn't have one when it is being made visible.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2014-03-16 09:11:00 +01:00
Uli Schlachter a82b15d805 drawin: Inline drawin_init() into its only caller
Signed-off-by: Uli Schlachter <psychon@znc.in>
2014-03-16 08:56:55 +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 983001613a Drawable: Improve signal behavior
When property::surface is emitted, the drawable didn't know its geometry yet,
which had weird side effects. Fix this by changing the C API a little. The
function drawable_set_surface() now no longer allows a NULL surface as its
argument.

The required changes for the titlebar code also means that we no longer throw
away the double-buffering surface when a client is moved.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2013-02-20 14:09:19 +01:00
Uli Schlachter dac95db79b drawin: Correctly set window shape
Thanks to "rnoway" (aka Arnaud?) for noticing my typo.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2012-11-06 20:43:05 +01:00
Uli Schlachter 37d074f881 Drawin: Re-add shape support
Commit 03e0ee53d2 removed window shapes, because at the time I was too
lazy to port them from the old image system to oocairo.

This commit re-adds them, but for now only as a way to set the shape.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2012-11-05 18:11:16 +01:00
Uli Schlachter 77fedaeee8 Remove unused signal property::widgets
Signed-off-by: Uli Schlachter <psychon@znc.in>
2012-10-31 22:24:23 +01:00
Uli Schlachter c6658742ff drawin: Update the drawable's geometry on move
We only need to update a drawin's drawing related resources when its size
changes. Thus, when a drawin is just moved, drawin_update_drawing() is not
called. However, this function was used for telling the drawin's drawable about
its geometry. This means that the drawable had an outdated idea about what its
geometry was.

Fix this by making sure to always call drawable_set_geometry().

Thanks to Javafant for reporting this bug on IRC.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2012-10-26 21:11:27 +02:00
Uli Schlachter 1e418cbe3b drawable: Add property::surface
This new property is used for fixing some missing redraws that the old code had.
Those could be seen via awful.menu. Open and close a submenu repeatedly and the
submenu will appear black.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2012-10-20 22:51:52 +02: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 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
Arvydas Sidorenko d61cdb86c9 Renamed luaL_reg to luaL_Reg
The original struct name is luaL_Reg, but Lua v5.1 had a
`typedef luaL_reg luaL_Reg`, which in v5.2 was removed
and as a result breaking the build in Awesome which uses luaL_reg
version exclusively.

Signed-off-by: Arvydas Sidorenko <asido4@gmail.com>
2012-06-12 10:52:10 +02:00
Uli Schlachter 4f30dfd198 Switch from oocairo to lgi.cairo
Signed-off-by: Uli Schlachter <psychon@znc.in>
2012-05-27 19:20:34 +02:00
Uli Schlachter 20cafb4851 drawin: Remove bg_color property
The default background color (None) means that the server will leave the
window's content untouched when an exposure happens. This should get rid of all
cases of "flashing window".

The real background will later be drawn while awesome is handling the expose
event.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-12-23 16:54:55 +01:00
Uli Schlachter e40bfedd30 drawin: Don't cause X11 errors during allocation
We were only creating an X11 window for a new drawin after we handled all the
options that were passed in. However, this means that drawin({ height = 4 })
would try to resize the window before we created a window, which caused an X11
error.

Fix this by moving our initialization before of the handling of construction
arguments.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-09-12 19:38:20 +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 2729357ad2 Fix possible crash on shutdown (FS#904)
Open some windows, select a layout which does something (=not floating) and
restart awesome. It's likely that it will crash during the shutdown.

The reason is that awesome cleans up various state before going down. This is
mostly all the lua state. However, drawin_wipe, which is called for cleaning up
after a drawin, dared to emit a sigal which then let various lua code run which
had access to objects which were already destroyed.

Various bad things can happen this way, in this situation it was a crash when an
already-destroyed client was resized.

The fix is to move the signal out of drawin_wipe. It doesn't belong there
anyway. Instead, property::workarea should be emitted when the drawin's visible
property changes as this is when the workarea changes, too (screen_area_get()
only looks at visible drawins).

Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-05-14 16:54:33 +02:00
Uli Schlachter 13364a0181 Turn globalonf.drawins into the list of visible drawins
This fixes a crash when the opacity of a not-visible drawin is changed. This
happened because we got a PropertyNotify for our own change of _NET_WM_OPACITY
and then tried to set the drawin's opacity to this new value.

However, the drawin was only reachable through globalconf.drawins and wasn't
ref'd in lua.  This means that the luaA_object_push() call in
property_handle_net_wm_opacity() didn't find the drawin and instead pushed a
nil. This then later caused an unprotected lua error in window_set_opacity().

Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-03-28 08:29:30 +02:00
Uli Schlachter 08cd44dda7 drawin: Remove screen property
There isn't much point in the screen property of a drawin because the geometry
already defines on which screen the drawin is.

The biggest chunk of changes from this is due to removing the functions
drawin_detach and drawin_attach which where called when the screen property was
set/unset.

The code from drawin_detach is moved into drawin_set_visible and drawin_wipe.
drawin_attach is moved into drawin_init.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-03-27 16:21:49 +02:00
Uli Schlachter 4e31c72497 drawin: Remove some dead code
Thanks to a recent commit, a drawin's window will always be a valid and existing
window. This means we can remove all the code which checks this before doing
something.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-03-09 16:21:20 +01:00
Uli Schlachter 61fde273ca drawin: Update the drawing-stuff less often
We don't need an up-to-date pixmap and cairo surface for a drawin which isn't
visible. Thus, only bring those up-to-date when the drawin is visible.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-03-09 16:21:20 +01:00
Uli Schlachter 2f406a9385 Simplify drawin screen handling
Instead of creating/destroying a window whenever the drawin is attached/detached
from some screen, a window is now created when the drawin is created and it
isn't destroyed until the drawin is garbage collected.

Since we can now safely assume that a drawin always has a associated window,
this should make it possible to simplify some stuff.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-03-09 16:21:08 +01:00
Uli Schlachter f57dbb6a78 Remove a possibility for lua to cause X11 errors
The lua code could keep a reference to out cairo surface for a drawin after it
was destroyed. So make sure the surface is finished before the associated
drawable is destroyed.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2010-12-19 14:29:52 +01:00
Uli Schlachter da78a89dcd Remove some pointless code
This is a left-over from when widgets where removed (commit
d213f19c5f).

Signed-off-by: Uli Schlachter <psychon@znc.in>
2010-12-19 14:26:34 +01:00
Uli Schlachter 1076a6ea47 Drawin: Add bg_color property
We actually have to set a proper background color on all our drawins, else the
default black will "flicker through" while the window is drawn.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2010-12-12 21:14:04 +01:00
Uli Schlachter 742c0dead0 Systray: Fix
Signed-off-by: Uli Schlachter <psychon@znc.in>
2010-10-06 15:38:44 +02:00
Uli Schlachter d9aa194cb3 drawin: Let lua access the drawing surface
Lua now has access to a cairo surface via drawin.surface. When the drawing to
this surface is finished, it should call drawin:refresh() to make the result
visible.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2010-10-06 14:15:34 +02:00
Uli Schlachter 9c7ebf55fa Fix some style errors
Signed-off-by: Uli Schlachter <psychon@znc.in>
2010-10-06 13:53:07 +02:00