Commit graph

93 commits

Author SHA1 Message Date
Uli Schlachter
6f1df7a3ad Fix disconnecting not connected signals (#950)
When a function is disconnected from a signal ("disconnect_signal") that is not
actually connected to the function, two things happened:

1. The attempt to remove the function from the signal array didn't do anything
2. Unreferencing the function noticed that the function wasn't referenced

The second step printed a big, fat scary warning.

Actually, this has the possibility of causing errors. For example, in the
following code, awesome would wrongly unreference the function at the
disconnect_signal() call and might later still try to call it when the
"refresh" signal is emitted:

do
    local function f() end
    awesome.connect_signal("refresh", f)
    awesome.disconnect_signal("debug::error", f)
end

Fix this by making signal_disconnect() return a boolean value indicating if it
actually did something. All callers are fixed to use this value and only update
the reference counts if something was actually disconnected.

Fixes: https://github.com/awesomeWM/awesome/issues/814
Signed-off-by: Uli Schlachter <psychon@znc.in>
2016-06-09 00:03:08 +02:00
Uli Schlachter
231436d9e3 C: Remove unneeded calls to signal_add()
Signed-off-by: Uli Schlachter <psychon@znc.in>
2016-06-04 17:57:08 +02:00
Uli Schlachter
7f43608d73 dbus.c: Check string return values properly
Apparently some versions of dbus kill the process with a failed assertion if
invalid UTF8 should be send out. Mine doesn't. Also, our behaviour of replacing
non-strings silently with strings is weird.

This commit thus makes converting from Lua to dbus fail if a non-string should
be sent as a string or if a string contains malformed UTF8.

Fixes: https://github.com/awesomeWM/awesome/issues/728
Signed-off-by: Uli Schlachter <psychon@znc.in>
2016-03-06 11:16:49 +01:00
Uli Schlachter
77507a2877 dbus.c: DBUS_MSG_RETURN_HANDLE_TYPE_STRING is only used once
So undefine this

Signed-off-by: Uli Schlachter <psychon@znc.in>
2016-03-06 11:12:10 +01:00
Uli Schlachter
9a030ba299 dbus.c: Fix handling of DBUS_TYPE_BYTE
From the DBus docs of DBUS_TYPE_BYTE:

   Type code marking an 8-bit unsigned integer.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2016-03-06 11:07:37 +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
82f74aa895 a_dbus_convert_value(): Be less strict about wrong strings
The code doesn't check the type of any of the values that it converts. However,
string elements are silently skipped if they cannot be converted.

The proper fix would be to make this code check types. For now, it will be ok to
"convert" non-strings to an empty string.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2016-01-15 20:08:34 +01:00
▟ ▖▟ ▖
8557a7e0e4 properly flush dbus connection after send 2015-11-21 16:36:02 +01:00
▟ ▖▟ ▖
33d4100ea0 prevent segfault when dbus signal creation failed 2015-11-21 16:35:52 +01:00
▟ ▖▟ ▖
e8d209fde6 fix typo 2015-11-21 16:35:42 +01:00
▟ ▖▟ ▖
0414a579c2 Expose dbus signal sender
Closes https://github.com/awesomeWM/awesome/pull/198.
2015-09-23 21:05:03 +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
Daniel Hahler
8919faa7b3 doc: fix warnings from doxygen 2015-02-14 20:17:13 +01:00
Uli Schlachter
3bccb0ab73 a_dbus_message_iter: Handle DBUS_TYPE_DOUBLE
Fixes #78 on GitHub.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2015-01-17 19:44:04 +01:00
Da Risk
0ccda0eb9e Add luadoc for dbus.emit_signal() 2015-01-02 20:07:22 +01:00
Da Risk
e664a74710 Add support for notification actions
The desktop notification specification says that a notification can have
different actions. These actions allow the user to interact with the client
application and should be displayed by the notification server.
* Add function to emit a DBus signal
* Notifications : emit NotificationClosed signal when closing notification
* Notifications: use constant for notification closed reasons
* notifications: Implement notifications actions

This is just a basic implementation to display the actions send with the
notifications. The actions should be displayed differently
* Notifications: add support for default action
2014-12-31 14:28:46 +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
d668268591 Fix some more dubious uses of globalconf.L
Signed-off-by: Uli Schlachter <psychon@znc.in>
2014-12-06 11:07:20 +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
Uli Schlachter
88facb7f57 Make debug::index::miss and newindex work on classes and all objects
Signed-off-by: Uli Schlachter <psychon@znc.in>
2014-03-23 19:27:06 +01: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
Uli Schlachter
bfcb1628b7 dbus: Fix event handling
The port to glib failed to actually watch the file descriptor for events and
thus awesome silently ignored all dbus messages. My bad.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2012-11-21 22:05:15 +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
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
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
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
Uli Schlachter
4f6c6cf32e dbus: Make sure the lua stack is balanced
Signed-off-by: Uli Schlachter <psychon@znc.in>
2010-10-31 14:59:59 +01:00
Uli Schlachter
f61dca7068 dbus: Stop using a_tokenize()
Signed-off-by: Uli Schlachter <psychon@znc.in>
2010-09-02 19:02:21 +02:00
Uli Schlachter
4b69718072 signal: Fix another "unknown signal" warning
Signed-off-by: Uli Schlachter <psychon@znc.in>
2010-08-26 18:07:09 +02:00
Uli Schlachter
ab4c151ed8 Add signals before using them
This commit makes it an error if an unknown signal is connected, disconnected or
emitted. All signals have to be added before they can be used.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2010-08-25 23:00:36 +02:00
Uli Schlachter
948f960b7e Also rename the signal_* C function
Signed-off-by: Uli Schlachter <psychon@znc.in>
2010-08-25 20:48:42 +02:00
Julien Danjou
6d332f07a0 lua{class,object}: rename signals functions
I knew this was wrong at the beginning, f*ck.

Signed-off-by: Julien Danjou <julien@danjou.info>
2010-08-25 20:28:20 +02:00
Gregor Best
6e6a07b660 dbus: fix compiling error
Signed-off-by: Gregor Best <gbe@ring0.de>
Signed-off-by: Julien Danjou <julien@danjou.info>
2010-06-06 14:32:54 +02:00
Julien Danjou
bd30468d7a dbus: only warn, dot not raises an error (FS#713)
This is not user-called error, so it's a really bad idea to raise an Lua
error here.

Signed-off-by: Julien Danjou <julien@danjou.info>
2010-06-06 10:46:01 +02:00
Julien Danjou
596cac5fb1 dbus: add support for array as returned type
Signed-off-by: Julien Danjou <julien@danjou.info>
2009-12-28 10:40:07 +01:00
Julien Danjou
af01e176d7 dbus: move some convert code in a function
Signed-off-by: Julien Danjou <julien@danjou.info>
2009-12-28 10:40:04 +01:00
Julien Danjou
019608aa9e dbus: check that interface is not NULL (FS#667)
Signed-off-by: Julien Danjou <julien@danjou.info>
2009-11-09 20:49:37 +01:00
Julien Danjou
1dfa2c2a8d dbus: field can be nil
Signed-off-by: Julien Danjou <julien@danjou.info>
2009-11-09 20:49:02 +01:00
Julien Danjou
1c54d2fd12 dbus: fix crash if interface is NULL
Signed-off-by: Julien Danjou <julien@danjou.info>
2009-10-05 14:42:38 +02:00
Julien Danjou
b2297fda46 globalconf: remove config.h include
Signed-off-by: Julien Danjou <julien@danjou.info>
2009-09-07 17:28:55 +02:00
Brian Gianforcaro
73aa29645f Added documentation to D-Bus functions. Signed-off-by: Brian Gianforcaro <b.gianfo@gmail.com>
Signed-off-by: Julien Danjou <julien@danjou.info>
2009-09-04 18:18:04 +02:00
Julien Danjou
6dc68905dc dbus: check for signal uniqness
Signed-off-by: Julien Danjou <julien@danjou.info>
2009-08-21 15:30:48 +02:00
Julien Danjou
81d44ec5c4 dbus: call only one signal handler by interface
Signed-off-by: Julien Danjou <julien@danjou.info>
2009-08-21 15:30:48 +02:00
Julien Danjou
299bc00286 dbus: move to signal
Signed-off-by: Julien Danjou <julien@danjou.info>
2009-07-29 16:10:29 +02:00
Uli Schlachter
55524ece8d Use a libev prepare watcher for calling awesome_refresh()
Before this, awesome_refresh() could be called multiple times per mainloop and
one had to make sure to add awesome_refresh() calls in the right places.

Now, the prepare handler is invoked just before libev puts the process to sleep
(e.g. by calling select()) and awesome_refresh() does its thing.

All redundant calls to awesome_refresh() are removed, but the one in
selection.c has to stay because this function blocks in xcb_wait_for_event()
without using libev.

Signed-off-by: Uli Schlachter <psychon@znc.in>
Signed-off-by: Julien Danjou <julien@danjou.info>
2009-06-19 09:34:42 +02:00
Julien Danjou
acf4202143 dbus: do not exit on bus disconnection
Signed-off-by: Julien Danjou <julien@danjou.info>
2009-06-17 10:27:54 +02:00
Jonny Lamb
88be323e4a dbus: Use org.naquadah.awesome instead of org.awesome.
http://dbus.freedesktop.org/doc/dbus-specification.html#naming-conventions

Signed-off-by: Jonny Lamb <jonny@debian.org>
Signed-off-by: Julien Danjou <julien@danjou.info>
2009-06-15 20:42:28 +02:00
Julien Danjou
e4acb74a5a luaa: split dofunction()
Signed-off-by: Julien Danjou <julien@danjou.info>
2009-06-10 11:44:29 +02:00
Julien Danjou
0c800d9612 dbus: use dbus_bool_t when reading messages
Signed-off-by: Julien Danjou <julien@danjou.info>
2009-04-28 22:40:02 +02:00