Commit Graph

619 Commits

Author SHA1 Message Date
Pekka Paalanen b362736bb2 window: simplify window_create_surface
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-11-27 15:50:26 -05:00
Pekka Paalanen 9943686be3 window: convert shm path to toysurface
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>
2012-11-27 15:49:37 -05:00
Pekka Paalanen 03fc316000 window: add toysurface abstraction and port EGL path
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>
2012-11-27 15:49:34 -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
Jan Arne Petersen c31288daf1 window: Allow to get xkb context from display
Add display_get_xkb_context to get the xkb context from the display.

Signed-off-by: Jan Arne Petersen <jpetersen@openismus.com>
2012-11-27 13:19:38 -05:00
Jan Arne Petersen cd99706b61 text: Send more information with keysym events
Send state and modifier from the demo keyboard with the keysym event and
take them into account in the editor example.

Add some helper functions to write and read a modifiers_map array.

Signed-off-by: Jan Arne Petersen <jpetersen@openismus.com>
2012-11-27 13:06:21 -05:00
Pekka Paalanen 768117f90b window: make display_create_surface() shm-only
Nothing uses it to create EGL-surfaces outside of window.c. This makes
refactoring the EGL-based code easier, since we do not need to support
EGL-based Cairo surfaces without an associated struct window.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-11-19 16:00:01 -05:00
Pekka Paalanen 32127ca86d window: use different keys for different cairo privates
cairo_surface_t objects have a private set, either struct
shm_surface_data, or struct egl_window_surface_data. Use separate
private keys for each type to avoid mismatch.

This makes display_get_buffer_for_surface() safe, in that it won't
return garbage for an EGL-based cairo surface.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-11-19 15:55:28 -05:00
Pekka Paalanen 0c6a34378a window: merge struct surface_data into shm_surface_data
Struct surface_data was not really useful, and it definitely was not
used with EGL-based windows.

This also fixes a semantic mistake, where struct shm_surface_data was
put into cairo_surface_t private, but got out as struct surface_data
instead. Due to struct layout, however, this did not cause a real bug.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-11-19 15:55:26 -05:00
Pekka Paalanen f86504c881 window: remove unused MULT macro
Leftovers from

commit f02a649a3c
Author: Kristian Høgsberg <krh@bitplanet.net>
Date:   Mon Mar 12 01:05:25 2012 -0400

    Consolidate image loading code and move to shared/

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-11-19 15:55:24 -05:00
Pekka Paalanen a8d4c84693 window: make window_flush() private
Not called from any client.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-11-19 15:55:17 -05:00
Pekka Paalanen ce36f6dff4 window: make window_{create,set}_surface private
I do not think these are meant to be called by the applications
directly. Applications certainly do not have to call them.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-11-19 15:55:12 -05:00
Daniel Stone 8097274ce6 Clients: Don't set the cursor when we have no pointer
Avoids a segfault whenever we get a key event, and try to set the
cursor, dereferencing a NULL input->pointer.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-11-08 11:31:37 -05:00
Kristian Høgsberg 0f7a285fe1 window.c: Move misplaced break to where it belongs
The break statement wasn't copy and pasted along with the rest of the code
causing menu item before it ("Move to workspace below") to fall through to
the fullscreen case.
2012-11-05 20:24:32 -05:00
Kristian Høgsberg e77d7577a2 window: Fix use-after-free in menu button handler
Commit d2fbb3870c introduced a use-after-free
error in the case where we destroy the menu.
2012-10-30 18:10:32 -04:00
Kristian Høgsberg efb948846f window: Only advertise fullscreen menu item if client supports it
If the client doesn't set a fullscreen handler, we can't go fullscreen
and shouldn't advertise that in the window menu.  The menu implementation is
a little simplistic, so we just move the "Fullscreen" entry to the end of
the list and don't count it if we don't want it in the menu.

https://bugs.freedesktop.org/show_bug.cgi?id=47751
https://bugs.freedesktop.org/show_bug.cgi?id=48106
2012-10-30 18:07:02 -04:00
Scott Moreau 1bdb477522 toytoolkit: Don't destroy window cairo surface on shm attach.
https://bugs.freedesktop.org/show_bug.cgi?id=52454
2012-10-30 14:18:49 -04:00
Kristian Høgsberg d2fbb3870c window: Make press-drag-release menu selection mode work
The intended behavior is that a quick click (press and then release
within 500ms) just pops up the menu and doesn't select anything.  Then
we can mouse around and and click to select an item.  Alternatively, a
click and hold (ie press and release after 500ms) lets you press right
button, mouse down on the menu item you want and release to select it.
This is how menus work in most toolkits.

The handling in weston is fine, it's there to handle the case where
the button release happens outside any client window, since the client
doesn't get those events.  If such a release happens late or we get a
second release outside the popup window we shut down the popup.

The problem is in toytoolkit, where we need to select the item if we
get a release within 500ms or if we get a second release.  A second
release is the case where the first release came after 500ms and
didn't pop down the menu, and the second release event is from a click
on a menu item.

https://bugs.freedesktop.org/show_bug.cgi?id=52456
2012-10-30 13:45:31 -04:00
Kristian Høgsberg e530a0a240 window: Ignore input_set_pointer_image() if we don't have a pointer
https://bugs.freedesktop.org/show_bug.cgi?id=55782
2012-10-29 16:42:26 -04:00
Jonas Ådahl f461eee2b0 window: Always pass focused widget to widget motion handlers
Grabbed widgets should always receive motion events as if it was the
widget that would receive it if no grab was active. This means that the
focused widget should always be passed as the widget argument to widget
motion handlers.

This reverts commit 8c9c8fcf6e.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2012-10-19 16:56:08 -04:00
Jonas Ådahl f82eda5247 window: Don't set pointer image when requesting to move a surface
Since it's the server who moves the surface it's the server who sets the
pointer image.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2012-10-19 16:54:42 -04:00
Kristian Høgsberg 3146756adf clients: Don't ask for EGL_PIXMAP_BIT when choosing configs 2012-10-16 15:31:31 -04:00
Kristian Høgsberg a17f7a13fd clients: Check return value of wl_display_dispatch()
The simple clients all just call wl_display_dispatch() in a while loop
without checking the return value.  Now, if the server dies or other
error occurs, we get a -1 return value instead and need to break the loop.
2012-10-16 13:17:16 -04:00
Pekka Paalanen fb39d8d23c toytoolkit: make all EGL code dependant on cairo-egl
configure.ac: The toytoolkit clients used to get libEGL linked to them
even if there was no cairo-egl. This is useless, and actually harmful on
platforms, where libEGL absolutely requires one of the GL ES libraries
to be linked in, too.

Look for EGL-related packages only for cairo-egl with toytoolkit.

window.c: protect all GL header includes with HAVE_CAIRO_EGL, since that
is the only case we can support EGL, GL, or GLESv2 at all. In the case
we do not have cairo-egl, add enough definitions to let us build the
stubs for EGL-related functions.

Remove some #ifdefs that were inside of the same #ifdef already.

These changes allow to build sorfware rendering toytoolkit clients
without any bits of EGL libs or headers.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-10-16 10:47:22 -04:00
Pekka Paalanen 53e58485a5 window: remove dead EGL code
- remove unimplemented function from header
- remove the egl function pointers that were not used

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-10-16 10:46:15 -04:00
Kristian Høgsberg 3fb613effe window: Set input region also when we go fullscreen
We used to rely on the compositor resetting this as a side effect of
changing size, but it doesn't work like that any more.
2012-10-15 20:54:43 -04:00
Jonas Ådahl d9f6b078b6 window: Update modifier state directly after receiving a modifier event
If the keyboard modifier event was received after the key event the
modifier state would end up incorrect.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2012-10-15 20:54:43 -04:00
Pekka Paalanen b2f957a9f1 window: don't call output configure uninitialised
Callbacks registered via display_set_output_configure_handler() are
promised to be called when we know the current mode for the output. If
the following order of events happens:
1. toytoolkit binds to a wl_output global
2. application registers an output configure handler
3. the wl_output.mode events are received

Then in step 2 we would call the callback with uninitialised output
informations, giving it a 0x0 size.

To avoid such race, do not call the callback from
display_set_output_configure_handler() if the output has 0x0 size.

The wl_output.mode event will be received later, and that will trigger
the right call to the callback.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-10-15 20:54:43 -04:00
Kristian Høgsberg feb3c1d33b clients: Use wl_display_dispatch_pending() 2012-10-15 20:54:43 -04:00
Pekka Paalanen bc10638cd9 compositor, clients: apply wl_surface.frame on commit
Apply wl_surface.frame request only on the next wl_surface.commit
according to the new protocol.

This makes it explicit, which repaint actually triggered the frame
callback, since commit schedules a repaint. Otherwise, something causing
a repaint before a commit could trigger the frame callback too early.

Ensure all demo clients send commit after wl_surface.frame. Note, that
GL apps rely on eglSwapBuffers() sending commit. In toytoolkit, it is
assumed that window_flush() always does a commit.

compositor-wayland assumes renderer->repaint_output does a commit.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-10-10 21:39:11 -04:00
Pekka Paalanen 0cbd3b5059 compositor, clients: double-buffer input region
Make input region double-buffered as specified in the new protocol.

While doing it, get rid of the undef region code, and instead use a
maximum sized real pixman region. This avoids special-casing regions
that might sometimes be undef.

As the input region is now usable by default instead of undef,
weston_surface_update_transform() does not need to reset the input
region anymore.

weston_surface_attach() no longer resets the input region on surface
size change. Therefore, also weston_seat_update_drag_surface() does not
need to reset it.

Update toytoolkit to set input region before calling wl_surface_commit()
or swapBuffers (which does commit).

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-10-10 21:38:44 -04:00
Pekka Paalanen 512dde8ce9 compositor, clients: double-buffer opaque region
Make wl_surface.set_opaque_region double-buffered as required by the new
protocol. Also, do not reset the opaque region on surface size changes
anymore. Only explicit requests from the client will change the region
now.

In clients, make sure commit happens after setting the opaque region.

Mesa does not need a fix, as it never touches the opaque region.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-10-10 21:38:40 -04:00
Pekka Paalanen c9e00c06e9 clients: use wl_surface_commit
Use wl_surface_commit() to commit the buffer attach, as Weston now
requires.

NOTE: GL-applications are broken until you upgrade to a version of Mesa
which does wl_surface_commit() on eglSwapBuffers(). If you have
Cairo-gl, this means all toytoolkit apps, too.

simple-shm and simple-touch OTOH will work now.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-10-10 21:38:17 -04:00
Kristian Høgsberg fa80e11c84 Update to new fd and wl_registry APIs
This commit updates the clients and the wayland compositor backend to
use the new wl_registry mechanism and the thread safe fd API.
2012-10-10 21:34:38 -04:00
Scott Moreau 4e07236e87 toytoolkit: Take into account transform when sending output allocation. 2012-10-10 13:02:11 -04:00
Kristian Høgsberg 1671e1129d window: Add getters for fullscreen and maximized state
This lets us eliminate a bit of redundancy in the clienst where they track
fullscreen state themselves.
2012-10-10 11:36:24 -04:00
Scott Moreau c6a7e4b277 toytoolkit: Don't draw shadows for maximized windows.
Add THEME_FRAME_MAXIMIZED flag so the theming system can know not to draw
shadows for maximized windows. This allows maximized surfaces' content to be
sized and placed in a more expectable fashion.
2012-10-10 11:23:41 -04:00
Jonas Ådahl f77beeb981 window: Initialize workspace state before first roundtrip
The workspace state parameters were initialized after the first
roundtrip. If a workspace manager state event was received during this
roundtrip the state parameters were cleared leaving an incorrect state.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2012-10-09 22:47:24 -04:00
U. Artie Eoff 44874d9f02 desktop-shell: destroy data before exiting.
desktop-shell never returned from display_run() since it
was essentially killed when weston exited.  To fix this,
it is necessary to watch for EPOLLHUP in window.c so that
toytoolkit clients will return from display_run() when
weston quits.  This allows for clients to clean up
as needed.

Signed-off-by: U. Artie Eoff <ullysses.a.eoff@intel.com>
2012-10-04 11:37:40 -04:00
Tiago Vignatti 6f09338b0f toytoolkit: Process deferred tasks on fifo order instead
Signed-off-by: Tiago Vignatti <tiago.vignatti@intel.com>
2012-09-27 21:23:34 -04:00
Pekka Vuorela 4e363d21bb Require mouse release on top of frame button to trigger action
As common UI convention, allows action to be avoided by dragging
outside the button after mouse press.
2012-09-26 11:22:30 -04:00
Pekka Vuorela 6e1e385d51 Protect window callbacks from deleted windows
Calling window_destroy() was able to cause segfault for
callbacks triggering afterwards.
2012-09-26 10:20:32 -04:00
Philipp Brüschweiler 8c9c8fcf6e toytoolkit: supply correct widget in motion_handler callback 2012-09-04 15:56:37 -04:00
Philipp Brüschweiler 067abf67cd workspaces: don't segfault on invalid move_surface_to_workspace request
Also fixes the off-by-one in toytoolkit that exposed the issue.
2012-09-04 15:56:24 -04:00
Jonas Ådahl 14c92ff072 toytoolkit: Implement support for the workspace manager interface
Two buttons are added to the right-click menu of the window frame for
moving a surface either up or down.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2012-08-31 19:51:53 -04:00
Philipp Brüschweiler bd3f219344 toytoolkit: try multiple names when loading cursors
The correspondence between cursor functions and names of cursors has
never been standardized. As a consequence, each cursor function can be
represented as a cursor with one of several names. Be more robust when
loading cursor by trying all known names that correspond to a cursor.

This should fix https://bugs.freedesktop.org/show_bug.cgi?id=50487
and https://bugs.freedesktop.org/show_bug.cgi?id=52609 a bit more
thoroughly.
2012-08-29 15:06:09 -04:00
Philipp Brüschweiler 5418a904ca toytoolkit: don't ignore resizes with negative width or height
E.g. this can happen when you grab the lower right corner of a window
and move over the top of the window when resizing. In this case, the
changed width is still important and should be acted upon.

https://bugs.freedesktop.org/show_bug.cgi?id=53560
2012-08-16 10:33:56 -04:00
Philipp Brüschweiler 7e0cc54fca toytoolkit: add axis handler 2012-08-14 15:51:13 -04:00
Philipp Brüschweiler b8a8aff357 toytoolkit: remove unused actions from titlebar menu
They were introduced in b3cca0a411
but never actually implemented. Removing them should at least stop
users from wondering if weston is broken.

https://bugs.freedesktop.org/show_bug.cgi?id=52455
2012-08-14 10:17:07 -04:00
Kristian Høgsberg 86adef9d54 window.c: Handle multiple keyboard foci
Keep a count of number of wl_keyboard focus we have instead of
tracking the more recent wl_keyboard.
2012-08-13 22:28:10 -04:00
Christopher Michael ac3e5f2feb Add support in Weston for X cursor themes.
This patch, along with the wayland patch, adds the ability to specify
a cursor theme in the weston.ini file:

[cursors]
theme=THEME_NAME

If specified, than Weston can use a specific X cursor theme for the
pointer. This relies on the 0001-Add-support-for-X-cursor-themes.patch
for wayland.

[krh: edited to use shell section and key name cursor-theme]
2012-08-13 11:12:17 -04:00
Kristian Høgsberg b29798bcab window.c: Rearrange input handlers so they appear in the right order
They were all over the place before, now they appear in protocol order.
2012-08-13 10:01:46 -04:00
Kristian Høgsberg ae27737b28 window.c: Use pointer enter serial for setting cursor 2012-08-01 09:58:22 -04:00
Pekka Paalanen e288a0f415 window: warn on cursor load failure 2012-07-31 22:27:23 -04:00
Kristian Høgsberg 023be102d7 window.c: Set input region after (potentially) adjusting the surface size
Regressed in dd263e546b, spotted by Scott Moreau <oreaus@gmail.com>
2012-07-31 11:59:12 -04:00
Kristian Høgsberg 4fc1535c0a window: Handle Alt-F4 to close windows 2012-07-25 16:35:28 -04:00
Andre Heider 82b4c1bc6b window.c: Remove xkb leftovers 2012-07-25 16:24:49 -04:00
Kristian Høgsberg 67ace20f8e window.c: Add fullscreen handler to keep fullscreen state consistent 2012-07-23 21:56:31 -04:00
Kristian Høgsberg 0e696478a9 Handle new transform argument in wl_output.geometry event 2012-07-22 15:49:57 -04:00
Kristian Høgsberg d3a1965a3d clients: Implement minimum size for toy toolkit clients
We default to setting the minimum size to the initial size.  To set a
different minimum size than the initial size, set the minimum size first
then then initial size.  Good enough for a toy toolkit.

https://bugs.freedesktop.org/show_bug.cgi?id=50263
2012-07-20 11:33:02 -04:00
Ander Conselvan de Oliveira ddca49600f window: Workaround a stuck frame callback on the cursor surface
It is possible that a client loses the focus between receiving a
pointer.enter event and sending a pointer.set_cursor request. In that
case, the cursor surface might not be mapped and the frame callback
requested on it will never trigger.

Work around this by trying to remap the cursor surface whenever there
is a frame callback and the serial for the enter event is higher than
the cursor serial.
2012-07-16 13:35:25 -04:00
Scott Moreau fe89f07e33 toytoolkit: Remove obsolete function window_set_custom(). 2012-07-12 09:18:49 -04:00
Philipp Brüschweiler c547477e27 Remove dead code
window->title is always NULL inside window_create_internal
2012-07-11 15:46:37 -04:00
Kristian Høgsberg dd263e546b window.c: Only set input region when we have a decoration
https://bugs.freedesktop.org/show_bug.cgi?id=50490
2012-07-09 22:23:39 -04:00
Daniel Stone d4756b7955 toytoolkit: Remove redundant XKB free
We already unref these in fini_xkb().

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-07-09 18:03:06 -04:00
Martin Olsson 8df662ad87 clients: Silence 2x gcc 4.6.3 "warn_unused_result" compiler warnings
window.c:1173:6: warning: ignoring return value of ‘read’, declared with attribute warn_unused_result [-Wunused-result]
desktop-shell.c:305:6: warning: ignoring return value of ‘read’, declared with attribute warn_unused_result [-Wunused-result]
2012-07-09 17:50:46 -04:00
Martin Olsson 444799adbb clients: Don't leak "menu" on error path in clients/window.c 2012-07-09 17:50:44 -04:00
Kristian Høgsberg 8733b33f9f window.c: Don't allocate proxy manually
With the wayland change to automatically allocate the client side proxy
manually, we can now drop the code (and the FIXME) that did that and just
receive the proxy from the callback arguments.
2012-06-28 22:04:06 -04:00
Kristian Høgsberg 8150b190d6 shell: Take a wl_surface as parent for transient and popup windows 2012-06-27 10:24:22 -04:00
Kristian Høgsberg 962342cb8e shell: Don't make desktop_shell background a wl_shell_surface
We don't gain anything from taking a wl_shell_surface in
desktop_surface.set_background, except making wl_shell_surface
gratuitously dependent on wl_shell.  In shell.c we can also handle
backgrounds in their own background_configure function which simplifies
the mapping and placement logic.
2012-06-26 16:29:53 -04:00
Kristian Høgsberg 11f600d82e window.c: Always set cursor after pointer enter
If the cursor didn't change since last time we had pointer focus we just
wouldn't change it.  But whoever had pointer focus in the mean time could
have changed it, so make sure we always set the cursor after pointer enter.
2012-06-22 10:52:58 -04:00
Kristian Høgsberg f337052a5c window: Add support for the blank cursor 2012-06-20 23:04:41 -04:00
Kristian Høgsberg d3c69c279a window: Stop keyboard repeat when we lose keyboard focus 2012-06-20 22:41:59 -04:00
Kristian Høgsberg 8b19c64146 window: Create timerfd non-blocking
Otherwise we might end up blocking when we reset the timer after the
timerfd poll readable.
2012-06-20 18:00:13 -04:00
Kristian Høgsberg a1627927c7 window: Compute initial window size correctly
We didn't take decoration size into account before.
2012-06-20 17:30:03 -04:00
Kristian Høgsberg bd0cd762bc window: Only repeat key if we still have kb focus 2012-06-20 15:17:18 -04:00
Kristian Høgsberg cf4d244082 window: Add key-repeat to toy toolkit 2012-06-20 14:52:12 -04:00
Ander Conselvan de Oliveira 2a3cd287ef window: Plug leak of shm_surface_data on shm_suface_data_destroy()
This was causing a leak on every frame when using shm buffers.
2012-06-19 11:36:36 -04:00
Daniel Stone a494f1d3f0 Don't segfault clients when cursor isn't found
If we can't find a cursor for whatever reason, don't crash the client in
pointer_surface_frame_callback.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-06-18 15:09:40 -04:00
Ander Conselvan de Oliveira 80620076fc window: Implement animated cursors (using pointer surfaces)
Since the introduction of pointer.set_cursor(), it is possible for a
client to set the surface containing the pointer image and get frame
callbacks on it thus allowing a clear implementation of animated
cursors.

This also makes the busy cursor hack of using frame callbacks on the
busy surface unnecessary.
2012-06-15 11:03:12 -04:00
Ander Conselvan de Oliveira 37ffc3c14b compositor: Track pointer image protocol change
The request pointer.attach was replaced with pointer.set_cursor that
lets a client set the cursor surface for a given pointer.
2012-06-15 10:59:41 -04:00
Pekka Paalanen 1da1b8f3f1 Rewrite shm buffer file allocation v2
We had duplicated code in many places, using hardcoded paths for
temporary files into more than one path. Some cases did not bother with
O_CLOEXEC, and all hardcoded paths that might not exist.

Add an OS helper function for creating a unique anonymous file with
close-on-exec semantics. The helper uses $XDG_RUNTIME_DIR as the
directory for a file.

This patch unifies the buffer file creation in both Weston and the
clients.

As simple clients are better not linking to libshared, as it would
require e.g. Cairo, they pull the OS compatibility code directly.

Android does not have mkostemp(), so a configure test is added for it,
and a fallback used if it is not available.

Changes in v2:
	remove all the alternate possible directory definitions and use
	XDG_RUNTIME_DIR only, and fail is it is not set.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-06-06 13:26:30 -04:00
Kristian Høgsberg d56bd908bf shell: Use a busy cursor animation for unresponsive surfaces 2012-06-05 09:58:51 -04:00
Kristian Høgsberg 7cee19778a window.c: Add primitive support for animated cursors
This just adds an entry point to set a specific frame of an animated cursor.
2012-06-04 23:39:04 -04:00
Kristian Høgsberg f33984edea window.c: Set focus widget before calling enter handler
This way input_get_focus_widget() returns the right widget when
called from the enter handler.
2012-06-04 23:36:32 -04:00
Kristian Høgsberg 8591dbf8b5 window.c: Add watch cursor 2012-06-04 16:10:40 -04:00
Kristian Høgsberg 5a4e9ff51b window.c: Drop timestamp argument to input_set_pointer_image()
We need the serial to set a pointer image and we track that internally.
2012-06-04 16:04:07 -04:00
Scott Moreau 9295ce05ab Drop user input detection from text cursor position implementation. 2012-06-04 11:07:54 -04:00
Scott Moreau ae71220fc9 Convert text cursor position protocol to use fixed types. 2012-06-04 11:07:50 -04:00
Daniel Stone b7452fe313 Add support for wl_keyboard::keymap events
These keymap events communicate the keymap from the compositor to the
clients via fd passing, rather than having the clients separately
compile a map.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-06-01 11:14:51 -04:00
Kristian Høgsberg a4b3d0ede7 window.c: Handle losing selection data source 2012-05-31 23:30:32 -04:00
Daniel Stone 97f685449e clients: Move XKB info from display to input struct
As it does (will) vary per-seat.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-05-31 15:46:30 -04:00
Daniel Stone 2fce4028d6 Convert wl_pointer::axis to wl_fixed_t
To go with the matching protocol change.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-05-31 15:45:25 -04:00
Daniel Stone c9785eacca Use enum wl_keyboard_key_state instead of integer
Instead of using a uint32_t for state everywhere (except on the wire,
where that's still the call signature), use the new
wl_keyboard_key_state enum, and explicit comparisons.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-05-31 15:43:03 -04:00
Daniel Stone 4dbadb1556 Use enum wl_pointer_button_state instead of integer
Instead of using a uint32_t for state everywhere (except on the wire,
where that's still the call signature), use the new
wl_pointer_button_state enum, and explicit comparisons.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-05-31 15:42:47 -04:00
Daniel Stone 351eb61fbc Support wl_keyboard::modifiers event
This event lets the compositor inform clients of the canonical keyboard
modifier/group state.  Make sure we send it at appropriate moments from
the compositor, and listen for it in clients as well.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-05-31 15:27:47 -04:00
Pekka Paalanen 647f2bfd2a window: add wrapper for EPOLL_CLOEXEC
Android does not have EPOLL_CLOEXEC, so add a fallback.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-05-31 13:53:51 -04:00
Scott Moreau 7a1b32a198 Implement text cursor position protocol.
Here we create a new client/compositor interface in weston to allow
clients to report their x/y cursor position to the compositor. These
values are then used to center the zoom area on this point. This
is useful for everyone, especially people who are visually impaired.
2012-05-31 13:10:22 -04:00
Ander Conselvan de Oliveira 08bcf14903 dnd: implement option for not offering data to other clients
Add option --self-only to dnd client. If this options is passed, the
drag will be started with no data source so that no drag and drop
events are sent to other clients.
2012-05-29 09:58:17 -04:00
Yan Wang a261f7e6dc Weston: Free allocated cursors array when destroying
This array is allocated in create_cursors(). It should be freed in
destroy_cursors().
2012-05-29 09:53:42 -04:00
Ander Conselvan de Oliveira 210eb9d2ba dnd: work around cairo-gl brokenness
If cairo-gl is used, display_create_surface() will create an
wl_egl_window for each surface and this will result in errors if this
surface is used as a source. Also, one can't get a wl_buffer for such
a surface wich led to crashes when trying to do so for the drag icon.

This patch works around both problems by forcing the item and drag icon
surfaces to use shm.
2012-05-25 23:28:59 -04:00
Ander Conselvan de Oliveira dc8c8fce72 window: rename enum pointer_type to cursor_type
This avoids confusion with the pointer devices (struct wl_pointer).
2012-05-25 23:28:54 -04:00
Ander Conselvan de Oliveira d8f527c845 window: track changes in libwayland-cursor api
libwayland-cursor does not provide enum wl_cursor_type anymore so this
brings back enum pointer_type.

This partially revers commit 1042dc15e0.
2012-05-25 23:09:06 -04:00
Tiago Vignatti 82db9d80e6 window: add simple text tooltip handlers
Using set_transient.

Signed-off-by: Tiago Vignatti <tiago.vignatti@intel.com>
2012-05-25 22:53:59 -04:00
Kristian Høgsberg f96e6c00d9 Share code to to classify pointer location in frame 2012-05-22 16:38:53 -04:00
Ander Conselvan de Oliveira 1042dc15e0 window: use libwayland-cursor instead of libXcursor 2012-05-22 10:17:34 -04:00
Tiago Vignatti dec76580c4 window: send transient flags over the wire
Signed-off-by: Tiago Vignatti <tiago.vignatti@intel.com>
2012-05-21 12:30:50 -04:00
Daniel Stone 37816df646 Convert wl_input_device to wl_seat (and friends)
wl_input_device has been both renamed and split.  wl_seat is now a
virtual object representing a group of logically related input devices
with related focus.

It now only generates one event: to let clients know that it has new
capabilities.  It takes requests which hand back objects for the
wl_pointer, wl_keyboard and wl_touch interfaces it exposes which all
provide the old input interface, just under different names.

This commit tracks these changes in weston and the clients, as well as
similar renames (e.g. weston_input_device -> weston_seat).  Some other
changes were necessary, e.g. renaming the name for the visible mouse
sprite from 'pointer' to 'cursor' so as to not conflict.

For simplicity, every seat is always exposed with all three interfaces,
although this will change as time goes on.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-05-16 15:29:06 -04:00
Kristian Høgsberg 5a315bc72d Move cairo-util to shared/ 2012-05-15 22:33:43 -04:00
Kristian Høgsberg 5adb480e60 window: Move frame rendering to cairo-util 2012-05-15 22:25:28 -04:00
Kristian Høgsberg 42abdf5c80 window: Move theme rendering code to cairo-util 2012-05-15 22:14:27 -04:00
Kristian Høgsberg 291c69cf93 window: Move all frame theme related state into new struct theme 2012-05-15 22:12:54 -04:00
Kristian Høgsberg d9931880c5 window: Compute title vertical position based on font extents
We just fudged it before.
2012-05-15 21:52:25 -04:00
Rob Bradford 7507b570c6 window: Store the outputs that the window is on
Using the surface enter/leave events track which outputs the window is on and
store those in a "window_output_list" on the window.

To create this list we define a struct window_output that is the list
relationship between the window and the output.
2012-05-15 13:29:37 -04:00
Scott Moreau f7e498cb89 toytoolkit: Recalculate input region if client has modified it's size.
If a client changes it's width/height values in it's widget resize handler,
the input region will be wrong because of the assumptions toytoolkit makes
in frame_resize_handler(). So far, gears is the only client that does this.
2012-05-14 14:30:01 -04:00
Pekka Paalanen 79b5652de6 window: fix missed xkb API adaptation
Oddly enough, this failed to build on Android, but not otherwise.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-05-14 10:02:12 -04:00
Kristian Høgsberg 4c3dac9c66 clients: Remove superfluous #includes
In particular window.c and many clients were including glib.h without
using it and without the right cflags.
2012-05-11 16:40:22 -04:00
Kristian Høgsberg bef52d1423 Update to new libxkbcommon API
We no longer depend on xproto, we use xkbcommon keycodes now. Yay!
2012-05-11 11:24:35 -04:00
Martin Minarik 1998b154a7 window.c: frame_button: Maximize, minimize, close, icon buttons in window frame 2012-05-10 16:19:33 -04:00
Kristian Høgsberg 80680c7b75 window.c: Just use float instead of GLfloat, remove GLES2.h include 2012-05-10 14:11:44 -04:00
Dima Ryazanov ff1c2d7914 window: Don't crash if a cursor image failed to load.
Signed-off-by: Dima Ryazanov <dima@gmail.com>
2012-05-09 11:25:11 -04:00
Rafal Mielniczuk 87e4c9354e window: fix check of cursor image load result 2012-05-08 16:22:31 -04:00
Kristian Høgsberg 7016313778 Port Wayland clients to new xkbcommon API
A little different from Daniels initial patch.  We look up the common
modifiers at xkb init time and convert the xkb serialized modifier mask
to our own modifier bitmask.
2012-05-08 15:55:39 -04:00
Daniel Stone 103db7fb56 Convert wire input co-ordinates to fixed-point
To add greater precision when working with transformed surfaces and/or
high-resolution input devices.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-05-08 14:41:01 -04:00
Daniel Stone b230a7ee58 Convert internal input co-ordinates to GLfloat
Change all client motion handlers to take GLfloat for co-ordinates,
rather than int32_t.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-05-08 14:40:57 -04:00
Ander Conselvan de Oliveira 001de54ea1 window: use only one shm pool for all the cursor images
Cursor images are fairly small and having one pool for each image adds
a lot of unnecessary overhead. Instead, create one large pool and
allocated all cursor images from that.

In order to do that, however, the code that creates shm surface needed
some refactoring. This patch adds a new struct shm_pool that is used
by the cursor and also changes struct window to use it.
2012-05-07 14:44:02 -04:00
Daniel Stone 5d66371743 Change button from int to uint32_t
Since you can't really have a negative button number.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-05-07 12:57:11 -04:00
Daniel Stone da5b93c8d7 Change key/button grab bindings to take unsigned state
'state' here meaning 'is it up or down?', obviously.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-05-07 12:54:14 -04:00
Ander Conselvan de Oliveira 1493d2ae1c window: use libXcursor for loading pointer images 2012-05-03 10:14:04 -04:00
Kristian Høgsberg 3e0fe5c0df window: Set window title and class 2012-05-02 09:47:55 -04:00
Kristian Høgsberg 407ef64e17 window: Only set toplevel window type if nothing else is set 2012-04-27 17:17:12 -04:00
Casey Dahlin 9074db5d62 Send surface enter/leave events
These new protocol events allow us to tell which outputs a surface is on, and
potentially update where we allocate our buffers from.

Signed-off-by: Casey Dahlin <cdahlin@redhat.com>
2012-04-20 13:39:40 -04:00
Scott Moreau ff1db4a4f3 Install structuring for ping-pong protocol 2012-04-19 12:50:47 -04:00
Kristian Høgsberg a6c8b0084f window.c: Drop the toolkit grab when we start a compositor grab
We do this right for move and resize, but dnd and popups need the same
treatment.
2012-04-13 12:55:45 -04:00
Kristian Høgsberg f2eb68a921 window: Send serial number in set_popup request 2012-04-13 12:37:19 -04:00
Kristian Høgsberg 84b76c72c8 window: Initialize redraw_task.link so we can always remove it 2012-04-13 12:01:18 -04:00
Kristian Høgsberg eae5de7609 Follow wayland change to serial numbers 2012-04-11 22:42:15 -04:00
Kristian Høgsberg 5990fbb6e2 window: Fix remaining references to the egl image surface type
Didn't catch these before, was compiling with sw cairo.
2012-04-10 16:55:11 -04:00
Kristian Høgsberg bad4297380 window: Drop EGLImage surface type 2012-04-10 11:49:45 -04:00
Kristian Høgsberg 24b5e230fa window: Only unmap shm surface backing memory if it belongs to surface
Memory allocated out of the resize shm pool will be unmapped when the pool
is destroyed.
2012-04-10 11:32:35 -04:00
Kristian Høgsberg 6e2a8d74b5 window: Simplify the shm surface management
We can destroy a shm wl_buffer immediately after sending it to the server.
2012-04-10 11:23:13 -04:00
Kristian Høgsberg 610a3f2922 window: Check load_image result for NULL 2012-04-03 14:50:15 -04:00
Jonas Ådahl 3685c3abf6 Fix `unused-result' warnings.
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2012-04-03 14:50:15 -04:00
Kristian Høgsberg 1103a1a484 window: Use a persistent, big shm pool during resize
The biggest performance bottleneck while resizing is the continous
setting up and tearing down of mmaps and faulting in pages.  This commit
introduces a per-window pool that we'll allocate buffers out of if it's
available.  Then we set initialize it to a big shm pool when we start
resizing and free it when resizing is done.
2012-04-03 12:00:48 -04:00
Kristian Høgsberg 8f64ed0381 window: Only initialize egl if we have cairo egl 2012-04-03 11:57:44 -04:00
Kristian Høgsberg 16626282fd clients: Use new shm interface 2012-04-03 11:22:06 -04:00
Kristian Høgsberg 875ab9e735 Add signedness warning flag and fix fallout 2012-03-30 11:52:39 -04:00
Kristian Høgsberg 9629fe3206 Simplify shm buffer handling
There was a lot of code here to do a lot of work we didn't need to do.
If we damage a surface with a shm buffer attached, all we need to do
is to re-upload the damaged region to the texture.  As for drm buffers,
we don't assume anything changes on attach and only update the
regions the client tells us to update in the damage request.
2012-03-26 19:27:35 -04:00
Kristian Høgsberg 42b4f80116 window.c: Do resize work from the repaint idle callback
This way we always make sure we handle any resizing before we start drawing.
2012-03-26 13:49:29 -04:00
Kristian Høgsberg 6bd4d97271 window.c; Only redraw once per frame
Based on a patch from Martin Minarik <minarik11@student.fiit.stuba.sk> who
tracked down the excessive redraw problem.
2012-03-24 14:42:09 -04:00
Scott Moreau 210d079817 Hook up axis events. 2012-03-22 11:03:41 -06:00
Kristian Høgsberg ec323d222c window.c: Increase drop shadow fluffiness 2012-03-21 01:07:49 -04:00
Kristian Høgsberg b8abe7e9ae window.c: Tweak window decoration appearance
The old orange decorations were starting to look like clown shoes.
2012-03-20 23:56:05 -04:00
Kristian Høgsberg f02a649a3c Consolidate image loading code and move to shared/ 2012-03-12 01:40:59 -04:00
Kristian Høgsberg bcacef19b0 Add an option parser
On one hand, getopt (in particular the -o suboption syntax) sucks on the
server side, and on the client side we would like to avoid the glib
dependency.  We can roll out own option parser and solve both problems
and save a few lines of code total.
2012-03-12 01:28:50 -04:00
Rob Clark 6396ed36f4 clients/window: fix build issues w/ gles 2012-03-12 01:16:12 -04:00
Kristian Høgsberg b435e84d5a window: Compute frame boundary for all windows except fullscreen
We were only computing it for toplevel type windows, which broke
the unlock dialog size allocation and repainting.
2012-03-05 20:38:08 -05:00
Kristian Høgsberg 63e5e06d82 window: Only set opaque and input regions if they change
Setting these regions damages the entire window or causes a repick, which
we don't want to trigger if we don't need to.
2012-03-05 00:04:57 -05:00
Kristian Høgsberg 067fd60534 window.c: Drop support for rgb contexts 2012-02-29 16:15:53 -05:00
Kristian Høgsberg f10df85cd7 window: Set opaque region after child widget adjusts size 2012-02-29 12:43:05 -05:00
Kristian Høgsberg fcfc83f6ae clients: Use wl_display_disconnect() 2012-02-28 14:34:54 -05:00
Kristian Høgsberg 010f98b083 window: Track and report input and opaque regions
We just set the input region to the bounding box of the window frame
and set the opaque region to be the opaque rectangle inside the window
if the child widget is opaque.
2012-02-23 17:30:54 -05:00
Kristian Høgsberg 06d58b74af Update to enter/leave events for pointer and keyboard 2012-02-23 09:59:05 -05:00
Kristian Høgsberg 2675dc1c8d window: Don't draw decorations in fullscreen mode 2012-02-16 23:19:41 -05:00
Kristian Høgsberg 1517defe13 window: Set window type as it changes, not on every attach
It was always a bit sloppy, and the new fullscreen request doesn't work
that way.
2012-02-16 23:19:41 -05:00
Daniel Stone 0d5a509ae5 window: Use constant keycode offset of 8
The X11 compositor currently posts its key presses as keycode - 8; this
is due to X11 having a historical minimum keycode of 8, whereas evdev is
numbered starting from 1.  So while the KEY_* constants begin with
KEY_ESC at 1, the corresponding keycode in both X11 and the XKB keymaps
is 9.

window, on the other hand, was relying on xkb->min_key_code being 8 to
translate its keycodes back to useful values in the XKB 'evdev' keycode
map.  min_key_code may not always be 8, for restricted subsets of the
keycode map.

Perhaps not the best solution, but at least consistent.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-02-16 23:19:41 -05:00
Daniel Stone 9d4f030c0b window: Use new xkbcommon include path
xkbcommon in current git has moved its include files.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-02-16 23:19:40 -05:00
Pekka Paalanen b29f412eb8 protocol: remove absolute coordinates from pointer
This change depens on the Wayland core commit:
"protocol: remove absolute coordinates from pointer".

Remove the absolute coordinates from pointer motion and pointer_focus
events.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-02-16 23:19:40 -05:00
Pekka Paalanen dfb93a9e71 window: do not store absolute coordinates
These were not used for anything, anyway.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-02-16 23:19:40 -05:00
Kristian Høgsberg f856fd2f93 Follow set_fullscreen protocol change 2012-02-16 23:19:38 -05:00
Kristian Høgsberg d6bcd7daa7 window: Toggle maximized with super-f5 2012-02-16 23:19:38 -05:00
Tiago Vignatti c5528d8dc8 window: simplify a bit widget_set_size and widget_set_allocation
Signed-off-by: Tiago Vignatti <vignatti@freedesktop.org>
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-02-13 11:52:24 +02:00
Tiago Vignatti a571e75cc1 window: explicitly set TYPE_TOPLEVEL for new windows
Signed-off-by: Tiago Vignatti <vignatti@freedesktop.org>
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-02-13 11:52:24 +02:00
Kristian Høgsberg 09a96b5394 window: Don't set the window size in widget_set_size()
We propagate the toplevel widget size to the window size in the
window.c resize code.
2012-02-08 14:45:02 -05:00
Kristian Høgsberg 2ad3b7f866 window: Fold window_resize into idle_resize 2012-01-31 15:34:15 -05:00
Kristian Høgsberg 0d1c062913 window: Don't overwrite window->allocation until we've done the resize
This way we can actually detect whether or not a window resizes.
2012-01-31 15:30:47 -05:00
Kristian Høgsberg 009ac0a965 window: Dont take width and height in window constructor
Always set this by scheduling an initial resize.
2012-01-31 15:24:48 -05:00
Kristian Høgsberg 8e054f76cc flower: Dont allow resizing 2012-01-31 11:53:20 -05:00
Kristian Høgsberg d31fcab989 window: Make window frame menu available to client 2012-01-31 09:53:44 -05:00
Ander Conselvan de Oliveira e018b04c40 window: fix resizing of windows backed by shm buffers
When window_attach_surface() calls window_get_resize_dx_dy(),
window->resize_edges is cleared. However if there is already a pending
surface to be attached, the resize won't be done until the following
call to window_attach_surface(). In this next call, since resize_edges
is now zero, the top-left corner of the window will be unchanged. If
the user is resizing from the top or left border, this causes the
resize to happen in the wrong direction.

This patch changes window_attach_surface() to call
window_get_resize_dx_dy() only if an attach will actually happen.

Signed-off-by: Ander Conselvan de Oliveira <ander.conselvan.de.oliveira@intel.com>
2012-01-27 11:17:13 -05:00
Kristian Høgsberg 42c8f60506 window: Handle data_device.selection events with offer=NULL
This happens when the current selection data_offer is removed.
2012-01-27 11:08:40 -05:00
Kristian Høgsberg ae6e2717c5 window: Don't crash when window with focus_widget is destroyed
We would try to deliver a leave event to a widget in a destroyed window.
2012-01-26 11:09:20 -05:00
Neil Roberts 6b28aadd47 window: Fix sending button events when there's no grab
The code which sends the button events was checking whether there is a
focus widget with a button handler but then always sending the button
event to the grab widget. If the grab widget is different from the
focus widget at this point then it will check the wrong widget for a
button handler and potentially crash. It is also possible for there to
be no grab widget here in the following situation:

1. Press and hold down the left mouse button
2. Press and hold down the right mouse button
3. Release the left mouse button
4. Release the right mouse button

In this case the grab will be released at step 3 because the code only
keeps track of the grab for one button. Then it will try to send the
release event for the right mouse button to a NULL widget so it will
crash.
2012-01-24 11:25:15 -05:00
Kristian Høgsberg 824c6d0e38 window: Use CAIRO_OPERATOR_OVER for rendering the menu
We forgot to switch back from CAIRO_OPERATOR_SOURCE, which is broken,
but also hits a broken fallback in cairo-gl.
2012-01-19 13:54:11 -05:00
Pekka Paalanen 6d174cff7a window: menu leak fixes
When a menu self-destructs, free also the widget and struct menu.

As menus are self-destructing, it does not make sense to store the
window pointer, since we cannot clear it automatically. Therefore,
rename window_create_menu() to window_show_menu() that does not return
the window pointer. It also calls window_schedule_redraw() internally.

Fixes Valgrind reported memory leaks.

The alternative would be to explicitly destroy the menu in application's
menu callback.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-01-19 16:42:05 +02:00
Pekka Paalanen e156fb681e window: remove pointers to widget on destroy
Input devices may hold a pointer to the widget being destroyed. Reset
such pointers in widget_destroy().

This fixes a use-after-free in window_destroy(), if an application
destroys its widgets before the window.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-01-19 16:41:55 +02:00
Pekka Paalanen 4dde2fc6f6 window: destroy frame in window_destroy()
Fix a memory leak reported by Valgrind, by destroying the window
decorations widget, if it exists.

All widget pointers returned from toytoolkit to the application should
be destroyed by the application explicitly.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-01-19 16:41:48 +02:00
Kristian Høgsberg 2d57439592 clients: Allow compiling with the cairo glesv2 backend
This disables gears and wscreensaver, which use full GL.
2012-01-18 14:50:58 -05:00
Kristian Høgsberg 8e81df4503 Use new format codes 2012-01-11 14:24:46 -05:00
Kristian Høgsberg 62444800e1 window: Don't deref focus widget if there isn't one 2012-01-11 11:18:14 -05:00
Kristian Høgsberg f0993f61c0 window: Remove a few unused struct fields 2012-01-11 00:09:42 -05:00
Kristian Høgsberg b63235142d window: Move focus widget to struct input 2012-01-11 00:04:42 -05:00
Kristian Høgsberg 831dd52aa0 window: Implement input device grabbing
With all input events going to widgets now, we can grab an input device
to a widget, so that all events are delivered to that widgets handlers.
This lets us implement the last bit of the menu behaviour, that is
the client side grabbing of events.  The result is that we can now pop down
the menu when we receive clicks in the clients own windows and we
don't send motion and button events to other widgets.
2012-01-10 23:46:33 -05:00
Kristian Høgsberg 29af3ebce6 window: Make decorations just a widget
Woohoo, only took 25 commits of refactoring to get to this point.
2012-01-10 22:41:55 -05:00
Kristian Høgsberg bb97700474 window: Get rid of the window child allocation concept 2012-01-10 19:11:42 -05:00
Kristian Høgsberg 27ff086b8e window: Break widget grab before shell surface move or grab 2012-01-10 14:28:58 -05:00
Kristian Høgsberg 441338cb75 window: Keep widgets in a tree instead of a list 2012-01-10 14:22:14 -05:00
Kristian Høgsberg 30948989ee window: Use surface coordinates for looking up widgets 2012-01-10 14:22:14 -05:00
Kristian Høgsberg b67e94b170 window: Make resize and redraw handlers widget vfuncs 2012-01-10 14:22:10 -05:00
Kristian Høgsberg 5d12990dbe window: Allocate and flush the window surface in window.c
No need to push this to the toolkit users.
2012-01-10 12:25:32 -05:00
Kristian Høgsberg 75bc667a70 window: Drop the window widget
It was just a temporary convenience for moving things over.
2012-01-10 10:45:52 -05:00
Kristian Høgsberg 9ca2d08fb0 window: Run deferred tasks before blocking for initial iteration
The first iteration of the while loop wouldn't run the deferred tasks
before blocking in epoll_wait().  Move things around so we do.
2012-01-09 18:48:14 -05:00
Kristian Høgsberg bb901fac90 window: Return pointer type from widget enter handler 2012-01-09 11:22:32 -05:00
Kristian Høgsberg a8a0db3497 window: Move button handler to widget 2012-01-09 11:12:05 -05:00
Kristian Høgsberg 19dd1d7eb1 window: Use the window widget instead of adding a window sized widget 2012-01-09 10:42:41 -05:00
Kristian Høgsberg 87a57bbd73 window: Create a widget for the window, drop window motion handler 2012-01-09 10:34:35 -05:00
Kristian Høgsberg 5f190ef96a window: Convert a few clients to use widget motion handler 2012-01-09 09:44:45 -05:00
Kristian Høgsberg 04e98344cf window: Add a widget motion handler 2012-01-09 09:36:16 -05:00
Kristian Høgsberg ab9e79ffc2 window: Remove window enter/leave handlers 2012-01-09 09:32:07 -05:00
Kristian Høgsberg 391649b0dc window: Use widget enter/leave handlers for menu 2012-01-09 09:22:30 -05:00
Kristian Høgsberg ee143236d7 window: Replace widget focus handler with a enter/leave handler pair 2012-01-09 08:42:24 -05:00
Kristian Høgsberg 21eabf60b0 window: Use display_exit() instead of exit() in window menu 2012-01-08 15:41:52 -05:00
Kristian Høgsberg 9a13dab8a9 window: Move widget focus handler to the widget 2012-01-08 15:18:19 -05:00
Kristian Høgsberg c51f79954b window: Rename item to widget
It's a widget.
2012-01-08 15:09:53 -05:00
Kristian Høgsberg 4f7dcd6eb1 window: Add a window menu
At least this gives us a way to close the toy toolkit clients.
2012-01-06 22:03:44 -05:00
Kristian Høgsberg b3cca0a411 shell: Start implementing the popup surface type
This lands the basic behavior of the popup surface type, but there are still
a number of details to be worked out.  Mainly there's a hardcoded timeout
to handle the case of releasing the popup button outside any of the
client windows, which triggers popup_end if it happens after the timeout.
Maybe we just need to add that as an argument, or we could add a new event
that fires in this case to let the client decide whether it ends the popup
or not.
2012-01-06 11:41:55 -05:00
Kristian Høgsberg 9724b51750 More weston rename fixes 2012-01-03 14:35:49 -05:00
Kristian Høgsberg e7aaec301a x11: Bridge X11 CLIPBOARD selection to Wayland clients 2011-12-27 13:50:04 -05:00
Kristian Høgsberg e04ad57a01 window.c: Add touch event stubs
Prevent window.c clients from crashing on touch events.
2011-12-22 11:32:38 -05:00
Kristian Høgsberg 8a1d10d66c window.c: Rename input handlers to input_handle_*
They're event handlers for the input object, not the window object.
2011-12-22 11:32:34 -05:00
Pekka Paalanen 325bb60792 window: destroy surfaces on display_destroy()
Destroy the window decoration surfaces and pointer surfaces.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-12-22 11:27:51 +02:00
Pekka Paalanen e1207c708e window: destroy all inputs on display_destroy()
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-12-22 11:27:51 +02:00
Pekka Paalanen c20529846e window: destroy misc objects on display_destroy()
Windows are supposed to be destroyed by the application explicitly.

Deferred tasks are not supposed to be added after returning from
display_run().

Destroy remaining wl objects (except input related will be in a
following patch).

Close the epoll fd.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-12-22 11:27:51 +02:00
Pekka Paalanen 2c1426a72f window: destroy outputs on display_destroy()
This will also start calling the output destroy handlers, if an
application has set any.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-12-22 11:27:51 +02:00
Pekka Paalanen 5ec6585753 window: destroy window surfaces and title
Plugs leaks from struct window in window_destroy().

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-12-22 11:27:51 +02:00
Pekka Paalanen 51ce95a6eb window: remove unused struct members
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-12-22 11:27:50 +02:00
Pekka Paalanen fe6079ac09 window: add display_destroy()
Add a function to destroy the 'struct display', supposedly with all
contained resources, that are not explicitly created by the application.

The implementation at this time is incomplete. It does clean up the
following:
- xkb structure is freed (needs new libxkbcommon from git)
- EGL resources are freed
- wl_display is flushed and destroyed

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-12-22 11:27:50 +02:00
Pekka Paalanen 826d795448 window: add display_exit()
Add a function, that schedules the display_run() event loop to break
out.

When display_exit() is called, processing continues as usual, until
currently waiting events and deferred tasks have been processed, and
sent requests are flushed. Then, display_run() will return.

This enables toytoolkit apps to handle their exit instead of just being
killed or call exit().

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-12-22 11:27:50 +02:00
Kristian Høgsberg bbedd7e9d2 clients: Implement a toy-menu for testing the menu surface type 2011-12-19 15:40:10 -05:00
Pekka Paalanen 9015ead7d6 window: do proper Cairo device flushing
The Cairo documentation tells us to always call cairo_device_flush()
before using other rendering APIs on the cairo surface, especially where
the Cairo device shares state with us (that is, EGL and GL state in this
case).

Add a call to cairo_device_flush() into display_acquire_window_surface(),
which the toytoolkit offers for switching to native (GL) rendering.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-12-19 10:50:38 -05:00
Kristian Høgsberg cd9ac1da5f compositor: Remove server side cursors
We always expect the clients to set the cursor and attaching a NULL buffer
hides the cursor.  The cursor starts out hidden.
2011-12-15 09:15:08 -05:00
Pekka Paalanen 999c5b5dcb window: expose outputs to applications
Add output_configure_handler as a display property. This exposes only
configured outputs, that is the current mode info is already received,
to applications.

The handler is also called for mode changes on an existing output. This
simplifies the implementation in toytoolkit as we can defer the handler
calls from wl_output binding time to when we receive the current mode.
We do not need separate handlers for "new output" and "mode changed". A
plain "new output" handler would be problematic as the current mode is
not known yet.

Also add delete_handler hook for outputs, but that will never be called
for now, as the protocol lacks a way to signal output disconnections.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-12-14 11:17:46 +02:00
Pekka Paalanen 6b2dc9119e window: do not crash without wl_shell
Since it is the desktop-shell plugin in the compositor that offers both
wl_shell global interface and wl_shell_surface interface, those are not
available on the tablet-shell plugin.

The tablet-shell client uses the toytoolkit, so toytoolkit must work
somehow even without wl_shell.

Turn all operations in toytoolkit that would require wl_shell or
wl_shell_surface into no-ops.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-12-04 14:55:40 -05:00
Pekka Paalanen 068ae944db desktop-shell: update protocol and client to wl_shell_surface
Change desktop-shell protocol to use wl_shell_surface instead of
wl_surface.

Adapt the desktop-shell client and the shell plugin.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-12-04 14:54:34 -05:00
Pekka Paalanen 9d1613eb4a wl_shell_surface adaptation
Protocol changes in Wayland core introduced a new interface
wl_shell_surface, and moved all wl_shell surface methods into it. Adapt
the compositor and its Wayland backend, shell plugin, and all clients to
the new interface.

Depends on the Wayland core commit "protocol: introduce wl_shell_surface"

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-12-04 14:54:26 -05:00
Pekka Paalanen a03a93c6ea window: fix segfault in window_handle_key()
When a window destroyed, if any input had the window in keyboard
focus, the keyboard focus is reset to NULL. A new keyboard focus is set
only, if the user clicks something. If the user presses a key instead of
clicking, the key press event is sent to the client which has NULL
keyboard focus, triggering a segfault in window_handle_key().

Fix the segfault by ignoring the key event, if there is no target
window.

I triggered this segfault by clicking the unlock dialog away, and then
pressing a key.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-12-02 06:31:08 -05:00
Kristian Høgsberg 53ff2f6672 window.c: Cache outputs 2011-11-26 17:27:37 -05:00
Kristian Høgsberg 47fe08aad5 Implement the new dnd/selection protocol
The new protocol splits dnd/selection from wl_shell and allows us to move
the implementation out of shell.c.
2011-11-23 16:20:28 -05:00
Kristian Høgsberg c5241f5b73 Never include wayland-util.h directly
And fix a missing "" to <> conversion for wayland-client.h include.
2011-11-22 09:35:14 -05:00
Pekka Paalanen 50719bce2a Fix inconsistent #include style
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-11-22 09:27:03 -05:00
Kristian Høgsberg 980c49e6cd window: Remove unused variable 2011-11-18 15:24:23 -05:00
Pekka Paalanen 77cbc951cb window: clean up redraw and focuses on destroy
Currently, the way to destroy a window in a response to an event (e.g.
button click), is to put a task into the deferred list with
display_defer(). The task will then call window_destroy() from outside
event handling code.

As events are handled, it is possible that the deferred list contains
also the redraw task for this window. As the execution order of these
tasks is unknown (redrawing a freed window is a bug) and redrawing
something that goes away immediately is not useful, the redraw task must
be removed on window_destroy().

'struct input' contains pointers to windows currently in focus for that
input device. These pointers must also be cleared on window_destroy().
This fixes a use-after-free bug for the unlock dialog in desktop-shell
(future commit).

As an irrelevant minor cleanup, window::grab_device member is not used
anywhere, and is removed.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-11-15 16:43:24 -05:00
Rob Bradford 8bd35c7770 window: Avoid setting an invalid surface for the pointer
If we failed to load the pointer image to the surface then do not create a
buffer from a NULL surface and do not attach that to the device.
2011-10-25 12:20:51 +01:00
Rob Bradford 21223bf6d1 window: Report an error if we cannot load the pointer files 2011-10-25 12:19:36 +01:00
Kristian Høgsberg bcee9a4b25 desktop-shell: Add beginning of pop-up menu to panel 2011-10-12 00:36:16 -04:00
Benjamin Franzke 1a89f28c7d gears: Fail if compiled without cairo-egl 2011-10-07 10:06:01 +02:00
Benjamin Franzke 0c99163d9b window: Create a cairo device for each egl config 2011-10-07 10:06:01 +02:00
Benjamin Franzke 47eb8f4e91 window: Remove display_flush_cairo_device
Rather add a flush_surface utility that
flushed the cairo_device thats associated to a surface.
2011-10-07 10:05:57 +02:00
Kristian Høgsberg e4fb78de8f Handle compositors without wl_shell 2011-09-21 17:43:32 -04:00
Kristian Høgsberg e28d05b0ad window.c: Move window items to window.c 2011-09-20 21:43:54 -04:00
Kristian Høgsberg 3a69627f43 window: Stop using glib mainloop in toy toolkit 2011-09-19 17:28:55 -04:00
Kristian Høgsberg 1e164b9afd Move rounded_rect() to cairo-util.c 2011-09-19 17:26:44 -04:00
Kristian Høgsberg 547da5afc9 terminal: Make -f (fullscreen) option work again 2011-09-19 17:26:30 -04:00
Kristian Høgsberg f8ab46e149 window: Default to toplevel windows 2011-09-08 16:56:38 -04:00
Kristian Høgsberg 0c29eb292e clients: Add a simple desktop-shell app
This just provides the background surface and the top panel.
2011-09-06 18:02:34 -04:00
Kristian Høgsberg 900b226ac1 window: Add enter/leave handlers 2011-09-06 14:33:52 -04:00
Benjamin Franzke 4b87a13974 clients: Fix typos
And forgotten display_create conversion in view.c.
2011-09-01 10:36:53 +02:00
Benjamin Franzke 91eacca38b Remove egl display type setenv hack
No longer needed with mesa 7.12-devel egl display autodetection.
2011-08-31 16:25:18 -04:00
Kristian Høgsberg f389cacc20 Move away from visuals and just use EGLConfigs or shm format tokens 2011-08-31 16:21:38 -04:00
Kristian Høgsberg 9de79a92a6 window.c: Drop global handler argument
We can just register a global handler directly on the wl_display now.
2011-08-29 17:12:36 -04:00
Kristian Høgsberg a8d1fa762e clients: Bring clients up to date 2011-08-29 17:12:36 -04:00
Kristian Høgsberg 334182062f Use the new wl_callback interface 2011-08-29 17:12:36 -04:00
Benjamin Franzke 22d5481f91 window.c: Fix compile/run using cairo without egl 2011-07-15 17:56:04 +00:00
Benjamin Franzke 14f7ff91ad window: Set egl_window_resize late and once
Previously we resized in attach_surface and create_surface.
THe second resize overwrote dx or dy from the first.
2011-06-23 12:10:51 +02:00
Kristian Høgsberg 8f0ce05f52 compositor: Send out more detailed output events 2011-06-21 11:16:58 -04:00
Kristian Høgsberg 7a5c979f4c Move map requests to shell 2011-06-20 10:45:24 -04:00
Benjamin Franzke 65e5051bc7 clients: Add an optional roundtrip for visual lookup 2011-05-31 15:05:32 +02:00
Kristian Høgsberg 3be87d1931 window: Add support for opaque windows 2011-05-16 14:46:41 -04:00
Kristian Høgsberg 8357cd61d8 window.c: Deal with visual changes 2011-05-16 10:43:32 -04:00
Egbert Eich e7b8d9055e compositor: Set EGL_PLATFORM env variable for each backend.
I may have missed something, but - since the Wayland compositor
already picks a platform backend, opens a connection and initializes the
backend specific display data structure it doesn't make sense
to let egl pick a platform. If it picks a different one the
display specific data structure will most likely not match.
Thus determine the platform in the Wayland rendering backend by setting
the EGL_PLATFORM env variable.
For the client any other platform than 'wayland' doesn't seem to make
sense.
I'm not sure if I've got the the platform ofr openfwd right.

Signed-off-by: Egbert Eich <eich@freedesktop.org>
2011-05-10 16:42:08 -04:00
Benjamin Franzke bde55ec8e4 Implement buffer.damage in shm, use it in window.c 2011-04-22 11:53:45 -04:00
Kristian Høgsberg 7cbdb64ab6 Fix clients to work with wl_ prefixed interface names 2011-04-20 18:53:37 -04:00
Kristian Høgsberg 91342c6081 Switch to new subscribe protocol and wayland-egl 2011-04-20 14:20:02 -04:00
Kristian Høgsberg d11eadb519 window.c: Check for cairo device failure the right way 2011-04-14 11:54:59 -04:00
Kristian Høgsberg 01aed1c665 Remove double definition of window_get_wl_surface() 2011-04-11 16:59:05 -04:00
Kristian Høgsberg 11e2828bdc Merge remote-tracking branch 'bnf/surface-frame-event'
Conflicts:
	compositor/compositor.c
2011-04-11 16:47:50 -04:00
Kristian Høgsberg 12b0bb343b Fix window_set_child_size() for windows without decoration 2011-04-11 13:18:31 -04:00
Kristian Høgsberg 386857ba6a Add struct window accessor for the wl_surface 2011-04-11 13:17:44 -04:00
Tim Wiederhake b4b67344f0 Define global handler on display creation
Otherwise the initial announcement of interfaces gets lost.
2011-04-11 13:16:33 -04:00
Benjamin Franzke cff904e69d gears: Use wayland egl surface instead of images 2011-03-17 15:55:25 +01:00
Benjamin Franzke 6693ac2108 window: Use window surfaces for windows 2011-03-17 15:55:18 +01:00
Benjamin Franzke ec4d342aa9 Support per surface frame events
This fixes tearing with multi head.
2011-03-17 11:54:35 +01:00
Tim Wiederhake 9c7a8cc663 fix typo in window.c 2011-02-11 13:44:31 -05:00
Kristian Høgsberg 0d5007a76f window.c: Use eglGetProcAddress to look up extension functions 2011-02-09 10:57:44 -05:00
Kristian Høgsberg 297d6dd442 window.c: Include wayland-egl.h before EGL headers so we get the right platform 2011-02-09 10:51:15 -05:00
Kristian Høgsberg bfb8e61381 Follow wayland-egl renames 2011-02-07 10:30:38 -05:00
Kristian Høgsberg 297c6313eb Port window.c to use wayland-egl 2011-02-07 09:12:56 -05:00
nobled 7b87cb04a9 window: add null checks
Also check for invalid parameters early on, so if we crash,
we know *why* we crashed.
2011-02-01 18:51:47 +00:00
nobled 14d222f612 add newlines in error messages 2011-02-01 18:48:46 +00:00
Kristian Høgsberg 0ce245761c Add initial basic support for fullscreen surfaces 2011-01-28 15:18:33 -05:00
Kristian Høgsberg 3ba4858c4b compositor-x11: Handle keyboard focus correctly so we avoid stuck modifiers 2011-01-27 11:57:19 -05:00
Kristian Høgsberg 00439617f3 Fix new gcc 4.6 warnings
simple-client.c:156:10: warning: variable ‘ar’ set but not used [-Wunused-but-set-variable]

etc.
2011-01-25 15:16:01 -05:00
Darxus@chaosreigns.com c4df99cb2c Replace gdk_pixbuf_unref with g_object_unref
Because gdk_pixbuf_unref is deprecated and for compatability with
gdk-pixbuf 2.21.4.
2011-01-25 15:05:08 -05:00
Kristian Høgsberg d5fb9cc769 window.c: Make title not const
We now strdup it.
2011-01-25 12:45:37 -05:00
Kristian Høgsberg 6ec41abf72 Merge remote branch 'callum/master'
Conflicts:
	clients/window.h
2011-01-25 10:40:01 -05:00
Tim Wiederhake 81bd979835 initialise display
fixes valgrind:
==25178== Conditional jump or move depends on uninitialised value(s)
==25178==    at 0x409E2C: display_create (window.c:1582)
==25178==    by 0x407A43: main (terminal.c:2323)
and
==13793== Conditional jump or move depends on uninitialised value(s)
==13793==    at 0x40A2D1: display_handle_global (window.c:1504)
==13793==    by 0x4E2C183: display_handle_global (wayland-client.c:281)
==13793==    by 0x713FEE7: ffi_call_unix64 (in /usr/lib/libffi.so.5.0.10)
==13793==    by 0x713FC83: ffi_call (in /usr/lib/libffi.so.5.0.10)
==13793==    by 0x4E2C71A: wl_closure_invoke (connection.c:663)
==13793==    by 0x4E2BB7B: wl_display_iterate (wayland-client.c:484)
==13793==    by 0x4096CA: display_create (window.c:1664)
==13793==    by 0x407A43: main (terminal.c:2321)
2011-01-23 17:58:30 -05:00
Tim Wiederhake 748f672b2c free option context 2011-01-23 17:58:22 -05:00
Tim Wiederhake b6761dc294 fix resizing at top/left border 2011-01-23 13:59:30 -05:00
Tim Wiederhake 8a6f7e3139 compositor crashes if window width or height is <= 0 2011-01-23 13:58:18 -05:00
Kristian Høgsberg a495333d4f Remove unused bits of cairo code 2011-01-21 22:17:03 -05:00