Commit Graph

1157 Commits

Author SHA1 Message Date
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
Tiago Vignatti 1f221fff71 compositor: Send out touch events accordingly
Signed-off-by: Tiago Vignatti <tiago.vignatti@intel.com>
2011-12-22 11:13:05 -05:00
Tiago Vignatti 22c6bcec9c evdev: Add ABS_MT_* support for direct touch devices
This adds ABS_MT_* support for direct touch devices and notifies
the compositor.  The compositor has a stub for now.

Signed-off-by: Tiago Vignatti <tiago.vignatti@intel.com>
2011-12-22 11:13:04 -05:00
Kristian Høgsberg 773d13b543 compositor: Make surface picking not depend on an input device 2011-12-22 11:13:04 -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 e59d74a9b9 resizor: add exit key and cleanups
Make resizor quit when you press Esc key.

Call the toytoolkit cleanup functions, properly destroy window, display
and frame callback.

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
Pekka Paalanen fb850c4e0f simple clients: flush before destroying wl_display
Flush our pending destroy requests to the server before destroying the
wl_display.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-12-22 11:27:50 +02:00
Pekka Paalanen 2c2c1060e9 simple-egl: implement destructors
Destroy all wl objects and call EGL cleanup functions. Reduces leaks
reported by Valgrind considerably, though not to zero.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-12-22 11:27:50 +02:00
Pekka Paalanen c4cd62acee simple-shm: implement destructors
Implement proper destructors that call the wayland destroy functions.

With this and the "client: fix a strdup memory leak" patch in Wayland
core, simple-shm now runs Valgrind-clean (memcheck).

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-12-22 11:27:50 +02:00
Pekka Paalanen 88e60fc2ba simple clients: add signal handler for clean exit
Add signal handler for SIGINT to simple-egl and simple-shm, so they can
be exited voluntarily, without killing them. Later we can add clean-up
code and destructors, and check with valgrind for leaks and errors.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-12-22 11:27:50 +02:00
Pekka Paalanen 3429a72597 compositor: fix uniform handling for fade_output()
fade_output() is strange in that it manufactures a wlsc_surface object
by hand, and then calls wlsc_surface_draw() on it.

Valgrind complained, that wlsc_surface_draw() accesses uninitialised
data: wlsc_surface::alpha. fade_output() forgets to set it.

Initialise surface.alpha in fade_output(). Specifically, set it to
compositor->current_alpha to deliberatly avoid the gluniform1f() call in
wlsc_surface_draw().

fade_output() binds a different GL shader program than
wlsc_surface_draw() expects. This program does not have a uniform called
"alpha", and the uniform location given in glUniform1f() is not for
this program anyway. A hint of that is the runtime error:
Mesa: User error: GL_INVALID_OPERATION in glUniform(type mismatch)

Fixing this seems to get rid of half a thousand of Valgrind errors, and
of course the Mesa user error.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-12-20 10:59:39 -05:00
Kristian Høgsberg bbedd7e9d2 clients: Implement a toy-menu for testing the menu surface type 2011-12-19 15:40:10 -05:00
Kristian Høgsberg 8da0fbde12 resizor: Use symbolic name for BTN_RIGHT
Also, we were actually using BTN_MIDDLE before.
2011-12-19 15:36:10 -05:00
Kristian Høgsberg 2a25cd4ffa compositor: Remove shell->activate callback
It's all internal to the shell plugin now.
2011-12-19 15:21:40 -05:00
Kristian Høgsberg e1a850e5b0 compositor: Move click-to-focus and ctrl-alt-bs bindings to shell.c 2011-12-19 15:21:39 -05:00
Kristian Høgsberg f47d8fe88c compositor: Move binding code to util.c 2011-12-19 15:21:30 -05:00
Kristian Høgsberg 2bd5b6376c compositor: Consolidate code for finding and running bindings 2011-12-19 14:59:57 -05:00
Kristian Høgsberg 5a5f0077be compositor: Make click to activate behavior a binding 2011-12-19 14:54:11 -05:00
Kristian Høgsberg 42e40ae6dd x11: Ignore FocusOut with mode = NotifyUngrab
Not sure why we get these, but it happens for Alt-click to move a window
(metacity binding) and messes up the idle inhibit counter.
FocusOut event as a result of ungrabbing doesn't really make sense and
fortunately we can safely ignore them.
2011-12-19 14:36:52 -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
Tiago Vignatti ce03ec3fbe evdev: new header file for the driver
Besides the new header file, there's also a change in the main evdev creation
procedure for a more suggestive name (evdev_input_add_devices ->
evdev_input_create). There's no real functional changes in this commit.

Signed-off-by: Tiago Vignatti <tiago.vignatti@intel.com>
2011-12-19 01:14:03 +02:00
Tiago Vignatti 6e2d5f14e8 compositor-drm: remove/add evdev devices when vt switches
Reported-by: Ran Benite <ran234@gmail.com>
Signed-off-by: Tiago Vignatti <tiago.vignatti@intel.com>
2011-12-19 01:08:16 +02:00
Tiago Vignatti 9e2be08418 compositor: first destroy backend routines and then display
I caught this when an evdev device fd was trying to trigger the main event
loop, which was already free'd and causing an invalid read.

Signed-off-by: Tiago Vignatti <tiago.vignatti@intel.com>
2011-12-19 01:07:52 +02:00
Tiago Vignatti c349e1d0b0 compositor-drm: destroy evdev driver properly when finishing compositor
Signed-off-by: Tiago Vignatti <tiago.vignatti@intel.com>
2011-12-19 01:07:37 +02:00
Tiago Vignatti 0db1d5f551 evdev: use a separate function for adding devices
Adds new function evdev_add_devices for adding udev devices. No
functional changes.

Signed-off-by: Tiago Vignatti <tiago.vignatti@intel.com>
2011-12-19 01:00:35 +02:00
Tiago Vignatti b303a1d3fc compositor: use wl_list_for_each_safe when destroying output
Was causing an invalid read when the output is in fact destroyed. That's only
visible (segfault on my machine) on drm compositor because it's the only
backend trying to finish correct the compositor.

Signed-off-by: Tiago Vignatti <tiago.vignatti@intel.com>
2011-12-18 22:27:40 +02:00
Juan Zhao 7bb92f0c03 Activate toplevel fullscreen and menu surfaces
Activate the toplevel, fullscrren and menu surfaces during mapping,
so that the launched applications can get the keyboard focus without
clicking on that window.
2011-12-15 11:31:51 -05:00
Kristian Høgsberg ef458246b0 desktop-shell: Animate surface opacity in zoom animation as well 2011-12-15 11:24:25 -05:00
Kristian Høgsberg 541e5557ac compositor: Implement surface global alpha
Just a small tweak to the shader and we can control the overall surface alpha.
2011-12-15 11:15:12 -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 7296e7984f compositor: let shell override idle time
Move idle_time variable to struct wlsc_compositor, so that a shell
plugin can change it. Also store the original value from the command
line.

Add "duration" option to the desktop-shell screensaver config. This is
the time the screensaver will be visible, after idle timeout triggers
another time and blanks the screen.

Now you can have different delays to lock the screen, and switch off the
screen while a screensaver is running.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-12-14 13:50:35 +02:00
Pekka Paalanen e955f1edd1 shell: use desktop-shell ini file for screensaver path
Read the same configuration file in the shell plugin (desktop-shell) as
the desktop-shell client does.

Add a new section "screensaver", where "path" defines the path of the
idle animation client to be executed. Not defining "path" disables the
animation.

Idle animations are not in use by default. It must be configured in
wayland-desktop-shell.ini or launched manually.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-12-14 13:45:49 +02:00
Pekka Paalanen 18027e517a shell: automatic exec and kill of wscreensaver
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-12-14 13:45:33 +02:00
Pekka Paalanen bce2d3f9a7 compositor: add IDLE state
Add WLSC_COMPOSITOR_IDLE state to the possible compositor internal
states, and fix the drm backend to restore the previous state instead of
forcing ACTIVE.

Normally, the compositor only uses the ACTIVE and SLEEPING states. The
IDLE state is another active state, reserved for the shell, when the
shell wants to have unlock() calls on activity, but the compositor cannot
be SLEEPING.

Use the IDLE state to fix exposing the unlock dialog while a screensaver
is animating. Without this fix, is it impossible to activate the unlock
dialog without waiting for a second idle timeout that really puts the
compositor into SLEEPING.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-12-14 13:44:29 +02:00
Pekka Paalanen af0e34ce36 shell: center the unlock dialog
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-12-14 13:43:49 +02:00
Pekka Paalanen 2e097ee42a compositor: fix re-fading
Reorder code in fade_frame() to that if shell->lock() calls
wlsc_compositor_wake(), the fade animation will run again.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-12-14 13:43:42 +02:00
Pekka Paalanen baeb6a1dc1 shell: let screensaver wake up the compositor
Screensavers become visible the first time only after the compositor has
gone to sleep state. Therefore, to see screensaver in the start, wake up
the compositor. After a second idle timeout, the compositor will stay
sleeping.

We could also not apply this patch. It would mean the screensavers would
be visible only with the unlock dialog, and not become visible
automatically.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-12-14 12:56:15 +02:00
Pekka Paalanen 77346a66ec shell: implement screensaver surface type
Implement the basics of screensaver surface management. Exec'ing and
killing the screensaver client is punted for later.

When a surface registered as a screensaver is mapped, it stays hidden
if the screen is not locked, or it is added to the compositor visible
surfaces list if the screen is locked.

The map() is restructured to set initial position first, and stacking
next. This allows SHELL_SURFACE_SCREENSAVER share positioning with
SHELL_SURFACE_FULLSCREEN, while show_screensaver() does its own
wlsc_surface_configure() call.

Also fix centering to the given fullscreen output, not the first output.

Another bug fix: previously configure() would call
wlsc_surface_configure() unconditionally, which assigns an output to
the surface. While the compositor is locked, if an application resizes
its window, we hit configure() and assign an output while the surface is
not in compositor->surface_list. This leads to invalid memory access on
the next call to wlsc_surface_damage_below(). Fix this by not calling
wlsc_surface_configure() for surfaces that are not visible.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-12-14 12:51:01 +02:00
Pekka Paalanen 9826223a1b shell: handle surface type reassignment
So far nothing prevented a client for registering a surface as one type
and then as another type. With some special types, this would lead to
corrupted wl_lists.

Add a function, that either resets the surface type or posts an error to
the client. In case of an error, the set type operation must be aborted.

Change the type name SHELL_SURFACE_NORMAL to SHELL_SURFACE_NONE, as
there is nothing normal in the "none" type which just means uninitialised.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-12-14 12:27:47 +02:00
Pekka Paalanen 696f959a4b wscreensaver: implement screensaver interface
Create instances from outputs, and register the surfaces as
screensavers. Support multiple "Mode" instances.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-12-14 11:23:28 +02: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 6e16811e5e protocol: add screensaver interface
Add the screensaver interface to the desktop-shell protocol file. Also
add stubs for it in the compositor, and make wscreensaver to bind to the
screensaver interface. Wscreensaver gets a new option --demo to retain
the current behaviour as a regular wayland client.

When a screensaver application starts, it should bind to the screensaver
interface, enumerate all outputs, create a surface per output, and
register those surfaces via screensaver::set_surface request. Then it
continues with the usual animation loop, waiting for frame events. The
compositor will decide, when the given screensaver surfaces are
displayed. A screensaver application should respond to outputs coming
and going away by creating and destroying surfaces.

The compositor is supposed to activate a screensaver by exec'ing it, and
stop the screensaver by killing the client process. Only one client may
be bound to the screensaver interface at a time. If there already is a
client, the compositor could either kill it first, or not exec a new
one.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-12-14 11:17:00 +02:00
Tiago Vignatti 12c05b74ad evdev: run flush_motion only when needed
Signed-off-by: Tiago Vignatti <tiago.vignatti@intel.com>
2011-12-12 13:00:03 +02:00