Commit Graph

384 Commits

Author SHA1 Message Date
Kristian Høgsberg 15336e8b5c toytoolkit: Remove left-over pixman dependency
toytoolkit doesn't use pixman.  Remove the pixman.h include and the
LDADD.

https://bugs.freedesktop.org/show_bug.cgi?id=57812
2013-01-28 16:05:06 -05:00
Pekka Paalanen 0eab05d2a7 clients: add global_remove handler stubs
All the clients here were missing the global_remove handler. Because
window.c did not have it, weston-desktop-shell and weston-keyboard
segfaulted on compositor exit, as they received some
wl_registry.global_remove events.

Add more or less stub global_remove handlers, so that clients do not
crash on such events. Toytoolkit and all applications would need a lot
more code to properly handle the global object removal.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-01-24 16:42:38 -05:00
Rob Bradford f0a1af9f02 window: Free allocated memory on error path 2013-01-10 16:07:18 -05:00
Kristian Høgsberg 4e51b44c53 window: Fall back to cairo image when cairo EGL isn't available 2013-01-07 15:47:47 -05:00
Ander Conselvan de Oliveira 5403f5274d window: Allow clients to choose the fullscreen method 2012-12-14 11:27:34 -05:00
Pekka Paalanen 4dd0c412db window: add a note about freeing shm buffers
After a client has been double-buffering, and then switches to
single-buffering, it should release the 2nd buffer. That never happens
in practice here, so just add a comment and a check in case it ever
occurs in the future.

If we implemented the releasing now, it would be difficult to test.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-12-06 17:02:13 -05:00
Pekka Paalanen aac1c13332 clients: destroy wl_registry on exit
Plug an insignificant memory leak in demo programs that bother to clean
up at all.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-12-06 17:02:00 -05:00
Kristian Høgsberg bf74d5242a window: Add a widget default cursor convenience helper
In a few cases, we set a motion handler just to be able to set a fixed
cursor.  This adds a default cursor helper that can be used in those cases.
In case of the 'transformed' test case, we also avoid a brief flicker
of the pointer cursor, which is set on enter when the move grab is lifted.
2012-11-30 14:54:35 -05:00
Pekka Paalanen ec07669a08 window: change boolean to flags in toysurface::prepare()
Change the boolean parameter 'resize_hint' into a bitmask 'flags'.

Note, that this flags is very different to the other flags used in
creating the toysurface implementations. They do not make sense to mix
one way or the other. Prepare() cannot change the surface type, and
surface constructors do not care for dynamic hint flags.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-11-30 14:25:18 -05:00
Ander Conselvan de Oliveira 15256f66ab window: Add a way to retrieve a window's output transform
Add the output_get_transform() entry point and an output handler hook.
2012-11-30 14:24:08 -05:00
Ander Conselvan de Oliveira 6d4cb4e8c4 window: Let clients set buffer transformations
When a window's buffer transformation is set, its buffers are
reallocated with the appropriate size (i.e., with width and height
swapped in case of 90 or 270 degree rotation).
2012-11-30 14:24:04 -05:00
Ander Conselvan de Oliveira ddd3e27ab8 window: Honour opaque field for windows without a frame
Since the opaque region was set in frame_resize_handler(), if a client
created a frameless window setting the toplevel widget as opaque would
have no effect.

This patch fixes this by moving the call wl_surface_set_opaque_region()
to idle_resize(), and changing the latter function to set the whole
window as opaque if its toplevel widget has the opaque flag set.
2012-11-30 14:24:00 -05:00
Dima Ryazanov a85292e73c Fix a crash when opening two terminal windows and closing the first one.
To reproduce, launch the terminal, open a second window using Ctrl-Shift-N,
go back to the first window, and press Ctrl-D. The terminal's master FD gets
events even after being closed, causing terminal_destroy to be called twice
on the same object.

To fix this, I'm adding a function to stop watching an FD.
2012-11-30 14:11:41 -05:00
Pekka Paalanen a4eda73607 window: honour wl_buffer.release
Listen for wl_buffer.release events in the shm path, and if a previously
posted buffer is still held by the server, allocate another one. The
maximum of two should be enough, since there is no point for a server to
hold more than one buffer at a time.

Buffer allocation happens as needed instead of window creation time.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-11-27 15:57:54 -05:00
Pekka Paalanen 3cbb08944b window: fix tooltip text extents
After the toysurface rewrite, windows do not have a valid Cairo surface
outside their repaint cycle, so tooltips are not getting their size
right.

Create a dummy Cairo surface only for querying text extents, so we do
not rely on any window surfaces of parent windows or otherwise.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-11-27 15:50:53 -05:00
Pekka Paalanen b362736bb2 window: simplify window_create_surface
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-11-27 15:50:26 -05:00
Pekka Paalanen 9943686be3 window: convert shm path to toysurface
Implement shm_surface as a sub-class of toysurface, and unify the
toysurface call sites removing most buffer type specific branching.

Do not destroy and create a surface, if the size does not change.

The resizing optimization of shm surfaces is retained, but the pool is
moved from struct window to struct shm_surface, since it does not apply
to egl_window_surface.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-11-27 15:49:37 -05:00
Pekka Paalanen 03fc316000 window: add toysurface abstraction and port EGL path
We need more structure to the way we handle the backing storage in
toytoolkit, to make it possible to double-buffer the shm case properly.
The existing buffer handling is very complex with the three
different cases:
- EGLSurface backed Cairo surface with a window associated
- wl_shm backed Cairo surface with a window associated
- wl_shm backed Cairo surface without a window, as used by dnd.c

Introduce the toysurface abstraction, which defines the interface for
the both buffer handling cases that have a window associated. It also
means, that windows will not have a valid Cairo surface outside of their
repaint cycle.

Convert the EGLsurface case into toysurface for starters. For EGL-based
Cairo surfaces, the private data is no longer needed. Destroying
egl_window_surface will trigger the destruction of the cairo_surface_t,
not vice versa. This is possible because display_create_surface() is
shm-only.

The shm cases are left untouched.

As a side-effect, display_acquire_window_surface() and
display_release_window_surface() will no longer use the 'display'
argument. Instead, display will be the one inherited from the window.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-11-27 15:49:34 -05:00
Kristian Høgsberg 8c03616c39 weston-simple-im: Create our own xkb_context
There's no need to use the struct display xkb_context, we can just create
out ow.  This reverts c31288daf1.
2012-11-27 13:48:09 -05:00
Jan Arne Petersen c31288daf1 window: Allow to get xkb context from display
Add display_get_xkb_context to get the xkb context from the display.

Signed-off-by: Jan Arne Petersen <jpetersen@openismus.com>
2012-11-27 13:19:38 -05:00
Jan Arne Petersen cd99706b61 text: Send more information with keysym events
Send state and modifier from the demo keyboard with the keysym event and
take them into account in the editor example.

Add some helper functions to write and read a modifiers_map array.

Signed-off-by: Jan Arne Petersen <jpetersen@openismus.com>
2012-11-27 13:06:21 -05:00
Pekka Paalanen 768117f90b window: make display_create_surface() shm-only
Nothing uses it to create EGL-surfaces outside of window.c. This makes
refactoring the EGL-based code easier, since we do not need to support
EGL-based Cairo surfaces without an associated struct window.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-11-19 16:00:01 -05:00
Pekka Paalanen 32127ca86d window: use different keys for different cairo privates
cairo_surface_t objects have a private set, either struct
shm_surface_data, or struct egl_window_surface_data. Use separate
private keys for each type to avoid mismatch.

This makes display_get_buffer_for_surface() safe, in that it won't
return garbage for an EGL-based cairo surface.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-11-19 15:55:28 -05:00
Pekka Paalanen 0c6a34378a window: merge struct surface_data into shm_surface_data
Struct surface_data was not really useful, and it definitely was not
used with EGL-based windows.

This also fixes a semantic mistake, where struct shm_surface_data was
put into cairo_surface_t private, but got out as struct surface_data
instead. Due to struct layout, however, this did not cause a real bug.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-11-19 15:55:26 -05:00
Pekka Paalanen f86504c881 window: remove unused MULT macro
Leftovers from

commit f02a649a3c
Author: Kristian Høgsberg <krh@bitplanet.net>
Date:   Mon Mar 12 01:05:25 2012 -0400

    Consolidate image loading code and move to shared/

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-11-19 15:55:24 -05:00
Pekka Paalanen a8d4c84693 window: make window_flush() private
Not called from any client.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-11-19 15:55:17 -05:00
Pekka Paalanen ce36f6dff4 window: make window_{create,set}_surface private
I do not think these are meant to be called by the applications
directly. Applications certainly do not have to call them.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-11-19 15:55:12 -05:00
Daniel Stone 8097274ce6 Clients: Don't set the cursor when we have no pointer
Avoids a segfault whenever we get a key event, and try to set the
cursor, dereferencing a NULL input->pointer.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-11-08 11:31:37 -05:00
Kristian Høgsberg 0f7a285fe1 window.c: Move misplaced break to where it belongs
The break statement wasn't copy and pasted along with the rest of the code
causing menu item before it ("Move to workspace below") to fall through to
the fullscreen case.
2012-11-05 20:24:32 -05:00
Kristian Høgsberg e77d7577a2 window: Fix use-after-free in menu button handler
Commit d2fbb3870c introduced a use-after-free
error in the case where we destroy the menu.
2012-10-30 18:10:32 -04:00
Kristian Høgsberg efb948846f window: Only advertise fullscreen menu item if client supports it
If the client doesn't set a fullscreen handler, we can't go fullscreen
and shouldn't advertise that in the window menu.  The menu implementation is
a little simplistic, so we just move the "Fullscreen" entry to the end of
the list and don't count it if we don't want it in the menu.

https://bugs.freedesktop.org/show_bug.cgi?id=47751
https://bugs.freedesktop.org/show_bug.cgi?id=48106
2012-10-30 18:07:02 -04:00
Scott Moreau 1bdb477522 toytoolkit: Don't destroy window cairo surface on shm attach.
https://bugs.freedesktop.org/show_bug.cgi?id=52454
2012-10-30 14:18:49 -04:00
Kristian Høgsberg d2fbb3870c window: Make press-drag-release menu selection mode work
The intended behavior is that a quick click (press and then release
within 500ms) just pops up the menu and doesn't select anything.  Then
we can mouse around and and click to select an item.  Alternatively, a
click and hold (ie press and release after 500ms) lets you press right
button, mouse down on the menu item you want and release to select it.
This is how menus work in most toolkits.

The handling in weston is fine, it's there to handle the case where
the button release happens outside any client window, since the client
doesn't get those events.  If such a release happens late or we get a
second release outside the popup window we shut down the popup.

The problem is in toytoolkit, where we need to select the item if we
get a release within 500ms or if we get a second release.  A second
release is the case where the first release came after 500ms and
didn't pop down the menu, and the second release event is from a click
on a menu item.

https://bugs.freedesktop.org/show_bug.cgi?id=52456
2012-10-30 13:45:31 -04:00
Kristian Høgsberg e530a0a240 window: Ignore input_set_pointer_image() if we don't have a pointer
https://bugs.freedesktop.org/show_bug.cgi?id=55782
2012-10-29 16:42:26 -04:00
Jonas Ådahl f461eee2b0 window: Always pass focused widget to widget motion handlers
Grabbed widgets should always receive motion events as if it was the
widget that would receive it if no grab was active. This means that the
focused widget should always be passed as the widget argument to widget
motion handlers.

This reverts commit 8c9c8fcf6e.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2012-10-19 16:56:08 -04:00
Jonas Ådahl f82eda5247 window: Don't set pointer image when requesting to move a surface
Since it's the server who moves the surface it's the server who sets the
pointer image.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2012-10-19 16:54:42 -04:00
Kristian Høgsberg 3146756adf clients: Don't ask for EGL_PIXMAP_BIT when choosing configs 2012-10-16 15:31:31 -04:00
Kristian Høgsberg a17f7a13fd clients: Check return value of wl_display_dispatch()
The simple clients all just call wl_display_dispatch() in a while loop
without checking the return value.  Now, if the server dies or other
error occurs, we get a -1 return value instead and need to break the loop.
2012-10-16 13:17:16 -04:00
Pekka Paalanen fb39d8d23c toytoolkit: make all EGL code dependant on cairo-egl
configure.ac: The toytoolkit clients used to get libEGL linked to them
even if there was no cairo-egl. This is useless, and actually harmful on
platforms, where libEGL absolutely requires one of the GL ES libraries
to be linked in, too.

Look for EGL-related packages only for cairo-egl with toytoolkit.

window.c: protect all GL header includes with HAVE_CAIRO_EGL, since that
is the only case we can support EGL, GL, or GLESv2 at all. In the case
we do not have cairo-egl, add enough definitions to let us build the
stubs for EGL-related functions.

Remove some #ifdefs that were inside of the same #ifdef already.

These changes allow to build sorfware rendering toytoolkit clients
without any bits of EGL libs or headers.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-10-16 10:47:22 -04:00
Pekka Paalanen 53e58485a5 window: remove dead EGL code
- remove unimplemented function from header
- remove the egl function pointers that were not used

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-10-16 10:46:15 -04:00
Kristian Høgsberg 3fb613effe window: Set input region also when we go fullscreen
We used to rely on the compositor resetting this as a side effect of
changing size, but it doesn't work like that any more.
2012-10-15 20:54:43 -04:00
Jonas Ådahl d9f6b078b6 window: Update modifier state directly after receiving a modifier event
If the keyboard modifier event was received after the key event the
modifier state would end up incorrect.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2012-10-15 20:54:43 -04:00
Pekka Paalanen b2f957a9f1 window: don't call output configure uninitialised
Callbacks registered via display_set_output_configure_handler() are
promised to be called when we know the current mode for the output. If
the following order of events happens:
1. toytoolkit binds to a wl_output global
2. application registers an output configure handler
3. the wl_output.mode events are received

Then in step 2 we would call the callback with uninitialised output
informations, giving it a 0x0 size.

To avoid such race, do not call the callback from
display_set_output_configure_handler() if the output has 0x0 size.

The wl_output.mode event will be received later, and that will trigger
the right call to the callback.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-10-15 20:54:43 -04:00
Kristian Høgsberg feb3c1d33b clients: Use wl_display_dispatch_pending() 2012-10-15 20:54:43 -04:00
Pekka Paalanen bc10638cd9 compositor, clients: apply wl_surface.frame on commit
Apply wl_surface.frame request only on the next wl_surface.commit
according to the new protocol.

This makes it explicit, which repaint actually triggered the frame
callback, since commit schedules a repaint. Otherwise, something causing
a repaint before a commit could trigger the frame callback too early.

Ensure all demo clients send commit after wl_surface.frame. Note, that
GL apps rely on eglSwapBuffers() sending commit. In toytoolkit, it is
assumed that window_flush() always does a commit.

compositor-wayland assumes renderer->repaint_output does a commit.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-10-10 21:39:11 -04:00
Pekka Paalanen 0cbd3b5059 compositor, clients: double-buffer input region
Make input region double-buffered as specified in the new protocol.

While doing it, get rid of the undef region code, and instead use a
maximum sized real pixman region. This avoids special-casing regions
that might sometimes be undef.

As the input region is now usable by default instead of undef,
weston_surface_update_transform() does not need to reset the input
region anymore.

weston_surface_attach() no longer resets the input region on surface
size change. Therefore, also weston_seat_update_drag_surface() does not
need to reset it.

Update toytoolkit to set input region before calling wl_surface_commit()
or swapBuffers (which does commit).

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-10-10 21:38:44 -04:00
Pekka Paalanen 512dde8ce9 compositor, clients: double-buffer opaque region
Make wl_surface.set_opaque_region double-buffered as required by the new
protocol. Also, do not reset the opaque region on surface size changes
anymore. Only explicit requests from the client will change the region
now.

In clients, make sure commit happens after setting the opaque region.

Mesa does not need a fix, as it never touches the opaque region.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-10-10 21:38:40 -04:00
Pekka Paalanen c9e00c06e9 clients: use wl_surface_commit
Use wl_surface_commit() to commit the buffer attach, as Weston now
requires.

NOTE: GL-applications are broken until you upgrade to a version of Mesa
which does wl_surface_commit() on eglSwapBuffers(). If you have
Cairo-gl, this means all toytoolkit apps, too.

simple-shm and simple-touch OTOH will work now.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-10-10 21:38:17 -04:00
Kristian Høgsberg fa80e11c84 Update to new fd and wl_registry APIs
This commit updates the clients and the wayland compositor backend to
use the new wl_registry mechanism and the thread safe fd API.
2012-10-10 21:34:38 -04:00
Scott Moreau 4e07236e87 toytoolkit: Take into account transform when sending output allocation. 2012-10-10 13:02:11 -04:00