Commit graph

810 commits

Author SHA1 Message Date
Daniel Stone
3ec40512c7 More consistent ID printing
Use unsigned rather than signed for IDs, so they match up with what we
see in other prints.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-07-23 20:17:10 -04:00
Daniel Stone
db0add6d5e Make NEW_IDs nullable
The connection-handling code already allows this, so make it legal in
the protocol definition too.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-07-23 20:16:57 -04:00
Daniel Stone
efe23443d8 Unstatic arg_count_for_signature and get_next_argument
Expose these to other files using wayland-private.h, so wayland-client.c
can walk NULLables properly.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-07-23 20:15:28 -04:00
Mathias Fiedler
0b8b397e34 connection: reserve id on incoming new object
If a new object id arrives ensure that there is an empty array entry
created, otherwise we might get out of sync for new ids if object isn't
created by interface implementation.
2012-07-22 14:09:51 -04:00
Mathias Fiedler
bfcd681930 wayland-util: add method for reserving new object id
wl_map_reserve_new() ensures that new id is valid and will point to an
empty array entry.
2012-07-22 14:09:48 -04:00
Mathias Fiedler
900e4b63ef wayland-server: send error on invalid new object id
Creation of new client resources was silently ignored when
wl_client_add_resource() was used on server side and new object id was out
of range.

An error is now send out to the client in such case.

Also changed error message in wl_client_add_object, since
wl_map_insert_at() returns -1 only at invalid new id.
2012-07-22 14:06:37 -04:00
Kristian Høgsberg
76bfd68f47 wayland-shm: Commit the width/height getters that actually compile 2012-07-20 12:30:07 -04:00
Kristian Høgsberg
7ba218c9f8 shm: Add shm_buffer getters for width and height 2012-07-20 12:04:42 -04:00
Robert Ancell
0a9cd16f6a wayland-client: Add missing newline from an error message 2012-07-20 12:04:05 -04:00
Dmitry Guryanov
2e79c4877f remove listener from wl_data_source destroy_signal listener list
I've found a bug during wayland exploration - if you make two
drag'n'drops in weston client example, dnd - weston crashes with
segfault. I've tried to investigate it and found a problem.

In function drag_grab_button we first call data_device_end_drag_grab,
which sets seat->drag_data_source to NULL. Then we remove
listener from list only if drag_data_source is not NULL.

So if client will not free wl_data_source and start another drag'n'drop,
after the first one. Then two wl_data_source structures will be
free'd on client exit (let's name them s1 and s2).

next and prev pointer of
wl_data_source.resource.destroy_signal.listener_list in both
wl_data_source structures will be seat->drag_data_source_listener,
but next and prev in seat->drag_data_source_listener.link point
to listener_list in s2.

So if you try to iterate over listener_list in s1
then you get drag_data_source_listener as first item and
(struct wl_listener *)(&s2.resource.destroy_signal.listener_list)

Iteration over that list occurs in
wl_resource_destroy->destroy_resource->wl_signal_emit->wl_signal_emit
and try to call function at address of wl_resource->client, so
weston segfaults there.
2012-07-17 16:54:07 -04:00
Pekka Paalanen
9326498d03 server: fix wl_seat_set_keyboard
This makes wl_seat_set_keyboard similar to wl_seat_set_pointer in that
it's a no-op, if you try to set keyboard to NULL when it already is
NULL, instead of refusing to set it to NULL ever.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-07-10 14:08:01 -04:00
Pekka Paalanen
23bf48063f server: add lose_touch_focus()
Just like wl_keyboard and wl_pointer, add a signal handler for losing
touch focus.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-07-10 13:57:33 -04:00
Robert Ancell
e7e1296682 scanner: Include weston-client.h as the inline functions require it 2012-07-09 22:01:25 -04:00
Kristian Høgsberg
b4aff6b79f wayland-shm: Add return before we hit the error clean-up path
Regression in c94c0946db
2012-07-09 21:50:39 -04:00
Martin Olsson
dba322c1c0 Fixup source comment in wayland-util.h and fix typo in TODO 2012-07-09 18:11:06 -04:00
Martin Olsson
c94c0946db shm: Plug leak in shm_create_pool() 2012-07-09 17:59:45 -04:00
Martin Olsson
53bb401704 server: Don't crash for wl_seat_set_touch(seat, NULL) 2012-07-09 17:59:36 -04:00
Martin Olsson
e760ec9fa9 scanner: Plug memory leak in end_element() 2012-07-09 17:59:23 -04:00
Christopher James Halse Rogers
161c690b55 protocol: Add explicit nullable types
Most of the time it does not make sense to pass a NULL object, string, or array
to a protocol request. This commit adds an explicit “allow-null” attribute
to mark the request arguments where NULL makes sense.

Passing a NULL object, string, or array to a protocol request which is not
marked as allow-null is now an error. An implementation will never receive
a NULL value for these arguments from a client.

Signed-off-by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
2012-07-02 13:53:02 -04:00
Dylan Noblesmith
af5f8cc200 wayland-client: reject socket paths longer than 108 bytes
Attempting to write anything longer into the embedded char
array would create a non-null-terminated string, and all
later reads would run off the end into invalid memory.

This is a hard limitation of AF_LOCAL/AF_UNIX sockets.
2012-06-30 19:58:36 +00:00
Dylan Noblesmith
00c25a0565 wayland-server: reject socket paths longer than 108 bytes
Attempting to write anything longer into the embedded char
array would create a non-null-terminated string, and all
later reads would run off the end into invalid memory.

This is a hard limitation of AF_LOCAL/AF_UNIX sockets.
2012-06-30 19:58:05 +00:00
Dylan Noblesmith
4522467268 wayland-server: add more logging of errors 2012-06-30 19:57:22 +00:00
Dylan Noblesmith
30ff420ca9 wayland-server: fix socket ownership race condition
Always unlink() the lock file before closing the file
descriptor for it. Otherwise, there is a race like this:

Process A closes fd, releasing the lock
Process B opens the same file, taking the lock
Process A unlinks the lock file
Process C opens the same file, which now no longer exists,
and takes the lock on the newly created lock file

Process B and C both 'own' the same display socket.

unlink()ing while holding the lock is effectively a better
way to release the lock atomically.
2012-06-30 19:50:09 +00:00
Dylan Noblesmith
9475257459 wayland-server: fix fd leak on error path
And restructure get_socket_lock() so it's clearer that it's
allocating a new file descriptor.

Uncovered by an upcoming test.
2012-06-30 19:37:42 +00:00
Dylan Noblesmith
cadd999292 drop use of strerror()
It isn't thread-safe. Use the %m conversion specifier instead,
like the rest of the code already does.
2012-06-30 19:37:04 +00:00
Dylan Noblesmith
bb6e48b1b0 wayland-server: reduce use of magic numbers
Make it clear what the significance of '5' and '113' actually is.
Also drop an unneeded function argument.
2012-06-30 19:37:04 +00:00
Kristian Høgsberg
9de9e39f87 Allocate client proxy automatically for new objects
When the server send a new object ID, the client used to have to allocate
the proxy manually and without type-safety.  We now allocate the proxy
in a client-side post-processing step on the incoming closure.
2012-06-28 22:01:58 -04:00
Kristian Høgsberg
9afb5f61f8 Send modifier event to pointer focus when it changes too 2012-06-22 14:38:12 -04:00
Kristian Høgsberg
67e16be8aa Send keyboard modifier event using the keyboard resource 2012-06-22 12:20:00 -04:00
Daniel Stone
bcefacb89d Maintain keyboard modifier state in wayland-server
Provide a slot for keyboard modifier state inside wl_keyboard for
implementations to update, and use this to send wl_keyboard:;modifier
events whenever the keyboard or pointer focus changes.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-06-22 11:06:44 -04:00
Kristian Høgsberg
c806dde7e6 data-device: Fix list corruption when the source goes away
If the data source is destroyed, the corresponding offers may stay around for
a little longer (until the owning client destroys it).  When the offer is
finally destroyed, we have to be careful to only remove the source
destroy listener if the source hasn't yet been destroyed.

Thanks to Martin Minarik for tracking down where the corruption happened.
2012-06-18 12:09:47 -04:00
Kristian Høgsberg
8dc57f4dda connection: Set closure->start in demarshal too 2012-06-13 10:45:38 -04:00
Kristian Høgsberg
46f9745c10 connection: Always malloc closure
This lets us allocate the closure just big enough and is a first step towards
a message queue.
2012-06-13 10:45:34 -04:00
Jonas Ådahl
1432bd62df wayland-server: Add destroy signal to wl_seat
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2012-06-12 20:18:42 -04:00
Jonas Ådahl
f36f32a0e0 wayland-util: wl_list_insert_list() should accept empty lists
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2012-06-12 20:18:38 -04:00
Pekka Paalanen
c29020332a server: require XDG_RUNTIME_DIR
An arbitrary fallback to the current directory is only confusing.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-06-06 13:07:33 -04:00
Pekka Paalanen
0c7ca38c7f client: require XDG_RUNTIME_DIR
An arbitrary fallback to the current directory is only confusing.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-06-06 13:07:25 -04:00
Kristian Høgsberg
aa792ad3d6 Add a focus change signal for wl_pointer and wl_keyboard 2012-06-05 09:56:42 -04:00
Kristian Høgsberg
68f058ffd3 data-device: Don't implement data source through data offer object
The wl_data_source object used to specify the implementation for data
offers created for it.  This means you need a data offer to retrieve the
data from the source, which makes it awkward to use in-process in a
compositor.  Now we instead have three virtual functions that can be
connected to a protocol object or in-process data-sources such as an
X server proxy or clipboard.
2012-06-03 17:30:12 -04:00
Kristian Høgsberg
0760297633 data-device: Handle setting a NULL selection source 2012-05-31 23:29:08 -04:00
Kristian Høgsberg
0527ad8f00 data-device: Emit selection_signal also when we lose the selection 2012-05-31 23:28:31 -04:00
Kristian Høgsberg
8f63e8013b data-device: Only send out NULL selection if we have a resource
If the current keyboard focus client doesn't have a resource for the
data_device, don't send out the selection event.
2012-05-31 23:26:50 -04:00
Daniel Stone
872d074a43 Add key_state and button_state enums
Rather than hardcoding 0 and 1 everywhere.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-05-31 14:02:20 -04:00
Daniel Stone
9a1705c5f5 wl_keyboard: Add modifier event
This event sends the current keyboard modifier/group state from the
compositor to the client, allowing all clients to have a consistent view
of the keyboard state (e.g. current layout, Caps Lock, et al).  It
should be sent after a keyboard enter event, and also immediately after
any key event which changes the modifier state.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-05-31 14:01:56 -04:00
Daniel Stone
f7a39ff69b Always reset keyboard and pointer focus
If wl_pointer_set_focus or wl_keyboard_set_focus have been called before
a listener has been established for that seat and client combination,
the focus window will be set but the focus resource will be NULL.  This
changes these functions to always attempt to search for the relevant
focus resource, allowing the resource to be set by calling
wl_keyboard_set_focus and wl_pointer_set_focus again when a listener has
been established.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-05-31 14:01:29 -04:00
Martin Minarik
1b6a61d3e9 Wayland: logging: replace printf by wl_log 2012-05-31 13:57:20 -04:00
Martin Minarik
8e2a786703 Wayland: logging
The core libwayland libraries should not handle logging, only passing
the error messages to subscribed functions.
An application linked to libwayland-server or libwayland-client
will be able to set own functions (one per library) to handle error
messages.

Change in this series: make the wl_log return int, because
of compatibility with printf. It will return the number of bytes logged.
2012-05-31 13:57:15 -04:00
Pekka Paalanen
693e5983f4 build: add uninstalled pkg-config files
Required for building apps against wayland libraries that have not been
installed.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-05-29 10:09:59 -04:00
Ander Conselvan de Oliveira
75a5f7476a data-device: implement drags with no data source for self-dnd
Properly handle a drag with no data source, i.e., don't crash and send
events only to the client that initiated the drag. This way a client can
do self drag and drop without offering anything to other clients.
2012-05-29 09:58:13 -04:00
Ander Conselvan de Oliveira
d422a733b4 data-device: fix crash when a client dies during a drag with an icon
The commit that split wl_input_device into wl_seat and friends changed
erroneously the drag icon destroy listener, causing it to operate into
an invalid pointer to a wl_seat.
2012-05-25 23:10:01 -04:00