Commit Graph

255 Commits

Author SHA1 Message Date
Kristian Høgsberg eae5de7609 Follow wayland change to serial numbers 2012-04-11 22:42:15 -04:00
Benjamin Franzke 78db848196 compositor: Damage output in weston_output_init
So that hotplugged outputs are marked damaged initially.
2012-04-10 18:51:49 +02:00
Benjamin Franzke b687940cd5 compositor: Remove wl_output-global on unplug
Or we would segfault when a client binds to a output thats already
destroyed.
2012-04-10 18:51:15 +02:00
Kristian Høgsberg 035dd9c4de compositor: End keyboard grab when compositor loses keyboard focus 2012-04-10 00:35:15 -04:00
Kristian Høgsberg 31dd6b86c1 compositor: Don't pass output to notify_keyboard_focus
Doesn't make sense and was only used to distinguish between enter/leave.
2012-04-10 00:04:22 -04:00
Benjamin Franzke bfeda130de Introduce weston-launch
weston-launch starts weston and provides mechanism
for weston to set/drop drm master, open a tty,
and read input devices without being root.

Execution is allowed for local-active sessions
or users in the group weston-launch.
2012-04-06 14:01:19 +02:00
Kristian Høgsberg 875ab9e735 Add signedness warning flag and fix fallout 2012-03-30 11:52:39 -04:00
Kristian Høgsberg dbae80e6b5 compositor: Support alpha for solid color surfaces 2012-03-29 11:34:39 -04:00
Jonas Ådahl c97af923d9 Properly dispose event sources and event loops
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2012-03-28 23:00:08 -04:00
Kristian Høgsberg fb6de223b2 compositor: Use GL_EXT_unpack_subimage for texture updates 2012-03-27 17:10:20 -04:00
Kristian Høgsberg 8cbfb2a40a compositor: Rename weston_buffer_attach to weston_surface_attach
This was always an operation on the surface, not the buffer.
2012-03-27 17:05:06 -04:00
Ander Conselvan de Oliveira 7fb9f95dce compositor: move force_configure field to shell_surface 2012-03-27 16:36:54 -04:00
Ander Conselvan de Oliveira 093bfa3793 compositor: make surface_configure() a vfunc
This allows us to move the logic that calls shell->map() or
shell->configure() into shell while allowing it to be overriden for
surfaces that should not be handle by the shell, such as drag icons.

This patch adds a pointer function called configure to weston_surface,
moves the currsent surface_configure() code into shell and implements
a separate configure() for drag surfaces.
2012-03-27 16:36:53 -04:00
Ander Conselvan de Oliveira e11683aab2 compositor: refactor surface_attach()
surface_attach() does two things: sets up a new buffer as the contents
of the given surface and then calls into shell so it can setup the
position of the surface and map it if necessary. However we do not want
the shell to meddle with some internal surfaces such as drag surfaces.

The intention of this refactoring is to make room for making the part
that calls into shell a virtual function that the compositor can
override for these internal surfaces.

This changes weston_buffer_attach() so it handle all the logic of tying
a buffer to a surface, including unmapping it when the buffer is NULL.
The shell map() vs. configure() logic is then split into a another
function: surface_configure(). In a later commit, this function will be
turned into a function pointer in struct weston_surface.
2012-03-27 16:36:53 -04:00
Ander Conselvan de Oliveira d6ea33dfd6 compositor: use new drag icon listener for setting up drag surfaces
That way we can get rid of the call to
weston_compositor_update_drag_surfaces() on shell->map().
2012-03-27 16:36:53 -04:00
Ander Conselvan de Oliveira 9390ae3ed1 compositor: make es->pitch consistent between shm and drm surfaces
For shm buffers, es->pitch is set using the stride of the buffer. If
the shell happened to set the surface width to something different than
the buffer width, the contents of the surface would be cropped on the
width during redraw. However, for non-shm surfaces, es->pitch was set to
the surface width. That caused the contents of the buffer to be scaled
on the width when the buffer was wider than the surface.

This makes the behavior on both cases the same: crop on the width and
scale on the height. (which is weird but consistent)
2012-03-27 16:36:53 -04:00
Ander Conselvan de Oliveira fbf2894812 compositor: add weston_surface_to_global_float helper 2012-03-27 16:36:53 -04:00
Ander Conselvan de Oliveira b8ab14fe04 compositor: add a weston_surface_is_mapped() helper 2012-03-27 16:36:53 -04:00
Kristian Høgsberg f9247ddc31 compositor: Use GL_BGRA_EXT for glReadPixels in screenshooter
This needs GL_EXT_read_format_bgra.
2012-03-27 15:59:46 -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
Tiago Vignatti 9a206c4da5 config-parser: consolidate shell files into weston.ini only
The shell choice happens in the configuration file now.

Signed-off-by: Tiago Vignatti <tiago.vignatti@intel.com>
2012-03-25 08:49:30 -04:00
Scott Moreau 6a3633d2bb Modify bindings for axis event detection. 2012-03-22 11:03:41 -06:00
Scott Moreau 210d079817 Hook up axis events. 2012-03-22 11:03:41 -06:00
Kristian Høgsberg afee221ccb compositor: Fix pointer type mismatch warnings 2012-03-20 22:43:56 -04:00
Juan Zhao 46436618d8 weston_surface: initialize pitch
Initializing pitch to 1 to avoid xxx/pitch errors
This won't influence the valid texture coordinate calculation, because
 in that case buffer_attach will provide the correct value.
2012-03-20 22:43:56 -04:00
Bill Spitzak 027b962d8c weston: don't hang in wait()
Pausing weston (with ^Z in the shell) and putting it in the background
made it hang.
2012-03-20 22:43:56 -04:00
Ander Conselvan de Oliveira 71b1d0c91d compositor: properly restore keyboard_focus in notify_keyboard_focus()
Commit f992b2fc removed the saved keyboard focus logic to fix a crash
when the saved surface is destroyed. However, setting keyboard focus to
the first surface on the list ends up trying to set the focus to the
cursor surface most of the time. The end result is a NULL keyboard
focus.

This patch restores the saved keyboard focus logic and fixes the crash
mentioned above using a destroy listener.
2012-03-20 22:43:55 -04:00
Ander Conselvan de Oliveira 96b0abd88a compositor: allow multiple input_device_attach()'s with a nil buffer
Without this change, weston would crash whenever a nil buffer was
passed to input_device_attach() if the cursor sprite was not mapped.
While at it, change the unmapping code to use weston_surface_unmap().
2012-03-20 22:43:55 -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
Kristian Høgsberg aa6019e125 Fix picking crashes
The surface list is only valid after repaint, so we need to do picking and
input delivery there.
2012-03-12 01:28:50 -04:00
Benjamin Franzke 0eee939d76 compositor: Fix compilation without xserver launcher 2012-03-08 13:15:02 -05:00
Kristian Høgsberg 7dbf5e2ea7 compositor: Only process input once per frame
When we're repainting, there's no point in polling for input events.
We just read input events once before each repaint and send out events
as needed.  The input events come with an accurate timestamp, so this
doesn't affect the timing information and client should always look at
the event timestamps if they're trying to determine pointer motion
speed or double click speed.  If we go idle (stop repainting) we add the
input devices back into the primary main loop and wait for the next event.

This avoids waking up the compositor separately (one or more times per
frame) to handle input events.  We also avoid updating cursor position
and other compositor state after the client has rendered its new
frame, reducing lag between what the client renders and the pointer
position.
2012-03-05 19:50:15 -05:00
Kristian Høgsberg 7ea10864c2 compositor: Move input devices to their own event loop
First step towards only handling input at repaint time.
2012-03-05 18:06:08 -05:00
Kristian Høgsberg abcef3cf7a compositor: Swallow binding key for bindings that don't set up a grab
This prevents passing the key press and release to the keyboard focus client.
2012-03-05 17:47:15 -05:00
Kristian Høgsberg d3c0275b14 Use wl_array_for_each() where possible 2012-03-04 22:35:47 -05:00
Kristian Høgsberg 0b5cd0cb4c Use typesafe server-side stubs 2012-03-04 21:57:37 -05:00
Kristian Høgsberg 525696851e compositor: Damage sprite surface on attach
Normally the client is responsible for damaging the surface after attach,
but the sprite surface is an internal surface.
2012-03-01 17:33:52 -05:00
Kristian Høgsberg 867dec7ff0 compositor: Post keyboard leave before destroying surface
We may want to move this into wayland-server.
2012-03-01 17:33:51 -05:00
Ander Conselvan de Oliveira 3e3bb3216e compositor: split drag surface update into smaller functions 2012-03-01 17:33:51 -05:00
Ander Conselvan de Oliveira c5fb9a7de9 compositor: fix crash when a drag surface is destroyed during the drag
This can happen for instance if the client that started the drag
crashes. Weston would crash because of the invalid surface pointed by
device->drag_surface.

Fix this by reseting the drag surface to nil on a destroy listener.
2012-03-01 17:33:51 -05:00
Kristian Høgsberg 3be2ce9e49 compositor: Organize surface stack using new struct weston_layer
The surface data structure is now a list of list of surfaces.  The core
compositor defines the fade and cursor layer, and it's up to the shell to
provide more layers for the various surface types it implements.
2012-03-01 17:33:51 -05:00
Kristian Høgsberg 944236a712 compositor: Just damage compositor->damage in weston_output_damage() 2012-03-01 12:47:23 -05:00
Kristian Høgsberg 1e8321213d compositor: Implement damage_below by using the new compositor->damage
We can now clip the surface bounding box against the previous frame
opaque clip, and then just union the result (visible damage) into
compositor->damage immediately.
2012-03-01 12:47:23 -05:00
Kristian Høgsberg 6ddcdaeb98 compositor: Store opaque clip for previous frame in weston_surface 2012-03-01 12:47:23 -05:00
Tiago Vignatti 8e53c7f566 compositor: add dpms and backlight support
DPMS kicks in only when wscreensaver is launched, in the moment that shell
call lock() for the second time. Backlight control internals are managed by
libbacklight:

	http://cgit.freedesktop.org/~vignatti/libbacklight/

Signed-off-by: Tiago Vignatti <tiago.vignatti@intel.com>
2012-02-29 14:01:56 -05:00
Kristian Høgsberg 9b154fa82b compositor: Insert dnd icon surface below device sprite surface 2012-02-29 12:52:32 -05:00
Kristian Høgsberg 9bc7095a78 compositor: Set an empty input region for the fade surface
Otherwise we don't set the cursor until the fade is done.
2012-02-29 12:52:32 -05:00
Ander Conselvan de Oliveira 90fbbd74cc compositor: make the input region of drag surfaces empty
With the input region changes, drag surfaces were being picked and
receiving events which led to problems on the client side.
2012-02-28 14:34:53 -05:00
Kristian Høgsberg 3b4af20100 compositor: Dont set the opaque region if we have an overall surface alpha 2012-02-28 09:23:23 -05:00
Alex Wu 8811bf9e8d compositor: Export functions and add weston_suface::force_configure for fullscreen
This will facilitate the implementation of fullscreen.

Signed-off-by: Alex Wu <zhiwen.wu@linux.intel.com>
2012-02-28 09:00:10 -05:00
Kristian Høgsberg d15fbe334a compositor: Remove surface overlapped attribute
We need to compute this as we assign surfaces to overlays, so that
if we assign a surface to an overlay, it isn't considered overlapping.
2012-02-23 23:06:13 -05:00
Kristian Høgsberg d8bf90c150 Move weston_output_set_cursor into compositor-drm.c
First step towards moving hw cursor handling into compositor-drm.c a its
general overlay handling.
2012-02-23 23:03:14 -05:00
Jesse Barnes 5308a5e09b compositor: add an assign_planes hook to the output
This allows each output back end to optimize drawing using overlay planes
and cursors (yet to be integrated).  If a surface is assigned to a
plane, the back end should clear its damage field so that the later
repaint code won't look at it.
2012-02-23 17:55:10 -05:00
Scott Moreau 2493be40a3 Fix pointer position clipping. 2012-02-23 17:45:56 -05:00
Scott Moreau ccbf29dcb4 Introduce output zoom.
Ideally, we would want to use <modifier>+Scroll binding but that will have
to wait for axis events. For now we just use keybindings. Zoom in/out with
Super+Up/Down.
2012-02-23 17:45:49 -05:00
Kristian Høgsberg 4889154f5b compositor: Initialize destroy_listener_list for internal surfaces too
We use this to look up user data on the surface, so make sure the list is
always valid.
2012-02-23 17:38:33 -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 dd631c1c36 simple-touch: Update to enter/leave changes 2012-02-23 16:20:38 -05:00
Kristian Høgsberg 5e7e6f2a22 compositor: Implement opqaue and input regions 2012-02-23 16:14:27 -05:00
Ander Conselvan de Oliveira a2f1129d13 compositor: assign output to drag surfaces
Otherwise we endup with a surface that is mapped but with outtup nil.
2012-02-23 16:12:30 -05:00
Kristian Høgsberg 31f9d0e8de compositor: Remove redundant weston_surface_damage_below() calls
In the attach case we always end up calling weston_surface_damage_below()
through weston_surface_update_transform() if and only if we need it.
2012-02-19 22:46:13 -05:00
Kristian Høgsberg d0e2ef7779 compositor: Surface is unmapped when surface->output is NULL
surface->buffer can be NULL, which happens when a client destroys the
attached buffer.  Fixes list corruption on resize.
2012-02-19 22:15:21 -05:00
Kristian Høgsberg afa264c6b6 compositor: Don't run keybindings if we have a key grab 2012-02-19 18:57:35 -05:00
Scott Moreau ec286eb8e8 compositor: Setup for keyboard grabs. 2012-02-19 18:57:34 -05:00
Scott Moreau 447013d718 Track server changes. 2012-02-18 11:55:51 -05:00
Kristian Høgsberg 1cbf3262dd compositor: Move fullscreen_output to shell_surface 2012-02-17 23:49:07 -05:00
Kristian Høgsberg 323ee04505 compositor: Make weston_surface_damage_below_noupdate() the default
We never want to update the transform and then damage below.  Damage
below is always used to trigger a repaint where the surface used to be
so we need to record the damage before updating the transform.
2012-02-17 12:45:43 -05:00
Kristian Høgsberg 3b5ea3bc6f compositor: Move unmap logic to new function weston_surface_unmap() 2012-02-17 12:43:56 -05:00
Kristian Høgsberg 12bbf81456 compositor: Only delete surface texture if we have one 2012-02-17 12:15:27 -05:00
Kristian Høgsberg 101cb6560c compositor: Get rid of surface->visual 2012-02-17 10:45:16 -05:00
Ander Conselvan de Oliveira 30eebc7c21 compositor: implement drag'n'drop icons
Signed-off-by: Ander Conselvan de Oliveira <ander.conselvan.de.oliveira@intel.com>
2012-02-16 23:19:39 -05:00
Ander Conselvan de Oliveira e9e0515cec shell: update position of surfaces with type none on map()
Needed for implementing drag'n'drop icons. When a drag starts, the
compositor will position the top-left corner of the client supplied
icon surface at the cursor hotspot. On the first attach to that
surface, the client may want to reposition it but shell->map did not
take sx and sy parameters.

This changes shell->map interface to take sx and sy parameters and
change dekstop shell implementation to update the position of a
surface of type none according to those parameters. Since a surface
of type none won't actually be mapped, the effect of this change is
only visible for surfaces that are made visible by the compositor.

Signed-off-by: Ander Conselvan de Oliveira <ander.conselvan.de.oliveira@intel.com>
2012-02-16 23:19:39 -05:00
Ander Conselvan de Oliveira d595f65fe2 compositor: add a way to disable picking of client surfaces
Surfaces like drag'n'drop icons shouldn't receive events as a normal
surface but are still created by the client so add a way for the
compositor to enable or disable the picking of a client surface.

Signed-off-by: Ander Conselvan de Oliveira <ander.conselvan.de.oliveira@intel.com>
2012-02-16 23:19:39 -05:00
Ander Conselvan de Oliveira b63e3e0201 compositor: fix two crashs on surface_attach() with null buffer
The condition to return from surface_attach with a null buffer involves
es->output being non-null. However if a surface was just created this
field would be null and an attach of a null buffer would cause the
compositor to crash.

The other crash happened if surface_attach was called twice with a
null buffer after a valid buffer was attached to the surface. Since
es->buffer was not being set to NULL, surface_attach() would call
wl_list_remove(&es->buffer_destroy_listener.link) twice for the same
surface.

Signed-off-by: Ander Conselvan de Oliveira <ander.conselvan.de.oliveira@intel.com>
2012-02-16 23:19:39 -05:00
Pekka Paalanen 8fb8d3b1b5 compositor, shell: add and use weston_surface_set_position()
Another shorthand like weston_surface_configure().

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-02-13 13:03:59 +02:00
Tiago Vignatti 9d3935296c compositor: make functions static
I know it's hard to figure out what the shells or backends will be
using as internal API at this point but we can try to minimize the
amount of WL_EXPORT being used anyway.

[pq: redone due to my earlier changes]

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-02-13 11:52:24 +02:00
Pekka Paalanen f8c6aae688 compositor: remove redundant cursor damage calls
As weston_surface_update_transform() automatically applies before and
after damage on surface geometry change, we don't need to explicitly add
the same damage in motion_notify() for the cursor surface.

We still need the side-effect, that is scheduling a repaint.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-02-13 11:40:39 +02:00
Pekka Paalanen cc2f868b2e compositor: round off fractions
Round off fractions from non-transformed surface position coordinates.

Transformed surface moved by a client may have non-integer position
coordinates. That is required to prevent drifting on continuous
resizing.

We can round the position to integers when the surface is not (anymore)
transformed.

This change may fix a rounding inconsistency in the opaque region setup,
where the rectangle is initialised from the coordinates without explicit
rounding operation.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-02-13 10:34:04 +02:00
Pekka Paalanen f07cb5d5f0 compositor: move output assignment to update_transform
Move the call to assign an output from weston_surface_configure() to
weston_surface_update_transform().

As update_transform takes new geometry into use, it should also reassign
the output for the surface, but only if an output was already assigned.

Add explicit assing output calls to where we relied on
weston_surface_configure() unconditionally assigning the output.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-02-10 15:50:27 +02:00
Pekka Paalanen 730d87e6a6 compositor: move opaque tracking into transform
Move the surface opaque region setup from weston_surface_configure() to
weston_surface_update_transform(), so we have less reason to call
update_transform from configure. Opaque region depends on geometry,
after all.

Also move the opaque field from weston_surface to
weston_surface::transform to make this obvious.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-02-10 15:47:56 +02:00
Pekka Paalanen b45ac5eada compositor: clarify update_transform vs. repaint
Remove redundant weston_surface_update_transform() calls from within
output repaint paths, and add a comment that we need to rely on
surface->geometry.dirty == 0 within the repaint sub-functions.

Now that weston_surface_update_transform() does damage as needed, and
weston_output_repaint() explicitly calls update_transform, we can reduce
the updates in rotate_grab_motion() to simply scheduling a repaint. This
will guarantee that the change in rotation ends up on screen ASAP.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-02-10 15:47:56 +02:00
Pekka Paalanen 9651678070 compositor: let update_transform deal damage
weston_surface_update_transform() is similar to
weston_surface_configure() in that it changes the surface region on
screen. Unlike configure, update_transform forgets to deal damage at
all, yet it is the only place where we can do damage_below() as needed.

Add a damage_below call to deal damage for the old surface region only
when needed. This uses the cached state from surface->transform to get
the old region.

Add a damage call to deal damage for the new surface region, after
updating the cached state.

Add a repaint call, since we have changed the scene and should render it
out.

This change fixes the rotation not updating the screen properly.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-02-10 15:47:56 +02:00
Pekka Paalanen 1d5035c705 compositor: simplify weston_surface_damage_rectangle()
The non-transformed case looked a little odd, calling
weston_surface_to_global(), since it already tests for transform.enabled
and simply uses width, height for the box.

Streamline it, by open-coding weston_surface_to_global(), and avoiding
another call into weston_surface_update_transform(). This way it does
not look suspicious to me.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-02-10 15:47:56 +02:00
Pekka Paalanen 219b982ed0 compositor: use floats in computing bounding box
In surface_compute_bbox(), call surface_to_global_float() instead of
weston_surface_to_global(). This avoids the recursion:

weston_surface_update_transform()
  weston_surface_update_transform_enable()
    surface_compute_bbox()
       weston_surface_to_global()
         weston_surface_update_transform()

which might be non-obvious when reading the code.

Computing the min and max coordinates in floats, we can have a tight
rounding margin by using floor() and ceil().

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-02-10 15:47:56 +02:00
Pekka Paalanen ece8a016aa compositor: move surface_to_global_float() definition
Move surface_to_global_float() definition earlier in the file. No code
changes.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-02-10 15:47:56 +02:00
Pekka Paalanen 80fb08dc66 compositor: split weston_surface_update_transform()
Split two helper functions out of weston_surface_update_transform() to:
- make the code clearer
- update the bounding box properly even if transformation fails
- unify the return point

Also add a comment on what matrix.d[12] is.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-02-10 15:47:56 +02:00
Pekka Paalanen 9abf393bd8 compositor: split weston_surface_damage_below()
Extract the core into a function that does not call
weston_surface_update_transform() or schedule repaint.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-02-10 15:47:55 +02:00
Kristian Høgsberg aded1f6823 compositor: Don't destroy sprite surface, just hide it 2012-02-08 16:33:57 -05:00
Kristian Høgsberg 9b8a82bf6d Merge remote-tracking branch 'pq/transform-fixes2' 2012-02-07 11:08:03 -05:00
Kristian Høgsberg 546a812004 compositor-wayland: Add window border 2012-02-07 11:02:59 -05:00
Kristian Høgsberg eb764841a5 compositor: Drop setuid when launching clients 2012-02-07 09:52:40 -05:00
Pekka Paalanen 9f9aa1be50 compositor: fix transformed opaque surface repainting
Computing the real maximal opaque screen aligned rectangle of a
transformed surface is hard. Let's drop the opaque optimisation
instead.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-02-06 16:26:57 +02:00
Pekka Paalanen ddae03cf9b compositor: q&d solution for surface drift
When a transformed (rotated) surface is continuously resized from its
top-left corner, its location will drift. This is due to accumulating
rounding errors in transforming an offset from surface-local to global
coordinates in surface_attach().

Diminish the drift down to unobservable level by changing the
weston_surface global position from integer to float.

The offset transformation is now done without rounding. To preserve the
precision, wl_shell::configure() interface must use floats, and so does
weston_surface_configure(), too.

The con of this patch is that it adds inconsistency to the surface
position coordinates: sometimes they are floats, sometimes integers.
2012-02-06 14:54:20 +02:00
Pekka Paalanen c7b45f68e6 compositor: clear surface damage on draw
Commit a0d6dc4f26 lost one line of code in
the refactoring, and so did not reset the surface damage on repaint
anymore. This causes damage to only accumulate, leading to a full
display redraw every cycle and hiding damage tracking issues.

Put the damage clear back.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-02-06 12:20:02 +02:00
Pekka Paalanen f55f544e4f compositor: fix and simplify shader uniform handling
The uniform location variables should be signed, according to the OpenGL
ES 2 specification. Moreover, GL_NONE, i.e. 0, is not an invalid nor
special location; it is actually used as a valid uniform location.

Change struct weston_shader uniform members to signed.

Stop using 0 for identifying a non-existing uniform, use -1 instead.
Furthermore, as the spec says a) glGetUniformLocation() will return -1
for non-active/existing uniforms, and b) glUniform*() function will
simply ignore all calls with location -1, we can simplify the code. We
don't have to avoid locating uniforms that don't exist, and we don't
need to test for them in weston_surface_draw() either.

Remove the micro-optimisation that avoids setting 'alpha' uniform if it
has not changed, in the name of simplification.

Unify shader creation by dropping init_solid_shader(), and calling
weston_shader_init() instead. The downside is that we compile the vertex
shader twice at startup now.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-02-02 16:49:05 +02:00
Kristian Høgsberg 0452abc820 compositor: Don't just update uniforms when we change shaders
The uniforms change from surface to surface or output to output, so always
set them.
2012-01-31 15:38:43 -05:00
Pekka Paalanen a4f80f34e2 compositor: handle attach request in surface-local coordinates
The x, y offsets in attach request are in surface-local coordinates, as
that is the only coordinate system the clients know about. The offset
must be transformed to global coordinate system to be applied properly.

This approximately fixes the top-left resizing of transformed surfaces.
However, it suffers from drift due to accumulating rounding errors in
continuous resizing.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-01-31 13:12:11 +02:00
Kristian Høgsberg d1e8625df2 compositor: Allow attaching null buffer
Attaching a null buffer is allowed and takes the surface back to the
unattached state it starts in.
2012-01-30 09:10:17 -05:00
Kristian Høgsberg 18c93009c1 compositor: Only set surface geometry through weston_surface_configure()
There are too many things to keep track of now, so let's require going
through this.
2012-01-27 11:58:31 -05:00
Pekka Paalanen d581a8fcc8 Collabora copyright updates
which I forgot to add while working on these files.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-01-27 16:26:17 +02:00
Pekka Paalanen 15d60efee9 compositor: make overlap computation use the boundingbox
This makes the overlap to account for surface transformations.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-01-27 16:15:02 +02:00
Pekka Paalanen 2267d45f7c compositor: use bounding box for damage regions
Change weston_surface_damage*() functions to use the full surface
bounding box or call surface_compute_bbox() to find the bounding box for
an arbitrary rectangle.

This should fix all rendering artifacts for non-opaque (i.e. ARGB)
transformed surfaces.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-01-27 16:15:02 +02:00
Pekka Paalanen 45f3e405c6 compositor: weston_surface_assign_output() to use bounding box
Use the bounding box to compute an approximation of which output
contains most of the surface.

Move the region32 init outside the loop, and fini it, too.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-01-27 16:15:02 +02:00
Pekka Paalanen 3bfcd4d907 compositor: weston_output_set_cursor() to use bounding box
If we ever have transformed cursor surfaces, we would better use the
bounding box to check if it is on the given output.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-01-27 16:15:02 +02:00
Pekka Paalanen a9f8a21c75 compositor: weston_surface_draw() to use bounding box
Use the proper bounding box in clipping the surface repaint area. Fixes
excessive clipping for transformed surfaces.

Also don't leak the region32 on early return.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-01-27 16:15:02 +02:00
Pekka Paalanen 60921e5787 compositor: move weston_surface::width,height into geometry
weston_surface::transform.boundingbox depends on width and height, and
therefore geometry.dirty flag, so move width and height into geometry.

Fix all users and check that the dirty flag is set.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-01-27 16:15:02 +02:00
Pekka Paalanen 6720d8f3bd compositor: add weston_surface bounding box
Compute a surface bounding box, especially for transformed surfaces, for
which one cannot simply use x,y,width,height.

The bounding box depends on width and height, so these are now under the
geometry.dirty flag.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-01-27 16:15:02 +02:00
Pekka Paalanen ba3cf95c0e compositor: move weston_surface::x,y into geometry
weston_surface::transform.position depends on x,y, and therefore the
dirty flag, so move x and y into geometry.

Also add the missing dirty flags.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-01-27 16:15:02 +02:00
Pekka Paalanen cd40362bba compositor: make position a surface transformation
Put the surface translation (absolute position) into the surface
transformations list. This allows to set additional transformations
before and after the global translation.

Having the translation cached, changing the surface x,y now requires to
set the geometry.dirty flag.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-01-27 16:15:02 +02:00
Pekka Paalanen 0e151bb487 compositor: honour repaint regions with transformed surfaces
Previously, if a surface was transformed, it repainted as a whole,
regardless of the computed repaint region. As damage regions determine
repaint regions and whether a surface is considered for drawing at all,
this lead to disappearing surfaces if all surfaces were considered
transformed. Also transparent transformed surfaces were redrawn without
the surfaces below being properly redrawn, leading to alpha-saturation.

Fix that by making texture_region() use the proper global-to-surface
coordinate transformation for texture coordinates. This makes it
possible to call texture_region() also for transformed surfaces.

As texture coordinates may now lie outside the valid texture image, the
fragment shader is modified to check the fragment texture coordinates.

The special path texture_transformed_surface() is no longer used and is
removed.

This change fixes many of the rendering artifacts related to transformed
surfaces.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-01-27 16:15:02 +02:00
Pekka Paalanen 3df327f4c9 compositor: disable attrib arrays after use
Not strictly necessary right now, but nice to clean up.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-01-27 16:15:02 +02:00
Pekka Paalanen e0f3cb25e8 compositor: rewrite draw and input coordinate transformations
For unifying the coordinate system handling, introduce functions for
converting explicitly between the global and the surface local
coordinate systems.

Use these functions in the input path, replacing
weston_surface_transform().

In the draw path, rewrite transform_vertex() to take in surface local
coordinates.

As shell now uses the new functions, the rotation origin is properly
placed in the middle of the surface.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-01-27 16:15:02 +02:00
Pekka Paalanen bc0b7e7756 compositor: restructure weston_surface::transform
Separate mutable data and cached immutable data in struct
weston_surface.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-01-27 16:15:02 +02:00
Pekka Paalanen 7ae02130bd compositor: handle non-invertible surface transformations
Detect a non-invertible surface total transformation, disable it, and
warn about it.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-01-27 16:15:02 +02:00
Pekka Paalanen 460099f143 shell: add key binding for rotating a surface
Add the key binding Super+Alt+MouseLeftButton to start rotating a
surface by dragging. The rotation is removed, when the drag is near the
rotation origin.

Rotated surface are a stress test for input event coordinate
transformations, damage region tracking, draw transformations, and
window move and resize orientation.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-01-27 16:15:02 +02:00
Pekka Paalanen 2a5ceccd57 compositor: apply full transformation to input coordinates
When converting input coordinates from global to surface-local system,
apply the full inverse surface transformation instead of just
translation.

Move weston_surface_update_transform() implementation realier in the
file, no changes.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-01-27 10:55:27 +02:00
Pekka Paalanen d1f0ab6343 compositor: simplify the matrix inversion API
The compositor will likely do an order of magnitude less matrix
inversions than point transformations with an inverse, hence we do not
really need the optimised path for single-shot invert-and-transform.

Expose only the computing of the explicit inverse matrix in the API.

However, the matrix inversion tests need access to the internal
functions. Designate a unit test build by #defining UNIT_TEST, and
export the internal functions in that case.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-01-27 10:44:22 +02:00
Pekka Paalanen 75b47ec45d compositor: implement inverse matrix transformation
Implement 4x4 matrix inversion based on LU-decomposition with partial
pivoting.

Instead of simply computing the inverse matrix explicitly, introduce the
type struct weston_inverse_matrix for storing the LU-decomposition and
the permutation from pivoting. Using doubles, this struct has greater
precision than struct weston_matrix.

If you need only few (less than 5, presumably) multiplications with the
inverse matrix, is it cheaper to use weston_inverse_matrix, and not
compute the inverse matrix explicitly into a weston_matrix.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-01-27 10:44:22 +02:00
Pekka Paalanen 061b7471f1 compositor: drop inverse matrix from weston_transform
Remove the inverse matrix member from struct weston_transform. It is
easier (and probably faster, too) to create and store only forward
transformation matrices in a list, multiply them once, and then invert
the final matrix, rather than creating both forward and inverse
matrices, and multiplying both.

Add a stub for the 4x4 matrix inversion function.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-01-27 10:44:22 +02:00
Pekka Paalanen c61eca6002 compositor: implement a stack of surface transformations
Having at most one transformation object attached to a surface is not
enough anymore. If we have a surface that needs to be scaled to
fullscreen, and then we have the zoom animation, we already need two
transformations combined.

Implement support for multiple transformations by adding a transformation
list. The final transformation is the ordered composite of those in the
list. To avoid traversing the list every single time, add a dirty flag,
and cache the final transformation.

The existing transformation users (only zoom) are converted.

Note: surface drawing should honour all kinds of transformations, but
not damage region code nor input event translating code take
transformations into account, AFAICT. Therefore anything but translation
will probably behave badly until they are fixed.

Cc: Juan Zhao <juan.j.zhao@linux.intel.com>
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-01-27 10:43:49 +02:00
Kristian Høgsberg 681f9f4149 compositor: Keep fade surface around while we're fading
This removes more special cases from weston_output_repaint() and we
avoid creating and destroying the surface for each animation frame.
We gain another special case in weston_compositor_top(), but that's
less of a problem, and we'll fix that later.
2012-01-26 10:59:33 -05:00
Kristian Høgsberg 607c1a769d compositor: Use weston_surface_create for creating solid color fade surface 2012-01-26 10:47:11 -05:00
Kristian Høgsberg bbeefb0189 compositor: Create surfaces neutral, select shader later
We only setup the shader and create the texture once we attach a buffer
or set a color.
2012-01-26 10:00:23 -05:00
Kristian Høgsberg 46e64ee3e1 compositor: Drop unused saved_texture surface field 2012-01-26 09:28:42 -05:00
Kristian Høgsberg 2200d70e56 compositor: Clear repaint_scheduled when an idle repaint is cancelled
We don't hit this case often, but if we did, the compositor would get stuck
thinking a repaint was already scheduled.
2012-01-26 08:47:04 -05:00
Kristian Høgsberg 30c018be3a compositor: Combine repaint and weston_output_repaint
Fewer repaint functions is better.
2012-01-26 08:40:37 -05:00
Kristian Høgsberg a82c4860a1 compositor: Compute overlapped early and base hw cursor decision on that 2012-01-26 01:03:58 -05:00
Kristian Høgsberg 9f404b7ac8 compositor: Move tracking of scanout buffers to compositor-drm 2012-01-26 00:11:01 -05:00
Kristian Høgsberg 5f5e42ef50 compositor: Remove prepare_scanout_surface callout
For the drm backend, we just refactor setup_scanout_surface into
drm_output_prepare_scanout_surface and call it from drm_output_repaint.
2012-01-25 23:59:44 -05:00
Kristian Høgsberg 06cf6b0238 compositor: Pull prepare_render and present callouts into repaint
This dramatically simplifies the backend repaint abstractions and paves
the way for moving overlay and cursor setup into the backend.
2012-01-25 23:47:45 -05:00
Kristian Høgsberg 68c479af05 compositor: Move repaint loop into a backend function
We've trimmed down the actual repaint loop to just iterating through the
surface list and calling weston_surface_draw(), so we push that to the
backend without too much code duplication.
2012-01-25 23:32:28 -05:00
Kristian Høgsberg 32cdc384f4 compositor: Insert the fade surface in the surface list
This lets us repaint it in the repaint loop instead of the fade_output()
special case.
2012-01-25 23:16:38 -05:00
Kristian Høgsberg 0763262e3d compositor: Move shader setup to weston_surface_draw() 2012-01-25 23:02:06 -05:00
Kristian Høgsberg 765bcdf1fa compositor: Compute whether or not a surface is overlapped 2012-01-25 22:20:30 -05:00
Kristian Høgsberg ee324c20ed compositor: Remove special casing of fullscreen surfaces
This was supposed to draw black borders around a fullscreen surface that
was smaller than the output.  We don't want to special case that in the
repaint loop, but may use a different shader or such.  And we want the
surface to have an opaque region that covers the output so that that
will eliminate overdraw of lower surfaces.
2012-01-25 22:09:10 -05:00
Kristian Høgsberg a0d6dc4f26 compositor: Do the per surface clip region math in weston_surface_draw() 2012-01-25 22:02:00 -05:00
Kristian Høgsberg ac58741940 compositor: Assign surface damage before setting up scanout buffers 2012-01-25 21:48:26 -05:00
Kristian Høgsberg bcecca49b8 Revert "weston: Drop priviledges early, and seteuid when needed"
This reverts commit fc6ccb868f.

We still need root permissions for drmDrop/SetMaster.  Without
integration with ConsoleKit or systemd we also don't have access
to /dev/dri/cardX in the case where we open a new VT.
2012-01-24 12:41:19 -05:00
Benjamin Franzke fc6ccb868f weston: Drop priviledges early, and seteuid when needed 2012-01-24 11:26:41 -05:00
Pekka Paalanen 8423a89d41 compositor: initialise segv_action.sa_mask
Valgrind complained sa_mask member is not initialised, fix that.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-01-19 10:19:02 -05:00
Kristian Høgsberg 90b53815ba compositor: Flush surface damage to surface below on destroy
When we destroy a surface, we damage the surface below so that the area
exposed by the disappearing surface will be repainted.  However, if that
surface also is destroyed, the damage information is lost and we fail to
repaint that area.

This commit introduces weston_surface_flush_damage(), which flushes the
surface damage the the surface below when a surface is destroyed.  When
multiple surfaces are destroyed at the same time, the damage now accumulates
and sinks down through the surface stack as it should.
2012-01-18 21:41:37 -05:00
Kristian Høgsberg 34f80ff813 drm: Cancel any scheduled repaints in the leave vt handler
If we don't cancel the repaint, we end up pointlessly redrawing the output.
What's worse is that pageflipping to the new buffer eventually fails and
we miss the finish_frame callback, leaving the compositor stuck when we
re-enter the vt.
2012-01-18 11:50:31 -05:00
Kristian Høgsberg 0690da60d4 compositor: Install a SEGV handler to try and clean up the VT if we crash 2012-01-16 11:54:30 -05:00
Kristian Høgsberg 1760ebb236 xserver: Set DISPLAY for clients launched by the compositor 2012-01-15 16:04:33 -05:00
Kristian Høgsberg 8e81df4503 Use new format codes 2012-01-11 14:24:46 -05:00
Kristian Høgsberg 249713bbe0 Remove redundant glTexImage2D() call
When we later upload the cursor image with glTexImage2D(), that will unbind
the image just fine.  No need for a NULL upload.  Except that that doesn't
currently happen with mesa drivers, but the NULL upload is redundant either
way.
2012-01-06 15:24:59 -05:00
Kristian Høgsberg c5e2376d3f compositor: Damage below before attaching new buffer 2012-01-06 14:37:19 -05:00
Kristian Høgsberg dade64968c Move wl_data_device implementation to wayland-server 2012-01-06 11:28:53 -05:00
Kristian Høgsberg faf1fee64f Move default grab implementation to wayland-server 2012-01-05 11:00:01 -05:00
Kristian Høgsberg 9ddb826077 Use new grab api 2012-01-05 11:00:01 -05:00