Commit Graph

181 Commits

Author SHA1 Message Date
Murray Calavera 883ac02d22 Whitespace corrections
Signed-off-by: Murray Calavera <murray.calavera@gmail.com>
2015-06-06 12:39:51 -07:00
Jonny Lamb 51a7ae5f89 clients & tests: use eglGetPlatformDisplayEXT when supported
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
2015-03-20 13:56:38 -07:00
Jasper St. Pierre de8bd50d35 clients: Allow creating a "detached" menu
This will be used by the xdg_surface.show_menu_window implementation.
2014-05-23 09:37:19 -07:00
Jasper St. Pierre dda9313bd9 clients: Remove the window / user parameters from the menu function
We want the ability to create a detached menu.
2014-05-18 13:54:15 -07:00
Jasper St. Pierre de6809912e terminal: Only add the new size to the title when we're resizing
Add a new state_changed_handler callback to the window to know when the
window has changed state; the terminal will use this to know when the
window started and ended its resize operation, and modify the terminal's
titlebar accordingly.
2014-05-12 23:34:05 -07:00
Jasper St. Pierre c815d62b85 xdg-shell: Rename set_transient_for to set_parent
It's a confusing name that comes from the ICCCM. The ICCCM is best
forgotten about.

With the addition of the potential new "transient" role meaning a
parent-relative toplevel like a long-lived popup, used for e.g.
tooltips, the set_transient_for name will become even more confusing.
2014-05-13 00:35:30 -04:00
Andrew Wedgbury 9cd661e746 Make sure config.h is included before any system headers
There was an issue recently in screen-share.c where config.h was not
being included, resulting in the wrong definition for off_t being used on
32 bit systems. I checked and I don't think this problem is happening
elsewhere, but to help avoid this sort of problem in the future, I went
through and made sure that config.h is included first whenever system
headers are included.

The config.h header should be included before any system headers, failing
to do this can result in the wrong type sizes being defined on certain
systems, e.g. off_t from sys/types.h

Signed-off-by: Andrew Wedgbury <andrew.wedgbury@realvnc.com>
2014-04-07 10:22:28 -07:00
Manuel Bachmann cd186fbfaf toytoolkit: match parent surface type when adding a subsurface
When adding a subsurface (to display a tooltip) in toytoolkit,
we now get the parent window surface type (SHM or EGL) and
define the new surface type as the same.

This fixes crashes with tooltips in cases like having
Cairo-EGL available but running the X11 compositor.

Signed-off-by: Manuel Bachmann <manuel.bachmann@open.eurogiciel.org>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
2014-04-06 22:37:45 -07:00
Jason Ekstrand 738715d628 toytoolkit: Expose output make and model
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2014-04-02 21:26:16 -07:00
Jasper St. Pierre 5a183329ca clients: Add support for the minimize button 2014-02-18 19:20:18 -05:00
Jasper St. Pierre 53686048cc window: Add wrappers for xdg_surface_set_transient_for 2014-02-01 01:53:05 -08:00
Jasper St. Pierre 76ec0826bc westoy: Remove fullscreen methods
These aren't supported under xdg_shell, at least not right now.
If xdg_shell ever gets support for them, we can revert this commit
and adapt it.
2014-02-01 01:43:02 -08:00
Jasper St. Pierre 7f4386e90a westoy: Use subsurfaces for tooltips instead of transient windows
Transient windows, at least not as they are today, don't exist in
xdg_shell. Subsurfaces allow for specially placed surfaces relative
to a window, so use these instead.
2014-02-01 01:42:35 -08:00
Kristian Høgsberg 700d6ad071 keyboard: Don't strcat() into a strdup()ed string
We need to reallocate the memory to hold the entire concatenated string,
but strcat() doesn't do that.

Closes: https://bugs.freedesktop.org/show_bug.cgi?id=71750
2014-01-09 23:45:18 -08:00
Neil Roberts 97b747cdda westoy: Add an option to explicitly disable cairo on a widget
The subsurfaces example creates a subsurface widget and uses EGL to
render to it directly rather than using the cairo context from the
widget. In theory this shouldn't cause any problems because the westoy
window code lazily creates the cairo surface when an application
creates a cairo context. However commit fdca95c7 changed the behaviour
to force the lazy creation at the beginning of each surface redraw.
This ends up making the triangle surface get two attaches – one from
Cairo and one from the direct EGL.

It looks like it would be difficult to reinstate the lazy surface
creation behaviour whilst still maintaining the error handling for
surface creation because none of the redraw handlers in the example
clients are designed to cope with that. Instead, this patch adds an
explicit option on a widget to disable creating the Cairo surface and
the subsurface example now uses that.

Closes: https://bugs.freedesktop.org/show_bug.cgi?id=72854
2014-01-09 15:03:15 -08:00
Kristian Høgsberg ef9c8eb2db keyboard: Handle touch up event
This fixes arrow keys which trigger on button up.

Closes: https://bugs.freedesktop.org/show_bug.cgi?id=73169
2014-01-07 12:57:59 -08:00
Neil Roberts 5e10a04481 clients: Add a widget_get_wl_subsurface
Adds a simple accessor for the wl_subsurface for widgets created with
window_add_subsurface.
2013-12-04 16:34:07 -08:00
Philip Withnall c971d2a8b3 clients: Add window_is_transient() helper to the toy toolkit window 2013-12-02 11:44:50 -08:00
Xiong Zhang bf3c1c6913 distinguish touch screen and pointer dnd in client
Data device interface in client just handle with pointer's dnd.
If a touch screen trigger dnd, it will use pointer struct like i
nput->sx, input->sy, input->pointer_focus. So if pointer is moving
when touch screen trigeer a dnd, wrong behaviore will occur.
Before touch screen start dnd, system call touch_grab()
to mark the following drag and drop operation is generated by
touch screen.
Defined some common variables in struct input to track dnd.

Note, touch screen and pointer can't generate drag and drop at the
same time, becuae data device protocol can't identify the drag
and drop event is generated by touch screen or pointer.

Signed-off-by: Xiong Zhang <xiong.y.zhang@intel.com>
Reviewed-by: Kristian Hogsberg <hoegsberg@gmail.com>
2013-11-25 16:32:12 -08:00
Pekka Paalanen a662206e71 protocol: move sub-surfaces to Wayland
This reverts commit 2396aec684.

This exact version of the sub-surface protocol has been copied into
Wayland core. Therefore it must be removed from here to avoid build
conflicts and useless duplication.

No other changes to sub-surface protocol consumers are needed, the
identical API is now offered by libwayland-client and libwayland-server.

The commit adding sub-surfaces to Wayland is:
Author: Pekka Paalanen <pekka.paalanen@collabora.co.uk>

    protocol: add sub-surfaces to the core

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2013-11-15 16:23:17 -08:00
Jasper St. Pierre 77a51fd2c8 westoy: Remove some accessors for wl_shell / wl_shell_surface
We want to remove support for these deprecated interfaces. Since
nothing is using them, this is a simple change.
2013-11-13 20:43:56 -08:00
Jasper St. Pierre bf17590f86 westoy: Remove unused support for window parents
It seems that this was only used by the popup menu infrastructure,
which can handle this all on its own. Implementing e.g. transients
in the future can be done with a simple xdg_shell_set_transient_for.
2013-11-13 16:43:03 -08:00
Jasper St. Pierre 01eaaac79a westoy: Remove window_touch_move
It seems to be the same as window_move, except it ignores the passed
in serial (???) and instead just uses the one of the display.
2013-11-13 16:37:36 -08:00
Xiong Zhang 83d8ee779e window, desktop-shell: deal with output unplug on client side
when output is removed, weston-desktop-shell should destroy panel
and background surface on destroyed output.

Signed-off-by: Xiong Zhang <xiong.y.zhang@intel.com>
2013-10-23 22:36:37 -07:00
Kristian Høgsberg 67b8215bcb terminal: Add context menu with new terminal/copy/paste 2013-10-23 16:52:05 -07:00
Jason Ekstrand ee7fefcffc Rename frame_create and frame_set_child_size with a window_ prefix
This is to avoid a collision with an actual frame structure.

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 22:12:16 -07:00
Kristian Høgsberg 0749e3f470 terminal: Accept utf-8 text drop 2013-09-04 20:41:06 -07:00
Rusty Lynch 1084da506e Add touch support for wl_shell_surface_move 2013-08-16 10:56:00 -07:00
Kristian Høgsberg b20b00923a window: Add API to check for subcompositor, use in subsurface example
This way we can fail with a nice error message.
2013-08-15 11:54:03 -07:00
Rusty Lynch 041815aa05 window.c: Add touch handlers
This adds basic infrastructure for handling touch events in the toytoolkit.
2013-08-12 16:50:26 -07:00
Peter Hutterer f3d62276d2 malloc + memset -> zalloc
And for clients using the xmalloc helper, use xzalloc.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-08-08 13:46:13 -07:00
Tomeu Vizoso bee45a14cd window: Allow hinting of a preference for RGB565 when creating a window
And check if the renderer supports the RGB565 format for wl_shm buffers
before creating the cairo surface and requesting the buffer.

It can save quite some memory with big surfaces such as desktop
backgrounds.
2013-08-06 16:49:27 -07:00
Kristian Høgsberg ce27841be5 clients: Introduce xmalloc() and use it a few places
For the sample clients we introduce xmalloc() to simplify OOM-handling.
This patch only converts a few callsites, but this will be our strategy
going forward.
2013-07-25 15:54:20 -07:00
Kristian Høgsberg 1cc5ac34b5 clients: Nested compositor example
A wayland compositor doesn't provide a mechanism for buffer sharing between
clients.  Under X, one client can render to a Pixmap and another can use it
as a source in a subsequent drawing operations.  Wayland doesn't have a
mechanims to share Pixmaps or textures between clients like that, but it's
possible for one client to act as a nested compositor to another client.

This less work than it sounds, since the nested compositor won't have to
provide input devices or even any kind of shell extension.  The nested
compositor and its client can be very tightly coupled and have very specific
expectations of what the other process should provide.

In this example, nested.c is a toytoolkit application that uses cairo-gl
for rendering and forks and execs nested-client.c.  As it execs the client,
it passes it one end of a socketpair that will be the clients connection
to the nested compositor.  The nested compositor doesn't even create a
listening socket.

The client is a minimal GLES2 application, which just renders a spinning
triangle in its frame callback.
2013-06-04 02:47:12 -04:00
Alexander Larsson edddbd14ac Convert all scales to int32_t
The type changed in the protocol, so update weston for this.
2013-05-28 15:27:45 -04:00
Alexander Larsson d68f523f30 window: Add window_get_output_scale()
This lets you find the maximal scale for all the outputs a window
is on, which is useful for picking a buffer_scale.
2013-05-22 16:18:52 -04:00
Alexander Larsson 5e9b652a15 window: allow setting a buffer scale on a window 2013-05-22 16:17:25 -04:00
Alexander Larsson afd319afce window: Track output scales 2013-05-22 16:17:19 -04:00
Pekka Paalanen 7ff7a80007 clients: add subsurfaces demo
Add a demo program with:
- a main surface (green)
- a Cairo-image sub-surface (red)
- a raw GLESv2 widget (triangle)

Sub-surface input region is set empty to avoid problems in toytoolkit.

If Cairo links to libGL, then we will end up with also libGLESv2 linked
to subsurfaces program, and both libs getting really used, which leads
to disaster.

Do not build subsurfaces demo, if Cairo links to libGL and cairo-egl is
usable.

The GL rendering loop is not tied to the toytoolkit or the widget, but
runs directly from its own frame callback. Therefore it runs
independent of the rest of the application. This also relies on one of
two things:
- eglSwapInterval(0) is implemented, and therefore eglSwapBuffers never
  blocks indefinitely, or
- toytoolkit has a workaround, that guarantees that eglSwapBuffers will
  return soon, when we force a repaint on resize.
Otherwise the demo will deadlock.

The code is separated into three sections:

1. The library component, using only EGL, GLESv2, and libwayland-client
   APIs, and not aware of any toolkit details of the parent application.
   This runs independently until the parent application tells otherwise.

2. The glue code: a toytoolkit application widget, who has its own
   rendering machinery.

3. The application written in toytoolkit.

This patch also adds new toytoolkit interfaces:
- widget_get_wl_surface()
- widget_get_last_time()
- widget_input_region_add()

Toytoolkit applications have not had a possibility to change the input
region. The frame widget (decorations) set the input region on its own
when used, otherwise the default input region of everything has been
used. If a window does not have a frame widget, it can now use
widget_input_region_add() to set a custom input region.

These are not window methods, because a widget may lie on a different
wl_surface (sub-surface) than the window.

Changes in v3:
- replace set_commit_mode with set_sync and set_desync

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-05-10 14:35:53 -04:00
Pekka Paalanen 35e82631b6 window: create sub-surfaces
The new application API window_add_subsurface() will create a plain
widget that is on a new sub-surface.

The sub-surface position is taken from the surface's root widget
allocation. This way widget allocations are always in the main surface
(i.e. window) coordinates. However, Cairo drawing coordinates will now
be different to widget coordinates for sub-surfaces. Cairo coordinates
are fixed by applying a translation in widget_cairo_create(), so that
widget drawing code can simply use the widget allocation as before.

Sub-surfaces are hooked up into resize, window flush, redraw, and
find_widget. Window maintains a list of sub-surfaces in top-first order.

Add a client settable default commit mode, and toggle the mode when
resizing to guarantee in-sync updates of a window and its sub-surfaces.

Changes in v3:
- replaced set_commit_mode with set_sync and set_desync

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-05-10 14:35:53 -04:00
Pekka Paalanen 2396aec684 protocol: add sub-surfaces
Add protocol for sub-surfaces, wl_subcompositor as the global interface,
and wl_subsurface as the per-surface interface extension.

This patch is meant to be reverted, once sub-surfaces are moved into
Wayland core.

Changes in v2:

- Rewrite wl_subcompositor.get_subsurface description, and move mapping
  and commit details into wl_subsurface description. Check the wording
  in wl_subsurface.set_position description.

- Add wl_subsurface.set_commit_mode request, and document it, with the
  commit_mode enum. Add bad_value error code for wl_subsurface.

- Moved the protocol into Weston repository so we can land it upstream
  sooner for public exposure. It is to be moved into Wayland core later.

- Add destroy requests to both wl_subcompositor and wl_subsurface, and
  document them. Experience has showed, that interfaces should always
  have a destructor unless there is a good and future-proof reason to not
  have it.

Changes in v3:

- Specify, that wl_subsurface will become inert, if the corresponding
  wl_surface is destroyed, instead of requiring a certain destruction
  order.

- Replaced wl_subsurface.set_commit_mode with wl_subsurface.set_sync and
  wl_subsurface.set_desync. Parent-cached commit mode is now called
  synchronized, and independent mode is desynchronized. Removed
  commit_mode enum, and bad_value error.

- Added support for nested sub-surfaces.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-05-10 14:05:59 -04:00
Kristian Høgsberg 4172f668e7 Pass argc pointer to parse_options()
This lets us keep argc up to date as the backend picks out arguments
from the argv array.
2013-02-20 15:27:49 -05:00
Pekka Paalanen 0c4445ba57 window: create Cairo surfaces on demand for redraw
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>
2013-02-14 12:35:14 -05:00
Pekka Paalanen 02bba7ceb0 window: move buffer type and transform into struct surface
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>
2013-02-14 12:32:49 -05:00
Ander Conselvan de Oliveira 5403f5274d window: Allow clients to choose the fullscreen method 2012-12-14 11:27:34 -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
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
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
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