Commit graph

135 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
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
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
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
Kristian Høgsberg
f5df38959b Optimize wl_fixed_t to/from double conversion functions 2012-05-14 09:36:38 -04:00
Daniel Stone
c5aba11acc Add support for signed 24.8 decimal numbers
'fixed' is a signed decimal type which offers a sign bit, 23 bits of
integer precision, and 8 bits of decimal precision.  This is exposed as
an opaque struct with conversion helpers to and from double and int on
the C API side.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-05-08 14:40:39 -04:00
Pekka Paalanen
35d5053c62 os: wrap recvmsg(MSG_CMSG_CLOEXEC)
Some system C libraries do not have MSG_CMSG_CLOEXEC. This flag would
automatically set O_CLOEXEC flag on any received file descriptors.

Provide a fallback that does it manually. If setting CLOEXEC fails, the
file descriptor is closed immediately, which will lead to failures but
avoid leaks. However, setting CLOEXEC is not really expected to fail
occasionally.

Add tests for the wrapper. The setup is copied from connection-test.c.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-04-25 09:37:42 +03:00
Pekka Paalanen
1463a41f89 os: wrap F_DUPFD_CLOEXEC
Some system C libraries do not have F_DUPFD_CLOEXEC. Provide a fallback.

Add tests for the new wl_os_dupfd_cloexec() wrapper.

Add per-wrapper call counters in os_wrappers-test.c. Makes it easier to
determine the minimum required number of wrapped calls.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-04-25 09:32:58 +03:00
Kristian Høgsberg
243672cd3c connection: Make sure we can invoke closures built with wl_closure_vmarshal() 2012-04-22 14:17:20 -04:00
Kristian Høgsberg
1901d66ffc connection: Move closure object out of wl_connection 2012-04-22 13:49:35 -04:00
Kristian Høgsberg
0d6dea17b4 connection: Dont put fds in the connection until we send the closure 2012-04-21 23:50:13 -04:00
Pekka Paalanen
b7c7963f16 Fix printf format warnings
connection.c:530: warning: format '%lu' expects type 'long unsigned
int', but argument 2 has type 'unsigned int'

/connection.c:560: warning: format '%lu' expects type 'long unsigned
int', but argument 2 has type 'unsigned int'

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-04-17 15:02:15 -04:00
Kristian Høgsberg
3fb304bb3e connection.c: Fix signedness warnings 2012-03-30 10:43:32 -04:00
Kristian Høgsberg
ba32db9532 Move DIV_ROUNDUP out of public header, remove unused ALIGN 2012-03-30 10:28:39 -04:00
Kristian Høgsberg
1c5578e87f connection: Just look at buffer size and remove redundant n_fds_out
Instead of maintaining a count of the fds in the buffer, just compute
that from the buffer size.  That way we don't get out of sync.
2012-03-23 00:48:19 -04:00
Kristian Høgsberg
cab70c9e5d connection: Set n_fds_out to 0 when we send out the fds
This needs to happen always, not just when the fd buffer overflows.
2012-03-23 00:27:04 -04:00
Ander Conselvan de Oliveira
73d4a53672 Flush the connection if we have to many marshaled fds
The buffer used by wl_connection_data to receive a cmsg is 128 bytes
long. This can hold at most 28 fds but when a cmsg is generated for
sending the fds, there is no check for this limitation. The man page
for recvmsg does not show any way of recovering from MSG_CTRUNC, that
happens when the buffer supplied for cmsg is too short.

Fix this by flushing the data to be written instead of generating a
cmsg buffer longer than the maximum.
2012-03-10 16:01:46 -05:00
Kristian Høgsberg
ac80c54f18 connection: Export wl_connection_queue() so we can test it 2012-03-02 23:38:31 -05:00
Kristian Høgsberg
b26774da5b Don't block when flushing a full protocol buffer
In case the client isn't responding, this will block the compositor.
Instead we flush with MSG_DONTWAIT, which lets us fill up the kernel buffer
as much as we can (after not returning EPOLLOUT anymore it still can take
80k more), and then disconnect the client if we get EAGAIN.
2012-02-29 11:07:48 -05:00
Kristian Høgsberg
1b31149f92 connection: Fix printf format warnings 2011-12-17 16:05:44 -05:00
Laszlo Agocs
34901868b8 Increase closure buffer size and fail gracefully for too big closures.
Buffer size changed from 256 to 1024 bytes. Marshalling will now stop
if the buffer is not big enough.
2011-12-17 16:02:05 -05:00
Kristian Høgsberg
eae3bcb4cc New drag and drop / selection protocol
This commit brings a big change to the DND and copy/paste interfaces.
Most importantly the functionality is now independent of wl_shell.
The wl_shell interface is intended for desktop style UI interaction and
an optional and experimental interface.

The new interface also allows receiving the DND data multiple times or
multiple times during the drag, and the mechanism for offering and receiving
data is now shared between DND and selections.
2011-11-23 16:05:58 -05:00
Kristian Høgsberg
190492b97c debug: Use unsigned for object IDs 2011-11-22 14:04:10 -05:00
Kristian Høgsberg
cf04b0a18f Move private definitions and prototypes to new wayland-private.h 2011-11-18 13:46:56 -05:00
Kristian Høgsberg
4abc56bd6d Introduce wl_resource_queue_event() for sending events later
Some events, such as the display.delete_id, aren't very urgent and we
would like to not always send them immdiately and cause an unnecessary
context switch.  The wl_resource_queue_event() function will place the
event in the connection output buffer but not request the main loop to
poll for writable.  The effect is that the event will just sit in the
output buffer until a more important event comes around and requires
flushing.
2011-11-17 17:52:01 -05:00
Kristian Høgsberg
3a1e6df39a Add display event to acknowledge ID deletion
We need to make sure the client doesn't reuse an object ID until the
server has seen the destroy request.  When a client destroys an ID
the server will now respond with the display.delete_id event, which lets
the client block reuse until it receives the event.
2011-11-17 17:37:52 -05:00
Benjamin Franzke
3f1063f92a connection: Check object types in message parameters 2011-10-31 11:13:13 -04:00
Kristian Høgsberg
c8147edc3a Store objects in wl_map data structure
The wl_map data structure is just an array with a free-list that lets the
client recycle unused client IDs and keep range of client IDs under control.
2011-08-27 12:06:11 -04:00
Paulo Zanoni
1648109c84 connection: fix libffi usage, our functions return void
All clients were segfaulting on my machine.

Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
2011-08-27 12:06:10 -04:00
Kristian Høgsberg
f6ede01b68 connection: Object ID 0 is not a valid new object ID 2011-08-16 22:33:36 -04:00
Kristian Høgsberg
4c260db68c Rename source subdir from wayland to src 2011-08-12 16:25:14 -04:00
Renamed from wayland/connection.c (Browse further)