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>
weston-screenshooter is a helper binary that weston launches to write the
screenshot to disk. If somebody tries to launch it by hand, print a
warning and mention the screenshot keybinding.
This way libtool will remember the libtoytoolkit LIBADD libraries.
We can drop the toolkit_libs hack and just link to libtoytoolkit.la and
libtool will add the dependencies.
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>
We want to make sure that the matrix symbols are exported from weston and
that modules get them from there. To do that, we pull matrix.[ch] out of
libshared and back into weston. calibrator now also links to matrix.[ch]
and we add a IN_WESTON define to enable the WL_EXPORT macro when compiled
inside weston.
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>
This a basic calibration tool designed for "in factory" calibration of a touch
screen. The constants for the calibration functions:
x' = Ax + By + C and
y' = Dx + Ey + F
Are printed on stdout when the calibration is completed.
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.
We were pulling in cairo and the image loading libraries through libshared.
Split out libshared into a core libshared and a libshared-cairo that
pulls in the extra libraries.
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>
Toytoolkit doesn't buy us anything in this case, we're not rendering or
handling regular input events. Just talk directly to wl_display and
look up the 'input_method' global directly.
The key events we pass through to the input_method_context has to have
a serial number that corresponds to the key event we got. The struct display
serial is updated on pointer enter/leave and keyboard events, but not the
input method keyboard events. So the display serial will never correspond
to the key event we're dealing with and we have to pass through the
serial we get from the key event.