Commit Graph

520 Commits

Author SHA1 Message Date
Jasper St. Pierre 5befdda84f xdg-shell: Turn the resizing heuristics into an explicit state
Currently, there's a race condition. When resizing from the left, and
a client attaches a buffer after the resize ends, you suddenly see the
buffer jump to the right, because the resize ended while multiple
attaches were in-flight. Making resize a state can fix this, as the
server can now know exactly when the resize ended, and whether a commit
was before or after that place.

We don't implement the correct tracking in this commit; that's left as
an exercise to the reader.

Additionally, clients like terminals might want to display resize popups
to display the number of cells when in a resize. They can use the hint
here to figure out whether they are resizing.
2014-05-12 23:34:05 -07:00
Jasper St. Pierre ab2c108137 xdg-shell: Rework the state system
The states system, so far, has been a complicated mix of weird APIs
that solved a real race condition, but have been particularly ugly
for both compositors and clients to implement.
2014-05-12 23:33:59 -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
Ander Conselvan de Oliveira a57c9f1b90 window: Ignore input events from subsurfaces
Toytoolkit was not designed to handle input from subsurfaces and
instead it expects subsurfaces to have an empty input region. That way
input events for subsurfaces are generated on the main surface and
there is no need to convert coordinates before reporting the event to
the user.

However it is possible that a subsurface has a non-empty input region,
but in that case those events aren't properly processed. The function
window_find_widget() assumes the coordinates are in the main surface
coordinate space, and ends up chosing the wrong widget.

This patch changes the input code to completely ignore input events from
subsurfaces. This option was chosen instead of ensuring that the input
region on those surfaces is always empty since there's no enforcement
that a subsurface should completely overlap with the main surface. If
an event happens in the area of the surface that doesn't overlap, the
event could cause a completely unrelated surface to be picked.

https://bugs.freedesktop.org/show_bug.cgi?id=78207
2014-05-12 12:50:00 -07:00
Jasper St. Pierre bf39e5e1ba window: Add a simple getenv to force SHM rendering 2014-04-30 21:04:34 -07:00
Jasper St. Pierre bd600774be window: Clean up buffer type choosing
Extracting it to a function makes this cleaner and more
understandable.
2014-04-30 21:04:22 -07:00
Kristian Høgsberg 9c60933a13 window.c: Dismiss menu on touch up events 2014-04-29 14:47:19 -07:00
Kristian Høgsberg 1f67117f6f window.c: Also grab touch events when grabbing input 2014-04-29 14:30:44 -07:00
Kristian Høgsberg c31f624141 window.c: Prevent key event delivery while a grab is active
Ideally, we'll update the key event handling to deliver events to widgets,
but in the meantime, just blocking key event delivery while a grab is
active goes a long way.
2014-04-29 14:21:46 -07:00
Kristian Høgsberg 41f7ebc36a window.c: Update pointer focus when taking a grab 2014-04-29 14:12:20 -07:00
Neil Roberts a69dc01a6e clients/window: Don't remove the touch listener on a frame event
It looks like the handler for frame events from the wl_touch interface for
widgets may have been erroneously copied from the cancel handler so that it
removes all handlers as they are processed. I don't think this makes much sense
for the frame event. This was stopping the panel icons from being pushable with
touch events when using libinput since commit 1679f232e5. All that commit
does it make it start sending the frame events.
2014-04-25 15:18:37 -07:00
Kristian Høgsberg cdbbae2cac window.c: Create xdg_surface up front
Fixes initial fullscreen for calibrator.

https://bugs.freedesktop.org/show_bug.cgi?id=76970
2014-04-07 11:28:05 -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 a669bd5e00 toytoolkit: Don't crash if wl_data_device_manager is not present
This is primaraly to get weston-fullscreen to run on compositors that lack
copy-paste support.

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2014-04-02 21:26:20 -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
Jason Ekstrand ce97a6b184 toytoolkit: Only require xdg_shell if the window is not custom
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2014-04-02 21:26:11 -07:00
Hardening 842a36ae4a Check return value of wl_cursor functions
This patch adds checks for themes and cursors returned by wl_cursor functions.

Reviewed-by: Bryce Harrington <b.harrington@samsung.com>
2014-04-01 16:46:41 -07:00
Jasper St. Pierre e81a175fa1 clients: Remove unused client-side resize tracking code 2014-03-24 13:29:50 -07:00
Kristian Høgsberg c7680b09dd xdg-shell: Bump unstable version to 3 2014-02-19 10:14:46 -08:00
Jasper St. Pierre 8c6aa45f97 xdg-shell: Replace the set_* atrocity with a new approach
Rather than require that the client implement two methods for every state,
simply have one global request, change_state, and one global event,
request_change_state.
2014-02-19 09:50:40 -08:00
Jasper St. Pierre b223a72147 xdg-shell: Rename focused_set / focused_unset to activated / deactivated
To try and make the distinction between this event and keyboard focus.
2014-02-18 16:39:01 -08:00
Jasper St. Pierre 5a183329ca clients: Add support for the minimize button 2014-02-18 19:20:18 -05:00
Jasper St. Pierre 63a9c336f3 Reorder the xdg_shell implementations to fit the spec'd order 2014-02-18 19:20:17 -05:00
Jasper St. Pierre 63a1410348 window: Remove window_location enum
It's unused except for one easily-replaceable place.
2014-02-18 14:08:10 -08:00
Emilio Pozuelo Monfort e818d59e88 toytoolkit: avoid unnecessary redraws when focus changes
Clients that need to be redrawn when the focus changes do that by
listening to focus_changed and scheduling a redraw.

This was causing unnecessary redraws in the clients, as could be
easily seen by changing focus on weston-flower.

Signed-off-by: Emilio Pozuelo Monfort <emilio.pozuelo@collabora.co.uk>
2014-02-18 14:05:49 -08:00
Kristian Høgsberg 239902b323 client: Fix shell unstable version check
Use a static assert to catch mismatch between implementation and
interface version.  Fix window.c to not use XDG_SHELL_VERSION_CURRENT,
which will fail to catch version mismatches.  The implementation version
must updated manually when the implementation is updated to use the new
interface.
2014-02-11 16:22:10 -08:00
Kristian Høgsberg 2bff94e057 xdg-shell: Move "ping" and "pong" to xdg_shell, not xdg_surface
Responsivenes is a per-client thing so we move the ping/pong functionality
to xdg_shell.  Having this per-window was carries over from the EWMH
protocol, where the WM has no other way to do this.  In wayland, the
compositor can directly ping the client that owns the surface.
2014-02-11 16:22:10 -08:00
Jasper St. Pierre 7407345446 xdg-shell: Add set_margin request
This is used to figure out the size of "invisible" decorations, which we'll
use to better know the visible extents of the surface, which we can use for
constraining, titlebars, and more.
2014-02-06 13:05:03 -08:00
Jasper St. Pierre 2097fe12d4 xdg-shell: Add a "delete" event
This is equivalent to WM_DELETE_WINDOW request under X11, or equivalent
to pressing the "close" button under CSD. Weston currently doesn't have
a compositor-side way to close the window, so no new code is needed on
its side.
2014-02-06 13:05:03 -08:00
Kristian Høgsberg 44cd1968f2 xdg-shell: Drop edges arg from xdg_surface configure event 2014-02-05 21:37:58 -08:00
Kristian Høgsberg 9a7ad67d65 window: Delay scheduled redraws if we start maximize or fullscreen protocol
When we set the fullscreen flag, we have to wait for the corresponding
configure event and then attach a buffer of that size to indicate
that we've successfully gone fullscreen/maximized.

Without this patch, we can schedule a redraw and go through with it after
setting maximize/fullscreen and end up attaching a buffer of the wrong size.
In practice, what happens is that pressing the maximize button triggers
setting maximized, but also triggers a redraw to paint the maxmize button.
Without this change, repainting the button triggers a repaint that attaches
the same size buffer immediately.

https://bugs.freedesktop.org/show_bug.cgi?id=71927
2014-02-05 17:01:47 -08:00
Kristian Høgsberg d2a0213ee4 window: Ask xkbcommon whether or not to repeat a key 2014-02-05 13:43:59 -08: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 0790e3978a westoy: Port the toy toolkit over to xdg-shell 2014-02-01 01:53:05 -08:00
Jasper St. Pierre c0f17aba5e westoy: Remove MAXIMIZED and FULLSCREEN as separate window types
xdg_shell changes this around so that they are flags on the remote
object itself, not separate surface types. Move to a system where
we calculate the state from the flags ourselves and set the appropriate
wl_shell_surface type.

When we port to xdg_shell, we'll drop these flags and simply sync
on the client.
2014-02-01 01:43:10 -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
Jasper St. Pierre e22952bb13 westoy: Schedule a full resize when we add a subsurface
If a client adds a subsurface, we need to make sure it's allocated
properly, so queue a resize and redraw on the parent window.
2014-02-01 01:42:31 -08:00
Ander Conselvan de Oliveira 23900f70e5 input: Empty the current input region when configuring pointer surfaces
The input region of the cursor surface is set to empty in
pointer_cursor_surface_configure(). Since during the commit process
this function is called before the pending input region is made
current, it empties surface->pending.input instead of surface->input.

But pointer_cursor_surface_configure() is also called from
pointer_set_cursor() in order to map the cursor even if there isn't a
subsequent attach and commit to the cursor surface. In that case,
surface->input is never emptied, since the configure function emptied
only the pending input region and there wasn't a commit that made it
effective.

Fix this by emptying both pending and current input regions. The latter
shouldn't cause problems since the surface can't have a role prior to
being assigned the cursor role, so it shouldn't be mapped in the first
place.

Also change toytoolkit so that it triggers the bug.

https://bugs.freedesktop.org/show_bug.cgi?id=73711
2014-02-01 01:12:24 -08:00
U. Artie Eoff bae79ca741 clients/window: fail if NULL returned from frame_create
Signed-off-by: U. Artie Eoff <ullysses.a.eoff@intel.com>
2014-01-19 22:03:50 -08:00
Kristian Høgsberg 211b517e8c shell: Move maximize and fullscreen bindings to mod + SHIFT
mod + f and mod + m conflict with too many application bindings, in
particular if mod is mapped to ALT.
2014-01-11 13:58:33 -08:00
Kristian Høgsberg b637a40df9 window: Properly destroy tooltip windows when parent window is destroyed
If we destroy a window with an active tooltip, we leave the tooltip
hanging around.  Call tooltip destructor when destroying a window.
This fixes the stuck tooltip observed when unplugging a monitor with
an active tooltip on the panel.

Closes: https://bugs.freedesktop.org/show_bug.cgi?id=72931
2014-01-10 00:27: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
Kristian Høgsberg c152ee11e3 window.c: Don't put buttons on frames for custom windows
Custom windows don't have a wl_shell_surface and can't do anything in
response to these button (except crash).  This only affects the unlock
dialog.

https://bugs.freedesktop.org/show_bug.cgi?id=72542
2013-12-31 15:35:51 -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
Pekka Paalanen fdca95c7db window: handle insufficient buffer space
It is quite possible for os_create_anonymous_file() to fail when trying
to allocate a new wl_shm buffer. Propagate this failure out from
shm_surface_prepare. Most parts of toytoolkit are already avoiding NULL
cairo surfaces.

If cairo surface allocation fails, do not try to call the widget redraw
functions, those are not prepared to deal with NULL. Also do not
schedule a frame callback, this allows us to retry drawing the next
time.

If redraw fails for the main_surface of a window, restore the widget
geometry to what the compositor currently is showing. This keeps the
window visual appearance in sync with application state, so interacting
with the application does not break too badly.

If the very first draw of any window fails, then forcefully exit the
program. E.g. if weston-desktop-shell fails to allocate buffers for the
unlock dialog, w-d-s exits, and weston unlocks the screen automatically.

This patch allows e.g. weston-terminal to stop from enlarging while
resizing, if new sized buffers can no longer the allocated. Even then,
the application stays usable, as it can often repaint in the last
successful size. It does not crash, and the user is able to resize it
smaller, too.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2013-12-02 16:20:58 -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