Commit Graph

723 Commits

Author SHA1 Message Date
Uli Schlachter 2cf4ea5cd4 xutil.h: Add defines for valid coordinates and sizes
Signed-off-by: Uli Schlachter <psychon@znc.in>
2016-04-17 13:48:24 +02:00
Uli Schlachter 93e50b2e23 Merge branch 'lua-index-handlers' of https://github.com/psychon/awesome 2016-03-06 14:19:00 +01:00
Uli Schlachter f02b75f826 Fix arguments to luaL_checkstack()
The argument to luaL_checkstack() is the amount of new stack to make available,
not the new size of the stack. Thus, remove the addition of lua_gettop(L) here.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2016-02-17 19:07:06 +01:00
Uli Schlachter d09ece6b5a Require "integer" instead of "number" in more places
E.g. trying to press mouse button 1.5 via root.fake_input() doesn't make sense.
Previously the code silently truncated the number to an integer. Now it
complains about this instead.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2016-02-06 13:59:14 +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
Uli Schlachter 44fcfa2d48 Remove prototype of xutil_lock_mask_get()
This function was removed in 4ad516c63a, but I forgot to also remove it
from header. Whoops...

Signed-off-by: Uli Schlachter <psychon@znc.in>
2016-01-23 17:12:10 +01:00
Uli Schlachter 720cd879f3 Add timestamps to messages on stderr (#602)
Closes https://github.com/awesomeWM/awesome/pull/606.
Fixes https://github.com/awesomeWM/awesome/issues/602.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2015-12-31 15:38:17 +01:00
Uli Schlachter 5e6a893207 Replace various calls to warn() with luaA_warn()
luaA_warn() prints a Lua backtrace and thus generates more useful output. warn()
should only be used in awesome-internal places (e.g. receiving an error from the
X11 server).

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

Signed-off-by: Uli Schlachter <psychon@znc.in>
2015-12-31 15:35:13 +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 a141370704 Add a vim modeline to all C source
Most of the files already had this, at least.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2015-12-12 17:42:16 +01:00
Uli Schlachter 97048de60e Remove useless information from awesome -v
Most of this information isn't interesting. If you are getting awesome from a
distro, then the time, hostname and username of the build are likely 'random
stuff' and if you are building awesome yourself, then the hostname and username
are obviously yours and the time can still be interfered based on the awesome's
binary ctime.

The GCC version shouldn't make any difference at all.

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

Signed-off-by: Uli Schlachter <psychon@znc.in>
2015-12-01 20:17:21 +01:00
Kazunobu Kuriyama 2f7f25dcc7 Fix the definition of A_STRNEQ_CASE
Replace A_STRCASEEQ whose definition is not given anywhere with A_STREQ_CASE.

Closes https://github.com/awesomeWM/awesome/pull/488.
2015-09-28 23:34:52 +02:00
Uli Schlachter a5a106f97f Make it possible for Lua to emulate arbitrary properties
This makes it possible to add something similar to a __index / __newindex
metamethod to all our C objects. Based on this, Lua can then easily implement
arbitrary properties on our capi objects.
2015-09-27 17:43:41 +02:00
Daniel Hahler 481cd8f843 minor: doc: fix typo in buffer_init 2015-07-28 19:31:51 +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
Daniel Hahler 3cd0bb5783 common/array.h: add macro `foreach_reverse`
Ref: https://github.com/awesomeWM/awesome/pull/340
2015-07-25 16:42:50 +02:00
Daniel Hahler 1050237d04 minor: fix/improve doc comments 2015-07-12 17:42:53 +02:00
Uli Schlachter 55bffbcc45 Fix for previous commit
Forgot to commit the change that adds _NET_FRAME_EXTENTS to the list of atoms
that we actually query for and export to the C code.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2015-07-05 15:34:23 +02:00
Daniel Hahler d4d5bbcd5d Merge pull request #266 from awesomeWM/juw-docs
docs: move documentation to C source
2015-06-21 21:33:22 +02:00
Uli Schlachter 1408e8b952 Unset object's metatable in __gc
Run the following code:

  do
      local d
      local f = function() d.visible = true end
      if _VERSION >= "Lua 5.2" then
          setmetatable({}, { __gc = f })
      else
          getmetatable(newproxy(true)).__gc = f
      end
      d = drawin({})
  end
  collectgarbage("collect")

Awesome will segfault.

The reason for this is that after the above code ran, all variables in it are
unreferenced and will be garbage-collected at the next sweep phase. Lua runs
garbage collectors in the inverse order that their corresponding objects were
"marked" which means for the above code that the drawin's garbage collector will
run before function f runs. So the code will access the drawin after its
destructor already ran. Obviously, awesome's C code does not expect nor
correctly deal with this situation and was dereferencing a NULL pointer.

To fix this, this commit "unsets" the metatable of a userdata object when it is
being garbage collected. Since the type of a userdata is inferred via its
metatable, the object will no longer be accepted by luaA_toudata().

For the above code this will result in an unhelpful error message saying that
something tried to index a userdata, but userdata cannot be indexed. At least we
no longer crash and the traceback of the error will hopefully point at some __gc
metamethod which should be enough of a hint to figure out the problem.

Thanks-to: http://blog.reverberate.org/2014/06/beware-of-lua-finalizers-in-c-modules.html
Signed-off-by: Uli Schlachter <psychon@znc.in>
2015-06-20 12:33:17 +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
Uli Schlachter f5610fa920 objects: Add .valid property (Fixes #110)
This property is especially useful for client objects which are unusable after
unmanage. "Unusuable" here means that pretty much everything you do with the
client object results in a lua error.

Syntax is c.valid.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2015-02-15 12:16:03 +01:00
Daniel Hahler f562b4a64b luaA_object_emit_signal: check for valid object
By the time a signal gets emitted the object might be invalid already,
e.g. when it is very short-lived and unmanaged by the time the delayed
call to emit_signal is being invoked.

Ref: https://github.com/awesomeWM/awesome/pull/87#issuecomment-70901168
2015-02-10 14:52:47 +01:00
Uli Schlachter 8eed5e7bcf client: Include c.name in the result of tostring(c)
Signed-off-by: Uli Schlachter <psychon@znc.in>
2014-12-06 18:16:05 +01:00
Uli Schlachter a7cdbf468b Only include awesome-version-internal.h in one place
This means we have one less file which gets recompiled every time the result
from "git describe" changes.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2014-04-13 17:48:03 +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 1b21dce46c Revert "client: Add c.blob property"
This reverts commit a54636751b.

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>
2014-03-07 16:21:11 +01:00
Uli Schlachter 2b1febeabe Make objects properly inherit signals from classes
Signed-off-by: Uli Schlachter <psychon@znc.in>
2014-03-07 14:42:03 +01:00
Uli Schlachter a54636751b client: Add c.blob property
Signed-off-by: Uli Schlachter <psychon@znc.in>
2014-02-23 12:26:13 +01:00
Uli Schlachter 1703801728 ewmh: remove _NET_DESKTOP_GEOMETRY support
Our tag concept doesn't really fit into ewmh. Thus, we were setting this
property to a way too small value anyway (just the size of the first screen in
case of multiple screens).

Since this property is optional in ewmh, let's just drop it.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2013-09-27 23:01:49 +02:00
Uli Schlachter 381d840a82 Use $PATH when starting $SHELL
If $SHELL is set to "bash", previously awesome failed to restart itself, because
it could not find "bash". This commit makes awesome use execlp() instead of
execl() which means that $PATH is searched if the started command does not
contain a slash and this problem is fixed.

$SHELL is specified in POSIX and it doesn't seem to require an absolute path
name.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2013-09-27 16:22:55 +02: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
Gregor Best a2cd466103 Remove compiler warnings
Signed-off-by: Gregor Best <gbe@ring0.de>
Signed-off-by: Uli Schlachter <psychon@znc.in>
2012-11-24 18:15:34 +01: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 c491cd034c common/util.h: dodgy non-__GNUC__ p_delete
I assume nobody have tried to compile Awesome with GNU uncompatible
compiler for ages and thus non-__GNUC__ p_delete version got
overlooked for quite some time.
First of all, a problem I see is that it assigns void** to a variable
of type void* and then dereferences the same void* variable.
None of the compilers I am aware of will let you go through this
without an error.
And second of all, lets have one portable p_delete.

Signed-off-by: Arvydas Sidorenko <asido4@gmail.com>
Signed-off-by: Uli Schlachter <psychon@znc.in>
2012-07-31 16:33:05 +02:00
Uli Schlachter 2853d58f52 root: Add a wallpaper setter
This allows lua code to set a wallpaper directly instead of having to spawn some
external tools which possibly aren't installed.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2012-07-29 15:32:04 +02:00
Uli Schlachter 05a8ef2ed9 Handle execv() errors
Previously, awesome would just crash when execv() fails, because it already
destroyed all of its internal state, but then tries to do another main loop
iteration. Whoops.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2012-07-15 00:18:44 +02:00
Arvydas Sidorenko f41590e19c Wrapped luaL_register
Signed-off-by: Arvydas Sidorenko <asido4@gmail.com>
Signed-off-by: Julien Danjou <julien@danjou.info>
2012-06-12 13:32:40 +02:00
Arvydas Sidorenko 508dce9c14 Replaced already in Lua 5.1 deprecated lua_open()
In Lua 5.1 lua_open directly calls luaL_newstate, but was deprecated.
In Lua 5.2 lua_open was removed.

Signed-off-by: Arvydas Sidorenko <asido4@gmail.com>
2012-06-12 11:07:15 +02:00
Arvydas Sidorenko d612b922f3 lua_objlen wrapped in luaA_rawlen
In lua 5.2 lua_objlen was renamed for now reason

Signed-off-by: Arvydas Sidorenko <asido4@gmail.com>
2012-06-12 11:02:57 +02:00
Arvydas Sidorenko 47e21ad3cc Wrapped lua_[gs]etfenv into luaA_[gs]etuservalue
Lua 5.2 removed lua_[gs]etfenv and introduced
lua_[gs]etuservalue. Not sure though if it provides
the required functionality which awesome is using.
Thus, need some testing.

Signed-off-by: Arvydas Sidorenko <asido4@gmail.com>
2012-06-12 11:02:34 +02:00
Arvydas Sidorenko f2942a994d luaL_typerror -> luaA_typerror
Lua 5.2 removed luaL_typerror leaving to write our own version
if need it.

Signed-off-by: Arvydas Sidorenko <asido4@gmail.com>
2012-06-12 10:56:19 +02:00
Arvydas Sidorenko a77dc54f87 Unnecessary #define's to static inline functions
Signed-off-by: Arvydas Sidorenko <asido4@gmail.com>
2012-06-12 10:54:08 +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
Edward O'Callaghan 3ba9eabd86 Add platform support for DragonflyBSD.
Simply adds a define required for awesomewm to work on the BSDs.

Signed-off-by: Edward O'Callaghan <eocallaghan@auroraux.org>
Signed-off-by: Uli Schlachter <psychon@znc.in>
2012-05-20 22:46:34 +02:00
dodo 97040eb91d common/version.c: show lua release & version
Signed-off-by: Julien Danjou <julien@danjou.info>
2012-04-23 17:39:29 +02:00
Uli Schlachter a8fa910586 luaA_object_emit_signal: Fix a crash on non-objects
This was first fixed in 79b1f5aba1, but 3fbb5f15 reintroduced the crash. The
only "real" change in here is that there is now a "return;" after the
warn("Trying...");. The rest is just re-indentation.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2012-01-04 17:09:52 +01:00
Majic 0e8fc995bb Minor readability fixes, STREQ()-like macros added
Signed-off-by: Julien Danjou <julien@danjou.info>
2011-11-18 17:56:21 +01: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
Arnaud Fontaine be7fda45d8 Update the code following release of xcb-util 0.3.8.
xcb-util is now split into several repositories since 0.3.8. This
release also cleaned up the API a lot, thus update the code
accordingly.

Signed-off-by: Arnaud Fontaine <arnau@debian.org>
Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-05-10 18:27:39 +02:00