Commit graph

278 commits

Author SHA1 Message Date
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
Pekka Paalanen 79346ab3a5 shell: wait for desktop-shell init before fade in
On Raspberry Pi, weston-desktop-shell is so slow to start, that the
compositor has time to run the fade-in before the wallpaper is up. The
user launching Weston sees the screen flipping to black, the fbcon
fading in, and then the desktop popping up.

To fix this, wait for the weston-desktop-shell to draw
everything before starting the initial fade-in. A new request is
added to the private desktop-shell protocol to signal it. If a
desktop-shell client does not support the new request, the fade-in
happens already at bind time.

If weston-desktop-shell crashes, or does not send the 'desktop_ready'
request in 15 seconds, the compositor will fade in anyway. This should
avoid a blocked screen in case weston-desktop-shell malfunction.

shell_fade_startup() does not directly start the fade-in but schedules
an idle callback, so that the compositor can process all pending events
before starting the fade clock. Otherwise (on RPi) we risk skipping part
of the animation. Yes, it is a hack, that should have been done in
window.c and weston-desktop-shell instead.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2013-05-22 18:07:30 -04:00
Pekka Paalanen 7bb6510748 compositor: add capability flag for arbitrary surface rotation
The upcoming rpi-renderer cannot handle arbitrary rotations. Introduce
Weston capability bits, and add a bit for arbitrary rotation. GL and
Pixman renderers support it.

Shell or any other module must not produce surface transformations with
rotation, if the capability bit is not set. Do not register the surface
rotation binding in desktop shell, if arbitary rotation is not
supported.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2013-05-22 16:46:43 -04:00
Rob Bradford 2f8d9aacfa shell: End grab if the grabbed shell surface has been destroyed
The shell_grab_start function sets up a destroy notification on the
shell surface such that when the shell surface is destroyed the pointer
on the grab to the shell surface is set to NULL.

We must therefore check whether the shell surface is NULL and end the
grab if it is.

https://bugs.freedesktop.org/show_bug.cgi?id=64689
2013-05-20 16:53:49 -04:00
Hardening eb1e13044f Fix surface_pong when a seat doesn't have a pointer
This patch fixes a crash with the surface_pong when one of the
seats doesn't have a pointer. This was the case with the RDP compositor
that use a fake seat with no mouse or keyboard.
2013-05-17 16:30:39 -04:00
Kristian Høgsberg b9f1c5248b lock-surface: Set geometry width and height before centering
The subsurface patches changed the center_on_output() behavior a bit.
Instead of using the buffer width and height, it now looks at surface
geometry.  In lock_surface_configure() we haven't set up the geometry
when we call center_on_output() so the lock surface would never show
up.
2013-05-14 20:59:07 -04:00
Ossama Othman a50e6e4c50 config-parser: Honor XDG_CONFIG_DIRS
This set of changes adds support for searching for a given config file
in the directories listed in $XDG_CONFIG_DIRS if it wasn't found in
$XDG_CONFIG_HOME or ~/.config.  This allows packages to install custom
config files in /etc/xdg/weston, for example, thus allowing them to
avoid dealing with home directories.

To avoid a TOCTOU race the config file is actually open()ed during the
search.  Its file descriptor is returned and stored in the compositor
for later use when performing subsequent config file parses.

Signed-off-by: Ossama Othman <ossama.othman@intel.com>
2013-05-14 14:36:37 -04:00
Giulio Camuffo b836664c42 shell: account for the subsurfaces when going fullscreen or maximizing
We must calculate the bounding box of the surface + subsurfaces set and use
that when maximizing the window or going fullscreen.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-05-10 14:35:33 -04:00
Giulio Camuffo 61da3fc948 shell: enable moving and resizing of a surface when clicking on a subsurface
[pq: changed to weston_surface_get_main_surface(), and used a temporary
variable to clean up the expressions.]

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-05-10 14:35:25 -04:00
Pekka Paalanen 01388e253e shell: keyboard focus and restacking fixes for sub-surfaces
The shell needs to redirect some actions to the parent surface, when
they originally target a sub-surface. This patch implements the
following:

- Move, resize, and rotate bindings always target the parent surface.

- Opacity (full-surface alpha) binding targets the parent surface. This
  is broken, because it should change the opacity of the whole compound
  window, which is difficult to implement in the renderer.

- click_to_activate_binding() needs to check the shell surface type from
  the main surface, because sub-surface would produce SHELL_SURFACE_NONE
  and prevent activation.

- Also activate() needs to check the type from the main surface, and
  restack the main surface. Keyboard focus is assigned to the original
  (sub-)surface.

- focus_state_surface_destroy() needs to handle sub-surfaces: only the
  main surface will be in a layer list. If the destroyed surface is
  indeed a sub-surface, activate the main surface next. This way a
  client that destroys a focused sub-surface still retains focus in the
  same window.

- The workspace_manager.move_surface request can accept also
  sub-surfaces, and it will move the corresponding main surface.

Changes in v2:
- do not special-case keyboard focus for sub-surfaces
- fix surface type checks for sub-surfaces in shell, fix restacking of
  sub-surfaces in shell, fix focus_state_surface_destroy()

Changes in v3:
- Renamed weston_surface_get_parent() to
  weston_surface_get_main_surface() to be more explicit that this is
  about sub-surfaces
- Fixed move_surface_to_workspace() to handle keyboard focus on a
  sub-surface.
- Used a temporary variable in several places to clarify code, instead
  of reassigning a variable.
- Fixed workspace_manager_move_surface() to deal with sub-surfaces.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-05-10 14:34:54 -04:00
Kristian Høgsberg 6848c25677 input: Move surface picking into the pointer grab focus callback
Currently the core input code does surface picking before calling into
the focus callback of the current grab.  Not all grabs need to pick a
surface however, so we're doing work we don't have to in those cases.

For example, the shell move and resize grabs don't need to pick and the
default grab in implicit grab mode doesn't either.

With this change, the pointer grab mechanism is now very simple:
the focus callback is called whenever the pointer may have a new focus,
the motion callback is called whenever the pointer moves and
the button callback whenever a button is pressed or released.
2013-05-08 22:03:45 -04:00
Kristian Høgsberg be6403ed5c input: Get rid of grab focus concept
This was another complication that we had to have to support the
split between libwayland-server and weston.  Different grabs want to send
events relative to different surfaces at different times.  The default
grab switches between sending coordinates relative to the 'current' surface,
that is the surface the pointer is currently above, or the 'clicked'
surface, in case of an implicit grab.

The grab focus was set by the grab implementation and the core input code
would transform the pointer position to surface relative coordinates for the
grab focus and store in grab->x/y.

Now we can just let the grab implementation transform the pointer
coordinates itself, leaving the implementation free to transform
according to whichever surface it wants.  Or not transform at all if
it doesn't need surface relative coordinates (like the shell move and resize
grabs).
2013-05-08 21:03:23 -04:00
Kristian Høgsberg e122b7ba58 input: Remove 'current' and related fields from weston_pointer
The current surface field was used to track the surface the pointer was
currently over along with pointer position relative to that surface,
regardless of implicit or explicit grabs.  The main purpose was to restore
the default grab when another grab terminated.  We can now just repick in
that case and avoid keeping that state around, with the destroy listener
overhead that involves.

There was one other use case - we used to optimize out calls to
weston_pointer_set_focus() if the focus didn't actually change.  We can
still do that, but we have to do that in the default_grab_focus() handler
and compare against weston_pointer->focus instead.
2013-05-08 16:47:06 -04:00
Kristian Høgsberg fe7aa90ed4 compositor: Adapt to wl_surface going away
struct weston_surface is now the only surface type we have (in core, shell.c
has shell_surface, of course).  A lot of code gets simpler and we never
have to try to guess whether an API takes a wl_surface or a weston_surface.
2013-05-08 09:54:37 -04:00
Kristian Høgsberg 2bf876282f input: Eliminate weston_seat::has_pointer/keyboard/touch
We can just look at weston_seat::pointer/keyboard/touch now.
2013-05-07 23:40:26 -04:00
Kristian Høgsberg 8799d41b1e compositor: Move fan_debug to gl-renderer
With the debug binding infrastructure, we can do this all inside
gl-renderer.c.
2013-05-07 10:50:09 -04:00
Kristian Høgsberg e314875d00 input: Merge wl_seat into weston_seat 2013-05-07 09:07:43 -04:00
Kristian Høgsberg 4912454ba4 input: Remove wl_seat destroy signal
We already have one on weston_seat.
2013-05-06 22:27:40 -04:00
Kristian Høgsberg 02bbabbd56 input: Rename wl_pointer to weston_pointer
This is now a weston object.
2013-05-06 22:15:05 -04:00
Kristian Høgsberg 29139d4a45 fold wl_keyboard into weston_keyboard 2013-05-06 21:40:36 -04:00
Jan Arne Petersen cc75ec11ca text: Rename input_method to wl_input_method
Also rename input_method_context to wl_input_method_context,
input_panel to wl_input_panel and input_panel_surface to
wl_input_panel_surface.

Signed-off-by: Jan Arne Petersen <jpetersen@openismus.com>
2013-05-02 17:18:46 -04:00
Jan Arne Petersen 70d942b4d7 text: Rename ::set_panel to ::set_overlay_panel
Also add documentation to input_panel_surface::set_overlay_panel.

Signed-off-by: Jan Arne Petersen <jpetersen@openismus.com>
2013-05-02 17:12:02 -04:00
Jan Arne Petersen 7cd29e199a text: Add output argument to set_toplevel
Allow to specify an output for a toplevel  input panel surface.

Signed-off-by: Jan Arne Petersen <jpetersen@openismus.com>
2013-05-02 16:41:47 -04:00
Jan Arne Petersen 14da96bf81 text: Add support for panels following the cursor
Add input_panel_surface::set_panel to specify input panel surfaces which
are overlaying the application and are following the input cursor.

Signed-off-by: Jan Arne Petersen <jpetersen@openismus.com>
2013-05-02 16:41:47 -04:00
Philipp Brüschweiler 63e7be60b3 shell: clear popup grab interface on remove_popup_grab and popup_grab_end
Fixes a segfault. Steps to reproduce:

* start weston with the x11 backend
* open a terminal
* click on the icon in the top left corner, choose close
* close the x11 window containing weston
2013-04-15 21:13:34 -04:00
Giulio Camuffo 7fe01b18d8 sdk: be C++ friendly
This renames the weston_surface's private member to configure_private
and externs "C" the headers of the SDK.
2013-03-28 14:03:58 -04:00
Giulio Camuffo 1b4b61ace3 shell: set the popup grab button as pressed only if it actually is
This ensures the popup_grab.initial_up field isn't reset to 0
if the popup was not opened because of a mouse press but because
of moving the mouse with a popup already open. Not doing so will
make the first click outside the client area go ignored.
2013-03-27 13:11:06 -04:00
Giulio Camuffo 5085a75dee shell: handle multiple popups
This patch implements a popup stack. When the first popup is opened
the grab is started, and it is added to a list. Further popups will
be added to this list but the grab won't change. When a popup is
closed it is removed from the list and, if it is now empty, the grab
is ended.
A click outside the client area will send the popup_done event to
all the popups in the list, and the grab will end.
2013-03-25 22:36:58 -04:00
Rafal Mielniczuk fffdcdd654 shell: reset rotation for maximized surface
Surface will preserve its rotation transformation when maximizing, which
will cause inconsistencies (eg. no window shadows drawn)

This patch removes rotation from maximized surface and restore it when
unmaximizing (just like in fullscreen mode)
2013-03-19 12:27:23 -04:00
Rafal Mielniczuk 23c6759b76 shell: block move, rotate, resize in maximized state
To remain consisten with client side window, which blocks moving and
resizing of window in maximized state, we should do so on the compositor
side as well.

(until there is some unmaximize notification from server, which will
allow window to start drawing shadows and revert itself to toplevel
state)
2013-03-19 12:09:52 -04:00
Pekka Paalanen 483243fa67 compositor, shell: surface transform inheritance
Implements surface transform inheritance. A 'parent' pointer is added to
weston_surface::geometry, and is automatically used by
weston_surface_update_transform(). When updating the transform, the
parent transform is updated as needed, too.

shell_map_popup() is converted to use the new
weston_surface_set_transform_parent() function. Now, if we moved the
popup's parent surface while the popup is open, the popup surface will
stick to the parent properly.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-03-18 22:20:04 -04:00
Pekka Paalanen c3ce738653 compositor: introduce weston_surface_geometry_dirty()
Instead of directly setting the dirty flag on weston_surface geometry,
use a function for that.

This allows us to hook into geometry dirtying in a following patch.

Also add comments to weston_surface fields, whose modification causes
transform state to become outdated.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-03-18 22:19:57 -04:00
Scott Moreau 976a050f8f Fix memory leaks
Fix a couple leaks caught by valgrind.
2013-03-18 21:34:13 -04:00
Giulio Camuffo 184df50d3e compositor: call configure on surfaces with a null buffer too
This way the shell can know when a surface has been unmapped by
checking the value returned by weston_surface_is_mapped(surface).
The configure handlers have now width and height parameters, so
they do not need anymore to check manually the buffer size.
If a surface's buffer is NULL the width and height passed to the
configure are both 0.
Configure is now only called after an attach. The variable
weston_surface.pending.newly_attached is set to 1 on attach, and
after the configure call is reset to 0.
2013-02-27 15:32:04 -05:00
Ander Conselvan de Oliveira dda9d78ec9 shell: Go straight to sleep if the sceensaver isn't configured
If the screensaver path is not set, nothing would set the compositor
state to sleeping. In that case, outpus DPMS state was never set to
off.
2013-02-22 08:05:41 -05:00
Ander Conselvan de Oliveira b17537e2c5 shell: Use weston_compositor_sleep() instead of setting DPMS state
This should have been changed when the weston_compositor_sleep() entry
point was added.
2013-02-22 08:05:34 -05:00
Ander Conselvan de Oliveira a4575634f4 compositor: Rename lock and unlock signals to idle and wake
After the changes introduced in the previous patch, those names are
more appropriate. It is up to the shell to decide when to lock the
screen.
2013-02-21 21:12:45 -05:00
Ander Conselvan de Oliveira 87524b65cb compositor: Move state tracking complexity into shell
Previously, when coming back from idle the compositor would try to
track if the unlock signal needed to be sent, and the shell would
change the compositor state in order to track when to display or
hide the screensaver.

This patch finishes moving this out of the compositor. With this, the
compositor state should be changed only using the exported functions
weston_compositor_wake() and weston_compositor_sleep(). The unlock
signal will be sent if the compositor wasn't in the ACTIVE state
previously. The lock signal is sent when the compositor becomes idle.

The calls to weston_compositor_wake() in the shell where there to allow
it to trigger the fade in only after the lock surface was configured.
Now the shell has full control of the fade and does not needed to
change the compositor state to do that, so those calls were replaced
with shell_fade() calls.
2013-02-21 21:12:45 -05:00
Ander Conselvan de Oliveira 859e885985 shell: Use its own timer for the screensaver timeout
Previously, the shell would change the idle_time of the compositor to
the screensaver timeout and wake the compositor again, so that after
the timeout the compositor would fade to black and then the shell would
receive the lock signal again and would set the dpms state of the
outputs to off.

Instead, use a screensaver-specific timer for that, and call lock
without the back and forth between the shell and core Weston.
2013-02-21 21:12:45 -05:00
Ander Conselvan de Oliveira 19d10ef925 compositor: Move fade animation out of core Weston into shell
Previously, it was impossible to override the fade in/out behavior of
Weston using a different shell, since this was implemented in core
Weston. This also led to complicated interaction between the shell and
the core when displaying lock surfaces and screensavers.

This patch starts to solve this issue by moving the fade animation out
of the core. On compositor.c, besides deleting the fade code, the idle
handler had to be changed to emit the lock signal, since it was called
from the fade_frame() function before. This causes a slight change of
behavior, since before the fade would happen with the compositor being
active, while now it is already in the idle state. That leads to the
dpms state being set when cancelling the fade with mouse movement, and
in turn, to a slight freeze with drm compositor. This problem will be
fixed in a follow up patch.

On the shell side, the fade was re-implemented in a slightly different
manner. Instead of using a custom frame function, the fade animation
from animation.c is used. The interface for starting the fade was also
changed to take the value of an enum instead of a float alpha value,
in order to improve readability.
2013-02-21 21:12:44 -05:00
Ander Conselvan de Oliveira ee41605446 animation: Make fade more controllable
Add parameters to weston_fade_run() for setting the initial and target
values for the fade, as well as a parameter to set the spring constant
used for the animation.

Also add the weston_fade_update() function, that allows the animation
to be changed while it is still running.

This will be used to move the fade animation from core Weston into the
shell. These changes are needed to be able to fade out as well as in,
and to be able to reverse the fade in case of user input.
2013-02-21 21:12:44 -05:00
Kristian Høgsberg cb4685bbd1 Pass argc and argv to modules
This lets modules parse options from the command line.
2013-02-20 15:37:49 -05:00
Giulio Camuffo 8aa16174e2 shell: Do not hang when mapping a popup twice
When calling shell_map_popup() more than one time on the same shell_surface
the parent transform was getting added more than one time to the transform
list, resulting in an infinite loop when going through the list with
wl_list_for_each in weston_surface_update_transform_enable().
This commit removes the old transform before adding it again.
2013-02-18 16:56:40 -05:00
Jan Arne Petersen 6138197337 text: Add show/hide_input_panel requests
Allows to show/hide the input panel (virtual keyboard) more independent
of focus (some applications might to require additionaly click on a
focused entry to show the input panel).

Signed-off-by: Jan Arne Petersen <jpetersen@openismus.com>
2013-02-15 17:07:35 -05:00