Commit graph

321 commits

Author SHA1 Message Date
Jonas Ådahl 1ea343e1be Add cancel function to grab interfaces
A grab can potentially allocate memory and would normally end the grab
itself, freeing the allocated memory in the process. However at in some
situations the compositor may want to abort a grab. The grab owner still
needs to free some memory and abort the grab properly. To do this a new
function 'cancel' is introduced in all the grab interfaces instructing
the grabs owner to abort the grab.

This patch also hooks up grab cancelling to seat device releasing and
when the compositor looses focus, which would potentially leak memory
before.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2013-10-28 14:44:06 -07:00
Jonas Ådahl 1c6e63e880 shell: Don't leak weston_touch_move_grab structs
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2013-10-28 14:39:18 -07:00
Kristian Høgsberg c85f1d4595 shell.c: Prevent moving a window from more than one source
It was possible to start a move or resize with a pointer and then
start another move for the same surface with touch or a pointer from
another seat, which would make the window flicker around.  With this
commit, we now reject any attempts to move or resize a surface that is
currently grabbed.
2013-10-24 16:52:00 -07:00
Kristian Høgsberg 0d94f41b44 shell.c: Don't overwrite focus surface argument in activate_binding()
We need either the pointer or touch focus, which is passed in to
activate_binding().  Don't overwrite this with the pointer focus.
2013-10-24 16:29:51 -07:00
Kristian Høgsberg 7ab139ce16 shell: Don't cast weston_view to surface when we just need view->surface
Most of the shell.c bindings take effect on the current pointer or
touch focus.  That's now a view, but we need a surface in these cases.
Just get the surface from view->surface instead of trying to cast a
view to a surface.
2013-10-24 16:21:39 -07:00
Kristian Høgsberg 48588f8696 shell: Create a view for the grab_surface
Without the view, we can't set pointer and touch focus to the grab_surface
and touch moving fails.
2013-10-24 15:51:35 -07:00
Kristian Høgsberg a3a0e1867e shell: Add the right output object to the shell output_list
Error on my part while renaming the shell_output variable.
2013-10-23 23:36:04 -07:00
Xiong Zhang 6b48142f8a shell: register output->destroy_signal handler
setup_output_destroy_handler() deal with output created at
drm backend initialize time.
handle_output_create() deal with output created by hot plug handler
output_destroy_handler is removed when output was unplugged or
shell is destroyed.

Signed-off-by: Xiong Zhang <xiong.y.zhang@intel.com>
2013-10-23 23:17:15 -07:00
Jason Ekstrand a7af70436b Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:

 * The weston_surface structure storres everything required for a
   client-side or server-side surface.  This includes buffers; callbacks;
   backend private data; input, damage, and opaque regions; and a few other
   bookkeeping bits.

 * The weston_view structure represents an entity in the scenegraph and
   storres all of the geometry information.  This includes clip region,
   alpha, position, and the transformation list as well as all of the
   temporary information derived from the geometry state.  Because a view,
   and not a surface, is a scenegraph element, the view is what is placed
   in layers and planes.

There are a few things worth noting about the surface/view split:

 1. This is *not* a modification to the protocol.  It is, instead, a
    modification to Weston's internal scenegraph to allow a single surface
    to exist in multiple places at a time.  Clients are completely unaware
    of how many views to a particular surface exist.

 2. A view is considered a direct child of a surface and is destroyed when
    the surface is destroyed.  Because of this, the view.surface pointer is
    always valid and non-null.

 3. The compositor's surface_list is replaced with a view_list.  Due to
    subsurfaces, building the view list is a little more complicated than
    it used to be and involves building a tree of views on the fly whenever
    subsurfaces are used.  However, this means that backends can remain
    completely subsurface-agnostic.

 4. Surfaces and views both keep track of which outputs they are on.

 5. The weston_surface structure now has width and height fields.  These
    are populated when a new buffer is attached before surface.configure
    is called.  This is because there are many surface-based operations
    that really require the width and height and digging through the views
    didn't work well.

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-22 13:34:11 -07:00
Kristian Høgsberg 724c8d9e7c shell: Add a new weston.ini to control the startup animation
The new key startup-animation in the [shell] section lets you
control the startup animation.  Default is fade, but with this patch
we can also do none, which just show the desktop as fast as possible.
2013-10-16 11:38:24 -07:00
Neil Roberts e14aa4f0a9 Don't remove the touch grab until the last touch point is removed
Previously if you move a window around and temporarily add a second
finger then it will cancel the grab even though the original finger is
still held on the screen. It seems more robust to avoid cancelling the
grab until all fingers have been removed.
2013-10-14 13:53:16 -07:00
Neil Roberts aba0f25cb0 Add a touch move binding
When holding the compositor super key the touch events can now be used
to move a window.
2013-10-14 13:53:08 -07:00
Neil Roberts a28c69358c Add a touch binding to activate a surface
Adds a new binding type for touch events via the new function
weston_compositor_add_touch_binding. The binding can only be added for
a touch down with the first finger. The shell now uses this to install
a binding to activate the current surface.
2013-10-14 13:53:08 -07:00
Neil Roberts 96d790e74b input: Emit events on all resources for a client
The Wayland protocol permits a client to request the pointer, keyboard
and touch multiple times from the seat global. This is very useful in a
component like Clutter-GTK where we are combining two libraries that use
Wayland together.

This change migrates the weston input handling code to emit the
events for all the resources for the client by using the newly added
wl_resource_for_each macro to iterate over the resources that are
associated with the focused surface's client.

We maintain a list of focused resources on the pointer and keyboard
which is updated when the focus changes. However since we can have
resources created after the focus has already been set we must add the
resources to the right list and also update any state.

Additionally when setting the pointer focus it will now send the
keyboard modifiers regardless of whether the focused client has a
pointer resource. This is important because otherwise if the client
gets the pointer later than you getting the keyboard then the
modifiers might not be up-to-date.

Co-author: Neil Roberts <neil@linux.intel.com>
2013-09-21 20:56:55 -07:00
Hardening 57388e44e5 Notify clients on mode_switch()
This patch implements the notification of clients during mode_switch.
As discussed on IRC, clients are notified of mode_switch only when the
"native" mode is changed and activated. That means that if the native
mode is changed and the compositor had activated a temporary mode for
a fullscreen surface, the clients will be notified only when the native
mode is restored.
The scaling factor is treated the same way as modes.
2013-09-21 11:40:21 -07:00
Giulio Camuffo 62942ad3a6 xwm: set the shell_surface's title
add a new function pointer to the weston_shell_interface struct that
shells will set accordingly.
2013-09-11 13:50:54 -07:00
Kristian Høgsberg 2e3c396ae3 shell: Use wl_resource_for_each() for sending out workspace status 2013-09-11 12:00:47 -07:00
Kristian Høgsberg e1b655df92 shell: Make sure we have seat->pointer and seat->touch before dereferencing
Either of these may not be available when we handle wl_shell_surface.move,
and we need to not crash when that's the case.

https://bugs.freedesktop.org/show_bug.cgi?id=68649
2013-08-28 23:17:09 -07:00
Rusty Lynch 1084da506e Add touch support for wl_shell_surface_move 2013-08-16 10:56:00 -07:00
Rob Bradford 880ebc7ed9 input: For serial generation get the display from the compositor
This removes the use of wl_client_get_display() where the client is
derived from the focussed resource. This starts the removal of the
assumption of a single resource on a client that would be notified about
events on the focussed surface.
2013-08-12 16:54:10 -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
Kristian Høgsberg 3c17933de8 Use #define WL_HIDE_DEPRECATED to avoid deprecated warnings for wl_buffer 2013-08-06 19:27:04 -07:00
Kristian Høgsberg 9e5d7d17a7 shell: Remove redundant weston_pointer field from shell_grab
This is already in weston_grab.
2013-07-25 09:50:34 -07:00
Rob Bradford bdeb5d224d shell: Respect output transformation for input panel surface
Rather than using the dimensions in the mode we can use the recently
added output width and height members which are updated to reflect any
output rotation.

https://bugs.freedesktop.org/show_bug.cgi?id=66798
2013-07-12 23:56:18 -04:00
Kristian Høgsberg 919cddb0ab Convert to wl_global_create/destroy() 2013-07-09 02:02:11 -04:00
Kristian Høgsberg 6780073d78 shell: Always go through end_busy_cursor when ending the busy cursor grab 2013-07-04 01:12:17 -04:00
Kristian Høgsberg c9974a0796 shell: Dont set grab cursor if desktop-shell client died
If we don't have a desktop-shell helper client, don't try to send events
to it.

https://bugs.freedesktop.org/show_bug.cgi?id=65961
2013-07-03 19:26:04 -04:00
Rob Bradford dfe310512b shell: Allow ending of popup grabs from within the starting of the grab
Calling weston_pointer_start_grab can lead to a code path (in this case
when the shell surface is unresponsive) that can try and remove the
popup grab to setup a shell grab.

Ending the popup grab requires removing the surface from the grab's
surfaces list - however the grab had not yet been fully setup so the
grabbed surface was not yet in this list.

With this change we ensure we add the surface to the list before setting
up the pointer grab.

https://bugs.freedesktop.org/show_bug.cgi?id=66167
2013-07-03 19:06:25 -04:00
Louis-Francis Ratté-Boulianne 9a4f10f6bc shell: Fix calculation of center point in surface rotation
Make sure the center point of a rotation is not rounded to an
integer. It makes the calculation consistent with others in the
shell. It also ensures surfaces rotated 180 degrees are at the
exact same place.
2013-07-03 17:09:03 -04:00
Jason Ekstrand a85118c1b8 Use wl_resource_create() for creating resources
This commit sets the version numbers for all added/created objects.  The
wl_compositor.create_surface implementation was altered to create a surface
with the same version as the underlying wl_compositor.  Since no other
"child interfaces" have version greater than 1, they were all hard-coded to
version 1.

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-07-03 14:52:06 -04:00
Kristian Høgsberg f00460771e compositor: Fix remaining double free()s
Previous commit didn't catch all double free()s, hopefully this one does.
2013-06-25 11:19:31 -04:00
Quentin Glidic 8418c298af shell: Free temporary strings
Signed-off-by: Quentin Glidic <sardemff7+git@sardemff7.net>
2013-06-20 15:22:35 -04:00
Kristian Høgsberg 1cfd406f9d shell: Tweak spring animation for zoom animation type 2013-06-17 11:08:11 -04:00
Kristian Høgsberg 8eb0f4f830 shell: Fix warning and indentation in shell_surface_configure() 2013-06-17 10:33:22 -04:00
Kristian Høgsberg 5281fb1500 spring: Tweak the window fade-in spring to not overshoot
The fade animation overshoots and rings for a bit dipping back into
slightly transparent.  Bug 61675 was right.

https://bugs.freedesktop.org/show_bug.cgi?id=61675
2013-06-17 10:32:09 -04:00
Jason Ekstrand a0d2dde6cd output: Use wl_resource_get accessors for weston_output resources
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-06-14 16:51:20 -04:00
Jason Ekstrand 44a3863a17 input: Use wl_resource_get accessor functions for resources
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-06-14 16:49:11 -04:00
Jason Ekstrand 51e5b14952 input_panel_surface: Change resource to a wl_resource pointer
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-06-14 16:49:11 -04:00
Jason Ekstrand 651f00e94a shell: Convert resources to pointers
This commit converts shell_surface.resource to a pointers and updates
shell.c to use wl_resource_get accessors for shell_surface, desktop_shell,
screensaver, and workspace_manager related resources.

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-06-14 16:49:10 -04:00
Jason Ekstrand 0f2ef7ebd3 Use wl_resource_get_user_data for weston_surface resources
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-06-14 15:58:29 -04:00
Tiago Vignatti fb2adba3da xwayland: Forward global position to X
xeyes works as expected now. subwindows are popped also as expected. This
patch should fix the following:

https://bugs.freedesktop.org/show_bug.cgi?id=59983

Signed-off-by: Tiago Vignatti <tiago.vignatti@intel.com>
2013-06-14 15:29:02 -04:00
Jason Ekstrand 26ed73cee8 Change weston_surface.resource to a wl_resource pointer.
This is the first in what will be a series of weston patches to convert
instances of wl_resource to pointers so we can make wl_resource opaque.
This patch handles weston_surface and should be the most invasive of the
entire series.  I am sending this one out ahead of the rest for review.

Specifically, my machine is not set up to build XWayland so I have no
ability to test it fully.  Could someone please test with XWayland and let
me know if this causes problems?

Because a surface may be created from XWayland, the resource may not always
exist.  Therefore, a destroy signal was added to weston_surface and
everything used to listen to surface->resource.destroy_signal now listens
to surface->destroy_signal.
2013-06-12 15:04:49 -04:00
Daniel Stone c228e23b05 configure.ac: Enable AC_USE_SYSTEM_EXTENSIONS
AC_USE_SYSTEM_EXTENSIONS enables _XOPEN_SOURCE, _GNU_SOURCE and similar
macros to expose the largest extent of functionality supported by the
underlying system.  This is required since these macros are often
limiting rather than merely additive, e.g. _XOPEN_SOURCE will actually
on some systems hide declarations which are not part of the X/Open spec.

Since this goes into config.h rather than the command line, ensure all
source is consistently including config.h before anything else,
including system libraries.  This doesn't need to be guarded by a
HAVE_CONFIG_H ifdef, which was only ever a hangover from the X.Org
modular transition.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>

[pq: rebased and converted more files]
2013-06-05 01:16:34 -04:00
Alexander Larsson 690f718834 shell: Position DRIVER fullscreen surfaces at origin
When a window is fullscreened with DRIVER method and we succeeded
in changing mode we need to actually move the surface to the
origin of the output, or it won't be used for scanout.
2013-05-29 10:18:15 -04:00
Alexander Larsson d622ed3fbf shell: Center window in fullscreen if needed
If modeset fails With DRIVER method, and always with FILL method
we want to center the window.
2013-05-28 17:22:04 -04:00
Alexander Larsson f82b6cac5e shell: Always go to original mode when focused window not fullscreen
Right now we only switch mode on activating a fullscreened window.
This has several problems:

* Once you're in fullscreen its hard to switch to a non-fullscreened
  window with alt-tab as you stay in the small resolution.
* If you switch from a fullscreened window to a non-fullscreened
  window and the fullscreened window is destroyed we will not
  restore the original mode (since the window is not
  shell_surface_is_top_fullscreen()
* Its hard to reach a different output on the right with the mouse
  when the mode is smaller that the original, as there is a "gap"
  between the two outputs. So, if you alt-tab to another window
  you can not always reach it.

This is somewhat of a sledge hammer, as it means you can't e.g.
focus a non-fullscreen on one output and have a window fullscreened
on another output. However, trying to restore only the outputs
the new window is on is problematic:

* It may later change output
* We want to see all windows anyway during alt-tab
* Can't reach the other windows with the mouse anyway

So, this seems like an ok solution.
2013-05-28 17:22:01 -04:00
Alexander Larsson 355748e3b5 shell: Use buffer_scale as output scale on fullscreen DRIVER
It may happen that you e.g. fullscreen a 800x600 surface with
buffer_scale 1 (e.g. a 800x600 buffer) on an output that is
otherwise scale 2. In this case we want to temporarily set
the output scale to 1, as we're really scanning out of a
scale 1 buffer. This causes us to e.g. report the input
positions in the right place, etc.

When we restore the original mode we also restore the original
scale.

Note that the scale change is a purely compositor internal change,
to clients it still looks like the output is scale 2.
2013-05-28 17:18:56 -04:00
Kristian Høgsberg 14e438c8a2 compositor: Parse config file in main(), only keep weston config object
Now that all backends and modules have been converted to the new
config parser API, we don't have to keep the fd around.
2013-05-26 21:48:14 -04:00
Kristian Høgsberg fc10cc0c65 shell: Remove input panel debug fprintf 2013-05-23 21:47:37 -04:00
Kristian Høgsberg 673a889fd8 shell: Use new config parser 2013-05-23 21:42:04 -04:00