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>
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.
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>
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).
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.
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.
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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.
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
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>
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.
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>
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>
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>
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>
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>
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>
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>
Add THEME_FRAME_MAXIMIZED flag so the theming system can know not to draw
shadows for maximized windows. This allows maximized surfaces' content to be
sized and placed in a more expectable fashion.
The workspace state parameters were initialized after the first
roundtrip. If a workspace manager state event was received during this
roundtrip the state parameters were cleared leaving an incorrect state.
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>