Make sure that display_acquire_window_surface() creates the Cairo
surface as necessary. Otherwise surface->toysurface can be NULL.
This fixes weston-screensaver fullscreen mode. Demo mode was not
affected as it uses window decorations, and so the Cairo surface is
created. This regression was introduced by:
commit 0c4445ba57
Author: Pekka Paalanen <ppaalanen@gmail.com>
Date: Wed Feb 13 16:17:23 2013 +0200
window: create Cairo surfaces on demand for redraw
Reported-by: Ander Conselvan de Oliveira <ander.conselvan.de.oliveira@intel.com>
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
Ideally the shell would send an unmaximize event to the client when
we try to move a maximized window, but for now, let's just prevent
moving maximized windows.
https://bugs.freedesktop.org/show_bug.cgi?id=56296
This introduces the function widget_cairo_create().
Instead of directly referencing surface->cairo_surface, use the function
widget_cairo_create(), which will create the cairo_surface as necessary,
and just returns a Cairo drawing context. Also fix window_get_surface()
similarly.
Now we can go through idle_redraw() without always creating Cairo
surfaces and committing them. This will be useful with sub-surfaces,
where repainting one sub-surface does not need to force the repaint of
all surfaces of a window.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
Menu and tooltip redraw functions were using the surface size directly.
For consistency, make them use the widget size instead, it is the same.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
Widgets should be rendering to a cairo_surface for a particular
wl_surface, just like buffers are per surface.
window_flush() has a change in behaviour: it will now send
wl_shell_surface.set_toplevel also without a cairo_surface to be
attached. This shouldn't change anything in practice.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
So that given a widget, we can access the surface specific data, like
buffers, and input and opaque regions.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
They are per wl_surface state.
The frame widget is always on the main surface, since it can be created
only for the window. That is why frame_resize_handler() can simply
assume that the surface is the main_surface.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
Repaint and resizing widget recursions must start from the root widget
of each (sub-)surface, so that buffers and regions get initialized
correctly. Make it easier by moving the widget field from struct window
to struct surface.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
These are surface specifics, since buffers are surface specific.
SURFACE_HINT_RESIZE is moved together to the other SURFACE_* flags, so
that surface_create_surface() would not need two flags arguments.
struct toysurface::prepare vfunc checks for SURFACE_HINT_RESIZE, and
egl_window_surface_create() and shm_surface_create() check for the
non-HINT flags.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
Fields 'allocation' and 'server_allocation' are surface specific. Fields
'saved_allocation', 'min_allocation', and 'pending_allocation' are
window specific, and will not be moved.
Field 'toysurface' is naturally surface specific, since it provides the
backing storage for the wl_surface.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
Struct window has many fields that are directly related to the
wl_surface, more than to the window as a whole. When we start composing
a window from several wl_surfaces, these fields need to be per
wl_surface, not per window.
Start separating such fields from struct window into struct surface by
moving the wl_surface.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
Handle the case when we the compositor somehow migrates from requiring
double buffering into working on single buffering, so we release the
extra shm buffer.
Currently, I do not think this can happen in practice, but in the future
it may happen with sub-surfaces.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
Check for errors in the first wl_display_dispatch() call. Otherwise
doing something silly like
$ WAYLAND_SOCKET=999 ./clickdot
will segfault.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
Make them explicitly mention EGL, otherwise one can easily think that
"failed to initialize display" refers to Wayland display.
Also explicitly mention falling back to wl_shm. I tested this with a
LD_PRELOAD trick that overrides eglBindAPI and makes it fail.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
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>
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