Commit Graph

1613 Commits

Author SHA1 Message Date
Daiki Ueno
60fc83af6e build: Install wayland-scanner.mk under $(pkgdatadir). 2013-07-03 16:37:31 -04:00
Kristian Høgsberg
3cff4693ea wayland-server: Free non-legacy wl_resource structs during wl_client_destroy
We need to free the non-legacy resources during client shutdown as well.
2013-07-02 17:01:46 -04:00
Kristian Høgsberg
477c7237e1 wayland-server: Remove left-over double free in unbind_resource() helper 2013-07-02 17:01:46 -04:00
Kristian Høgsberg
c82a52a47e wayland-server: Remove error event posting from wl_resource_create
The wl_client_add/new_object() functions sends out an NO_MEMORY error if
the allocation fails.  This was convenient in a couple of places where
that was all the error handling that was needed.  Unfortunately that
looks like out-of-memory isn't handled at the call site and set a bad
precedent for not cleaning up properly or not handling at all.

As we're introducing wl_resource_create() as a replacement for those two
functions, let's remove the automatic error event posting and require
the caller to do that if necessary.

This commit also introduces a new helper, wl_client_post_no_memory() to
make it possible to send NO_MEMORY events from bind where we don't have
a wl_resource.
2013-07-02 17:01:46 -04:00
Kristian Høgsberg
b5b1165008 wayland-server: Mark wl_client_add/new_object as deprecated 2013-07-02 17:01:46 -04:00
Kristian Høgsberg
9cc0a67896 wayland-server: Dont free resource in user data destroy callback 2013-07-02 17:01:46 -04:00
Jason Ekstrand
a09d7f0d60 wayland-server: Verify request versions before invoking handler
This commit provides a layer of protection for the compositor in the form
of message version checking.  We track version information in the
wl_resource and now use this version information to verify that a request
exists in that protocol version before invoking it.  This way libwayland
won't accidentally invoke a request that does not exist and thereby cause
the compositor to crash.

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-07-02 17:01:46 -04:00
Jason Ekstrand
4917a967bd Add wl_resource_create() and a version field to wl_resource
A new function, wl_resource_create(), lets the compositor create a
wl_resource for a given version of the interface.  Passing 0 for the
object ID will allocate a new ID. The implementation, user data and
destructor can be set with wl_resource_set_implementation().

These two functions deprecates wl_client_add/new_object and the
main difference and motivation is the ability to provide a version number
for the resource.  This lets the compositor track which version of the
interface a client has created and we'll use that to verify incoming requests.

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-07-02 17:01:23 -04:00
Jason Ekstrand
d35b6278c0 Add version information to wl_message signatures.
This commit adds version information to wl_message signatures and a
wl_message_get_since function to retrieve.  The since version comes in the
form of a (possible) integer at the begining of the message.  If the
message starts with an integer, then it specifies the "since" version of
that message.  Messages present in version one do not get this "since"
information.  In this way we can run-time detect the version information
for a structure on a per-message basis.

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-07-02 15:52:47 -04:00
Kristian Høgsberg
d94a8722cb server: Make wl_object and wl_resource opaque structs
With the work to add wl_resource accessors and port weston to use them,
we're ready to make wl_resource and wl_object opaque structs.  We keep
wl_buffer in the header for EGL stacks to use, but don't expose it by
default.  In time we'll remove it completely, but for now it provides a
transition paths for code that still uses wl_buffer.

Reviewed-by: Jason Ekstrand<jason@jlekstrand.net>
2013-07-02 15:52:47 -04:00
Rob Bradford
2e07587443 protocol: add no_keymap format to keymap formats
This format is used to specify that the key button events received are not in
relation to any key map and that the codes should be interpreted directly.

v2: Use zero for the no keymap enum value and enhance the documentation
for the enum entry.
2013-06-28 19:51:12 -04:00
Jason Ekstrand
3af748b872 Change wl_shm_buffer to use a resource pointer
This commit also has the effect of making wl_shm_buffer no longer a
wl_buffer derivative.

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-06-21 19:18:08 -04:00
Jason Ekstrand
ee0d986a50 Change SHM wl_buffer functions to use the wl_shm_buffer structure
This commit does not break ABI.  It merely changes the types of some things
and adds a wl_shm_buffer_get function.

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-06-21 19:18:06 -04:00
Jason Ekstrand
5ac5d55d81 Add a wl_resource_instance_of function
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-06-21 19:18:04 -04:00
Jason Ekstrand
96afa34776 Free non-legacy resources inside wl_resource_destroy
This commit makes wl_resource_destroy automatically free all non-legacy
resource structures.  Since wl_resource is now an opaque structure it
doesn't make sense for the clients to be freeing it.  This checks to make
sure that it was added through wl_client_add_object or wl_client_new_object
and not wl_client_add_resource before it frees it.  This way if it is a
legacy resources embedded in a structure somewhere we don't have an invalid
free.

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-06-20 15:12:26 -04:00
Ander Conselvan de Oliveira
7094441b1d doc: Add a small contributing guide
Document what we expect in terms of commit messages and coding style.
New contributors are usually unaware of this, so it is good to have a
document to point them too.
2013-06-18 01:29:01 -04:00
Kristian Høgsberg
3c7e8bfbb4 client: Add wl_display_prepare_read() API to relax thread model assumptions
The current thread model assumes that the application or toolkit will have
one thread that either polls the display fd and dispatches events or just
dispatches in a loop.  Only this main thread will read from the fd while
all other threads will block on a pthread condition and expect the main
thread to deliver events to them.

This turns out to be too restrictive.  We can't assume that there
always will be a thread like that.  Qt QML threaded rendering will
block the main thread on a condition that's signaled by a rendering
thread after it finishes rendering.  This leads to a deadlock when the
rendering threads blocks in eglSwapBuffers(), and the main thread is
waiting on the condition.  Another problematic use case is with games
that has a rendering thread for a splash screen while the main thread
is busy loading game data or compiling shaders.  The main thread isn't
responsive and ends up blocking eglSwapBuffers() in the rendering thread.

We also can't assume that there will be only one thread polling on the
file descriptor.  A valid use case is a thread receiving data from a
custom wayland interface as well as a device fd or network socket.
The thread may want to wait on either events from the wayland
interface or data from the fd, in which case it needs to poll on both
the wayland display fd and the device/network fd.

The solution seems pretty straightforward: just let all threads read
from the fd.  However, the main-thread restriction was introduced to
avoid a race.  Simplified, main loops will do something like this:

	wl_display_dispatch_pending(display);

	/* Race here if other thread reads from fd and places events
	 * in main eent queue.  We go to sleep in poll while sitting on
	 * events that may stall the application if not dispatched. */

	poll(fds, nfds, -1);

	/* Race here if other thread reads and doesn't queue any
	 * events for main queue. wl_display_dispatch() below will block
	 * trying to read from the fd, while other fds in the mainloop
	 * are ignored. */

	wl_display_dispatch(display);

The restriction that only the main thread can read from the fd avoids
these races, but has the problems described above.

This patch introduces new API to solve both problems.  We add

	int wl_display_prepare_read(struct wl_display *display);

and

	int wl_display_read_events(struct wl_display *display);

wl_display_prepare_read() registers the calling thread as a potential
reader of events.  Once data is available on the fd, all reader
threads must call wl_display_read_events(), at which point one of the
threads will read from the fd and distribute the events to event
queues.  When that is done, all threads return from
wl_display_read_events().

From the point of view of a single thread, this ensures that between
calling wl_display_prepare_read() and wl_display_read_events(), no
other thread will read from the fd and queue events in its event
queue.  This avoids the race conditions described above, and we avoid
relying on any one thread to be available to read events.
2013-06-17 11:50:42 -04:00
Jason Ekstrand
61ac9c6849 server: Add aditional wl_resource accessors
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-06-14 15:56:08 -04:00
Rob Bradford
885d057536 protocol: Add missing since attribute for name event on wl_seat
This event was added in version 2 of the protocol.
2013-06-14 14:56:50 -04:00
Rob Bradford
c56af574ca build: Fix warning message on syscall failures 2013-06-14 14:56:43 -04:00
Kristian Høgsberg
bca4124045 server: Add wl_resource_get_id() 2013-06-07 01:00:30 -04:00
Jason Ekstrand
57f74af278 Update tests for wl_map changes and add a map_flags test 2013-06-05 17:55:14 -04:00
Jason Ekstrand
2d586a759e Remove incorrect sanity-check from wl_map_insert_at
I got a little over-eager with my sanity checks and didn't realize that the
client uses wl_map_insert_at to mark objects as zombies when they come from
the server-side.

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-06-05 17:45:47 -04:00
Jason Ekstrand
8fd60c683a Change WL_ZOMBIE_OBJECT from 0x2 to an actual pointer
In order to use the second-lowest bit of each pointer in wl_map for the
WL_MAP_ENTRY_LEGACY flag, every pointer has to be a multiple of 4.  This
was a good assumption, except with WL_ZOMBIE_OBJECT.  This commit creates
an actual static variable to which WL_ZOMBIE_OBJECT now points.  Since
things are only every compared to WL_ZOMBIE_OBJECT with "==" or "!=", the
only thing that matters is that it is unique.

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-06-05 17:45:36 -04:00
Kristian Høgsberg
a3870a297c protocol: Move new name event below existing requests and events and version it
Missed v2 of Robs patch that already did this based on feedback from
Ander and Daniel.
2013-06-05 01:08:58 -04:00
Jason Ekstrand
1488c96a5d Add accessor functions for wl_resource and deprecate wl_client_add_resource
This is the first step towards making wl_resource an opaque pointer type.

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-06-05 00:59:08 -04:00
Jason Ekstrand
2c7468b868 Add support for flags in the wl_map API and add a WL_MAP_ENTRY_LEGACY flag
The implementation in this commit allows for one bit worth of flags.  If
more flags are desired at a future date, then the wl_map implementation
will have to change but the wl_map API will not.

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-06-05 00:55:17 -04:00
Jason Ekstrand
28472970df Add a "side" field and some sanity checks to wl_map.
The original wl_map implementation did no checking to ensures that ids fell
on the correct side of the WL_SERVER_ID_START line.  This meant that a
client could send the server a server ID and it would happily try to use
it.  Also, there was no distinction between server-side and client-side in
wl_map_remove.  Because wl_map_remove added the entry to the free list
regardless of which side it came from, the following set of actions would
break the map:

1. Client creates a bunch of objects
2. Client deletes one or more of those objects
3. Client does something that causes the server to create an object

Because of the problem in wl_map_remove, the server would take an old
client-side id, apply the WL_SERVER_ID_START offset, and try to use it as a
server-side id regardless of whether or not it was valid.

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-06-05 00:33:57 -04:00
Rob Bradford
dce104dcc2 protocol: Add a name event to give seat name
This provides the ability for a client to differentiate events from
different seats in a multiple seat environment.
2013-06-05 00:05:25 -04:00
Rob Bradford
bc3e020475 build: Add declaration checks to check for required syscall flags
The required flags are relatively new and some older enterprise distributions
do not feature them.

https://bugs.freedesktop.org/show_bug.cgi?id=63360
2013-06-04 23:13:34 -04:00
Alexander Larsson
b693088904 protocol: Modes are specified in HW pixels
Modes are mainly meant to be used in coordination with fullscreen in
DRIVER mode, by e.g. games. For such games what they generally want
is to match some hardware mode and resize their window for that. We
don't really need to complicate this with the scaling. So, we
keep the resolutions in HW pixels, and drop the SCALED flag (as it
is now useless).

This lets you just create e.g an 800x600 buffer of scale 1 and
fullscreen that, ignoring the output scaling factor (although you can
of course also respect it and create a 400x300 surface at scale 2).
Conceptually the mode change is treated like a scaling which overrides
the normal output scale.

The only complexity is the FILL mode where it can happen that the user
specifies a buffer of the same size as the screen, but the output has scale
2 and the buffer scale 1. Just scanning out this buffer will work, but
effectively this is a downscaling operation, as the "real" size of the surface
in pels is twice the size of the output. We solve this by allowing FILL to
downscale (but still not upscale).
2013-05-28 15:40:02 -04:00
Alexander Larsson
e782dbecbc protocol: Use signed int for scale values
We usually use signed ints for things like this, to avoid
issues C sign coersion.
2013-05-28 15:27:36 -04:00
Alexander Larsson
d68c7d8aed protocol: Support scaled outputs and surfaces
This adds the wl_surface.set_buffer_scale request, and a wl_output.scale
event. These together lets us support automatic upscaling of "old"
clients on very high resolution monitors, while allowing "new" clients
to take advantage of this to render at the higher resolution when the
surface is displayed on the scaled output.

It is similar to set_buffer_transform in that the buffer is stored in
a transformed pixels (in this case scaled). This means that if an output
is scaled we can directly use the pre-scaled buffer with additional data,
rather than having to scale it.

Additionally this adds a "scaled" flag to the wl_output.mode flags
so that clients know which resolutions are native and which are scaled.

Also, in places where the documentation was previously not clear as to
what coordinate system was used this was fleshed out.

It also adds a scaling_factor event to wl_output that specifies the
scaling of an output.

This is meant to be used for outputs with a very high DPI to tell the
client that this particular output has subpixel precision. Coordinates
in other parts of the protocol, like input events, relative window
positioning and output positioning are still in the compositor space
rather than the scaled space. However, input has subpixel precision
so you can still get input at full resolution.

This setup means global properties like mouse acceleration/speed,
pointer size, monitor geometry, etc can be specified in a "mostly
similar" resolution even on a multimonitor setup where some monitors
are low dpi and some are e.g. retina-class outputs.
2013-05-22 16:15:33 -04:00
Alexander Larsson
911c068428 protocol: Allow output changes to be treated atomically
This add a wl_output.done event which is send after every group
of events caused by some property change. This allows clients to treat
changes touching multiple events in an atomic fashion.
2013-05-22 16:15:29 -04:00
Peng Wu
5144cf6206 protocol: Fix documentation typo 2013-05-22 15:49:13 -04:00
Kristian Høgsberg
508dd69b56 server: Drop struct wl_surface
This struct was only defined in the server API for the purpose of the
input structs and helper functions.  Now that those are gone we can dro it.
2013-05-08 09:45:59 -04:00
Kristian Høgsberg
e920572e5c Remove input structs
Looking at the functionality in the server library, it's clear (in
hindsight) that there are two different "things" in there: 1) The IPC
API, that is, everything that concerns wl_display, wl_client,
wl_resource and 2) and half-hearted attempt at sharing input code and
focus logic that leaves a lot of problematic structs in the API
surface, only to share less than 1000 lines of code.

We can just move those input structs and helper functions into weston
and cut libwayland-server down to just the core server side IPC API.
In the short term, compositors can copy those structs and functions
into their source, but longer term, they're probably better off
reimplementing those objects and logic their native framework
(QObject, GObject etc).
2013-05-07 09:10:49 -04:00
Kristian Høgsberg
83248317e4 configure.ac: Bump to 1.1.90 to open master for 1.2 work 2013-04-29 16:42:40 -04:00
Peter Hutterer
cfec3aecb9 protocol: revert hotspot_x/y in set_cursor back to int
copy/paste error introduced in 9c0357af6e

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-04-18 16:28:52 -04:00
Rob Bradford
e7d0a0b0ed protocol: Make it clear that returned "one-shot" objects are destroyed
The objects returned by the frame and sync request are destroyed by the
compositor after the "done" event on the wl_callback interface is fired.
2013-04-18 16:28:52 -04:00
Kristian Høgsberg
e593832066 configure.ac: Bump version to 1.1.0 2013-04-15 20:55:33 -04:00
Kristian Høgsberg
1daa6b3877 docs: Create html-pdf directories too
Fixes make dist here.
2013-04-15 20:50:52 -04:00
Peter Hutterer
509d1d802a doc: use a dynamic list of man pages
This requires that doxygen is run before the man target so find can actually
find the man pages.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-04-04 16:58:01 -04:00
Peter Hutterer
3ddedc053f doc: Improve "Library" and "Compositors" chapter
Originally written Tiago Vignatti <tiago.vignatti@intel.com>

Some modifications to adjust for previously merged conflicting patches and link
to the sections (instead of <emphasis>).

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-04-04 16:57:44 -04:00
Peter Hutterer
5cf14f4b57 doc: create a fake make target to de-duplicate the xml merging process
The only difference between the server and client xml files is the
directories and files being named *server* and *client*, respectively. Add a
new make target to get that process done to avoid duplication

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-04-04 16:57:28 -04:00
Peter Hutterer
b1d7131c36 doc: generate server documentation from XML too
Same as WaylandClientAPI.xml we now also generate WaylandServerAPI.xml for
publication. Most of this hunk is just adding a client/ or server/ into the
xml path to keep the two separate.

The change in wayland.doxygen now causes a standard doxygen call to not
generate anything - what is generated is specified through the options
passed by make.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-04-04 16:57:18 -04:00
Tiago Vignatti
5e014c81cc doc: Capitalize all Wayland occurrences
Signed-off-by: Tiago Vignatti <tiago.vignatti@intel.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>

[re-run of search/replace after rebasing]

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-04-04 16:57:07 -04:00
Peter Hutterer
4f7f09b4c8 protocol: input documentation fixes
Fix summary for wl_touch::motion, extend summary for wl_touch::down to match
up/motion a bit better.

Fix a typo in wl_touch, and claim that it's zero or more update events, not
one or more.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-04-04 16:40:12 -04:00
Rob Bradford
9fbcc7ae7d wayland-client: Avoid null dereference when handling deletion
If an unknown id is deleted then the lookup in the map will return NULL and
so we should avoid dereferencing that.

As this is unexpected behaviour log a message about the problem too.
2013-04-04 12:39:57 -04:00
Kristian Høgsberg
477dcd84c7 docs: Use MIT for documentation license 2013-04-03 16:26:14 -04:00