Commit graph

810 commits

Author SHA1 Message Date
Pekka Paalanen
00ea1701f2 server: fix signedness in wl_client_connection_data
The variables opcode and size were unsigned, which lead to warnings
about comparisons of signed vs. unsigned.

Change these variable to signed. Their usage never relies on being
unsigned.

This also fixes (an assumed) printf format string problem, where these
were printed with %d, not %u.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-03-30 09:32:26 -04:00
Kristian Høgsberg
4fe458346c Remove unused bits from wayland-server.h 2012-03-29 14:03:40 -04:00
Kristian Høgsberg
3891c73511 Fix formatting warning 2012-03-27 16:36:25 -04:00
Ander Conselvan de Oliveira
897a4ec62d data-device: notify the compositor about new drag icons
Let the compositor use a listener to be notified when a new drag icon
is set up.
2012-03-27 16:32:02 -04:00
Kristian Høgsberg
83685c506e Remove wl_buffer.damage and simplify shm implementation 2012-03-26 16:33:24 -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
Jonas Ådahl
80f4f0d512 event-loop: Use two-step destruction of event loop sources.
Instead of directly freeing an event source upon removal put it in a
queue later handled by the event loop; either after a dispatch or upon
event loop destruction.

This is necessary to avoid already queued up event sources to be freed
during some other dispatch callback, causing segmentation faults when
the event loop later tries to handle an event from the freed source.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2012-03-21 10:30:19 -04:00
Bill Spitzak
81ffaa04b9 Check arguments to wl_resource_post_error in gcc
The attached patch turns on printf argument warnings for this function,
which I found was being called incorrectly at least once in the wayland
source code.
2012-03-20 16:52:17 -04:00
Ander Conselvan de Oliveira
3c5d9694db event-loop: always do the post-dispatch check
The post-dispatch check on wl_event_loop_dispatch() was not being run
if epoll_wait returned 0 events, making the check unreliable.
2012-03-20 15:15:19 -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
814a626087 scanner: Add since attribute
This will help us document when a request or event was added to the protocol.
2012-03-05 10:31:53 -05:00
Kristian Høgsberg
8e2cac7ae4 Add wl_array_for_each 2012-03-04 13:40:49 -05:00
Kristian Høgsberg
ac80c54f18 connection: Export wl_connection_queue() so we can test it 2012-03-02 23:38:31 -05:00
Ander Conselvan de Oliveira
214e343311 Terminate drag if data source is destroyed 2012-03-02 11:45:11 -05:00
Pekka Paalanen
70db367ccc server: fix event sending type mismatches
These were not bugs in practice, because the first (and only) field of
struct wl_surface is struct wl_resource.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-03-02 18:09:27 +02:00
Pekka Paalanen
5ee70146c6 server: use the event sending wrappers
This exposes some type mismatches that are fixed in the next commit.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-03-02 18:06:19 +02:00
Pekka Paalanen
86a5d17afe scanner: emit event wrapper functions for server
Generate typed wrapper functions for sending events in a server.

This allows compile time type checking, unlike the existing method of
calling the variadic function wl_resource_post_event().

The stuff in wayland-server.h had to be slightly reordered to have all
(forward) declarations before use.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-03-02 17:55:45 +02:00
Kristian Høgsberg
0d22d25b87 wayland-server: Destroy resource before sending out delete_id event
In some cases, we send out events from the resource destructor and
those need to go out before we recycle the object ID.
2012-03-01 22:46:46 -05:00
Ander Conselvan de Oliveira
e7f6c509e2 Fix server crash when a client dies during a drag with an icon
If a client dies during a drag that it started using an icon surface,
the server could crash because the icon surface is not valid anymore.

Fix this by using a destroy listener to reset device->drag_surface to
nil when the surface is destroyed.
2012-03-01 11:52:05 -05:00
Ander Conselvan de Oliveira
cb3e102620 Fix wl_data_offer source destroy listener
The listener function implementation was getting a wrong pointer to the
wl_data_offer object because the resource parameter is actually the
data source and not the data offer.
2012-03-01 11:50:53 -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
Samuel Rødal
d224714afd Allow update function to not be set in wl_display_get_fd
Ignore previous patch, here's the correct version.

From 4e1bedaaf05b576f5191f8fe3a34904ab9707414 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Samuel=20R=C3=B8dal?= <samuel.rodal@nokia.com>
Date: Mon, 27 Feb 2012 15:17:20 +0100
Subject: [PATCH] Allow update function to not be set in wl_display_get_fd

The same check is done in connection_update, and now with
wl_display_flush() there's less need for the client to need to know the
connection mask.
2012-02-28 14:30:39 -05:00
Samuel Rødal
bf5a8fbb98 Rename client side wl_display_destroy() to wl_display_disconnect()
This avoids the clash with the wayland-server version with the same
name, and allows linking against both wayland-client and wayland-server
at the same time, which can be useful for unit testing purposes as
well as for nested compositing.

Without this there will be crashes as the wrong wl_display_destroy()
is called.
2012-02-28 14:23:58 -05:00
Üstün Ergenoğlu
a676b8f257 util: Comments before wl_list were a bit off, fixed the example usage.
Signed-off-by: Üstün Ergenoğlu <ego@ustun.fi>
2012-02-26 14:00:53 -05:00
Peter Hutterer
a8c9e82c49 scanner: Remove unused variable 'len'
scanner.c: In function ‘desc_dump’:
scanner.c:142:42: warning: unused variable ‘len’ [-Wunused-variable]

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-02-23 15:45:03 -05:00
Thiago Macieira
c56667bb83 Fix compilation: uid_t, gid_t and pid_t are defined in sys/types.h
This error shows up in third-party code when including
wayland-server.h.
2012-02-23 15:35:30 -05:00
Kristian Høgsberg
3c6f42112d Split pointer_focus and keyboard_focus into enter and leave events 2012-02-23 09:35:24 -05:00
Scott Moreau
ab3b5cd71c server: Implement wl_keyboard_grab_interface. 2012-02-18 11:55:22 -05:00
Scott Moreau
8134e06742 server: Rename wl_grab_interface.
In order to separate pointer and keyboard grabs, we need to
introduce a keyboard grab interface but first we must rename
some generic types to denote which device is holding the grab.

Type renames:

wl_grab_interface -> wl_pointer_grab_interface
wl_grab -> wl_pointer_grab
wl_input_device_start_grab -> wl_input_device_start_pointer_grab
wl_input_device_end_grab -> wl_input_device_end_pointer_grab
2012-02-18 11:51:38 -05:00
Kristian Høgsberg
8503cd6859 Add wl_client_get_credentials() to get unix credentials for client 2012-02-18 00:29:25 -05:00
Pekka Paalanen
5536031bfb protocol: remove absolute coordinates from pointer
Remove the absolute coordinate fields from the pointer motion and
pointer_focus events. Clients are not supposed to see any global
coordinates.

Fix wayland-server code accordingly. wayland-client code is unaffected.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-02-16 16:33:01 -05:00
Ander Conselvan de Oliveira
7243062f93 data_device: get rid of attach request
In the effort to make everything a regular surface, remove
data_device.attach request. To maintan the functionality, add
an icon surface parameter to data_device.start_drag.

Signed-off-by: Kristian Høgsberg <krh@bitplanet.net>
Signed-off-by: Ander Conselvan de Oliveira <ander.conselvan.de.oliveira@intel.com>
2012-02-16 16:11:44 -05:00
Tiago Vignatti
8f9de83f7b scanner: don't print new line when no descriptions are provided
Signed-off-by: Tiago Vignatti <tiago.vignatti@intel.com>
2012-02-09 10:06:18 -05:00
Kristian Høgsberg
0bcb30a9a0 Drop warning when we receive an event for zombie objects
Business as usual, but the message is confusing.
2012-02-09 08:28:52 -05:00
Kristian Høgsberg
fa525622e3 wayland-util.h: Avoid un-namespaced _container_of
Yes, there are worse offenders in that file, but this one isn't used in
the code and it makes Xorg angry.
2012-02-09 08:28:51 -05:00
Jesse Barnes
f66aa1d08f scanner: allow summary attributes in args and <description> in <protocol>
Add support for arg summaries for use by detailed structure element
descriptions.
2012-01-19 17:16:39 -05:00
Jesse Barnes
5cd0471311 scanner: Support documentation elements
On Wed, 18 Jan 2012 12:29:37 -0800
"Kristensen, Kristian H" <kristian.h.kristensen@intel.com> wrote:
> Yeah, that looks good.  I was thinking of a separate <description> tag
> to avoid stuffing too much into an attribute.

How does this look?  It adds a summary attribute to atomic elements,
and a <description> tag with a summary for others.  Spits out enum
documentation like this:

/**
 * wl_display_error - global error values
 * @WL_DISPLAY_ERROR_INVALID_OBJECT: server couldn't find object
 * @WL_DISPLAY_ERROR_INVALID_METHOD: method doesn't exist on the specified interface
 * @WL_DISPLAY_ERROR_NO_MEMORY: server is out of memory
 *
 * These errors are global and can be emitted in response to any server request.
 */
enum wl_display_error {
	WL_DISPLAY_ERROR_INVALID_OBJECT = 0,
	WL_DISPLAY_ERROR_INVALID_METHOD = 1,
	WL_DISPLAY_ERROR_NO_MEMORY = 2,
};

and structure documentation like this:

/**
 * wl_display - core global object
 * @bind: bind an object to the display
 * @sync: (none)
 *
 * The core global object. This is a special singleton object. It is used for
 * internal wayland protocol features.
 */
struct wl_display_interface {
	void (*bind)(struct wl_client *client,
		     struct wl_resource *resource,
		     uint32_t name,
		     const char *interface,
		     uint32_t version,
		     uint32_t id);
	void (*sync)(struct wl_client *client,
		     struct wl_resource *resource,
		     uint32_t callback);
};
2012-01-18 18:22:25 -05:00
Richard Hughes
4b5871e2b8 Fix 'make dist' as connection.h no longer exists 2012-01-13 12:58:52 -05:00
Neil Roberts
e0b6af03ca server: In default grab, update focus resource after sending release
The default grab implementation in wayland-server was updating the
focus resource before sending the button event. This would cause the
button release to be dropped from the implicit grab if the pointer is
moved away from the focus surface. This patch just swaps the order
around.
2012-01-12 10:59:07 -05:00
Kristian Høgsberg
151ca457b4 shm: Drop non-premul format, use less ambiguous ARGB8888 naming convention
This also matches the new wl_drm format names.
2012-01-11 14:19:54 -05:00
Kristian Høgsberg
b6b3d07c83 Move data device implementation into wayland-server 2012-01-06 11:40:02 -05:00
Kristian Høgsberg
dbb3ba7269 Move default grab implementation to wayland-server 2012-01-06 11:40:02 -05:00
Kristian Høgsberg
5ffe9f4708 New grab API
This commit changes the way struct wl_grab works in a couple of ways:

 - The grab itself now decides when it ends instead of hardcoding button
   up as the terminating event.  We remove the end vfunc since a grab now
   always know when it ends and can just clean up at that point.

 - We add a new focus vfunc that is invoked every time the pointer enters
   a new surface, regardless of any grabs.  The callback receives the
   surface and the surface-relative pointer coordinates.  The callback lets
   a grab send enter/leave events and change the grab focus.

 - The grab has a focus surface, wich determines the coordinate space
   for the motion callback coordinates.

 - The input device always tracks the current surface, ie the surface that
   currently contains the pointer, and coordinates relative to that surface.

With these changes, we will be able to pull the core input event delivery
and the drag and drop grab into the core wayland-server library.
2012-01-06 11:30:08 -05:00
Kristian Høgsberg
44b529f2e4 server: Allocate server ID for when resource->object.id is 0 2012-01-04 09:13:27 -05:00
Pekka Paalanen
c7473897fc server: remove wl_display::callback_list as unused
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-01-03 11:23:17 -05:00
Pekka Paalanen
2755847fce server: add wl_input_device_release()
Add a clean-up function for destroying all objects created in
wl_input_device_init(). Can be used to fix memory leaks reported by
Valgrind in the demos.

The init function was also missing an explicit initialisation of the
'keys' array. Add the explicit array init, although it is redundant with
the zeroing of the whole struct.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>

krh: Edited to rename function to *_release()
2012-01-03 11:22:58 -05:00
Kristian Høgsberg
d6465c5b40 Fix WL_EVENT_WRITEABLE typo 2011-12-28 22:51:34 -05:00
Kristian Høgsberg
c1b9203e5a Drop unused hash table
We now just use a table for looking up object IDs so we should drop the
hash table.
2011-12-27 13:58:56 -05:00
Kristian Høgsberg
bc79f1f820 Rename all instances of typeof 2011-12-22 15:32:37 -05:00