1
0
Fork 0
Commit graph

277 commits

Author SHA1 Message Date
Neil Roberts
f1752ff3ba Avoid mixing declarations and code
Mixing declarations and code causes problems for MSVC as it is a C99
feature so we should try to avoid it.
2010-10-25 13:18:25 +01:00
Neil Roberts
8e3674dcc1 Avoid variable length arrays in clutter-backend-x11
There was an array whose length was define by a static const int
variable. GCC seems to consider this a variable-length array so it
will cause warnings now that -Wvla is enabled. We might as well make
this constant a #define instead to avoid the warning.
2010-10-25 13:18:25 +01:00
Emmanuele Bassi
46c597a1f6 Clean up clutter-private.h/6
Move all Actor private API to a separate file.
2010-10-21 12:22:17 +01:00
Emmanuele Bassi
cf3a29f224 Clean up clutter-private.h/5
Move PaintVolume private API to a separate header.
2010-10-21 12:22:17 +01:00
Emmanuele Bassi
43edfc9400 Clean up clutter-private.h/4
Move the private Backend API to a separate header.

This also allows us to finally move the class vtable and instance
structure to a separate file and plug the visibility hole that left
the Backend class bare for everyone to poke into.
2010-10-21 12:22:17 +01:00
Emmanuele Bassi
8613013ab0 Clean up clutter-private.h/3
Move Stage private API to a separate header.
2010-10-21 11:33:26 +01:00
Emmanuele Bassi
c1771d152e Clean up clutter-private.h/1
Move DeviceManager/InputDevice private API to a different header.
2010-10-21 10:54:14 +01:00
Emmanuele Bassi
dd2f55c6f6 x11: Protect XComposite API calls
Since we allow compiling Clutter without the XComposite extension
available, we need to protect the calls to the XComposite API with
the guards provided by the configure script.
2010-10-19 10:43:50 +01:00
Emmanuele Bassi
8429aa8d75 Remove unnecessary GLib version checks
We now depend on a newer version of GLib than those checks tested for.
2010-10-18 11:26:45 +01:00
Robert Bragg
18e3273fb1 x11-tfp: Implement get_paint_volume virtual
One of the later changes made on the paint volume branch before merging
with master was to make paint volumes opt in only since we couldn't make
any safe assumptions about how custom actors may constrain their
painting. We added very conservative implementations for the existing
Clutter actors - including for ClutterTexture which
ClutterX11TexturePixmap is a sub-class of - but we were conservative to
the extent of explicitly checking the GType of the actor so we would
avoid making any assumptions about sub-classes. The upshot was that we
neglected to implement the get_paint_volume vfunc for
ClutterX11TexturePixmap.

This patch provides an implementation that simply reports the actor's
allocation as its paint volume. Also unlike for other core actors it
doesn't explicitly check the GType so we are assuming that all existing
sub-classes of ClutterX11TexturePixmap constrain their drawing to the
actor's transformed allocation. If anyone does want to draw outside the
allocation in future sub-classes, then they should also provide an
updated get_paint_volume implementation.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2349
2010-09-30 11:44:12 +01:00
Emmanuele Bassi
e36cc40a49 Merge branch 'wip/non-recursive'
* wip/non-recursive:
  build: Start moving to a non-recursive layout
2010-09-29 15:55:58 +01:00
Robert Bragg
771348b369 x11: minimize nasty artefacts when resizing windows
This is a workaround for a race condition when resizing windows while
there are in-flight glXCopySubBuffer blits happening.

The problem stems from the fact that rectangles for the blits are
described relative to the bottom left of the window and because we can't
guarantee control over the X window gravity used when resizing so the
gravity is typically NorthWest not SouthWest.

This means if you grow a window vertically the server will make sure to
place the old contents of the window at the top-left/north-west of your
new larger window, but that may happen asynchronous to GLX preparing to
do a blit specified relative to the bottom-left/south-west of the window
(based on the old smaller window geometry).

When the GLX issued blit finally happens relative to the new bottom of
your window, the destination will have shifted relative to the top-left
where all the pixels you care about are so it will result in a nasty
artefact making resizing look very ugly!

We can't currently fix this completely, in-part because the window
manager tends to trample any gravity we might set.  This workaround
instead simply disables blits for a while if we are notified of any
resizes happening so if the user is resizing a window via the window
manager then they may see an artefact for one frame but then we will
fallback to redrawing the full stage until the cooling off period is
over.
2010-09-29 15:12:59 +01:00
Robert Bragg
012e4ab153 x11: Queue clipped redraws for Expose events
Instead of triggering a full stage redraw for Expose events we use the
geometry of the exposed region given in the event to queue a clipped
redraw of the stage.
2010-09-29 15:12:59 +01:00
Robert Bragg
1ea7145efc Queue clipped redraws work in terms of paint volumes
There is an internal _clutter_actor_queue_redraw_with_clip API that gets
used for texture-from-pixmap to minimize what we redraw in response to
Damage events. It was previously working in terms of a ClutterActorBox
but it has now been changed so an actor can queue a redraw of volume
instead.

The plan is that clutter_actor_queue_redraw will start to transparently
use _clutter_actor_queue_redraw_with_clip when it can determine a paint
volume for the actor.
2010-09-29 15:12:57 +01:00
Emmanuele Bassi
8dd8fbdbdf build: Start moving to a non-recursive layout
*** WARNING: THIS COMMIT CHANGES THE BUILD ***

Do not recurse into the backend directories to build private, internal
libraries.

We only recurse from clutter/ into the cogl sub-directory; from there,
we don't recurse any further. All the backend-specific code in Cogl and
Clutter is compiled conditionally depending on the macros defined by the
configure script.

We still recurse from the top-level directory into doc, clutter and
tests, because gtk-doc and tests do not deal nicely with non-recursive
layouts.

This change makes Clutter compile slightly faster, and cleans up the
build system, especially when dealing with introspection data.

Ideally, we also want to make Cogl part of the top-level build, so that
we can finally drop the sed trick to change the shared library from the
GIR before compiling it.

Currently disabled:

  ‣ OSX backend
  ‣ Fruity backend

Currently enabled but untested:

  ‣ EGL backend
  ‣ Windows backend
2010-09-29 14:40:15 +01:00
Robert Bragg
f5f066df9c Try to clean up how we handle actor transformations
When building actor relative transforms, instead of using the matrix
stack to combine transformations and making assumptions about what is
currently on the stack we now just explicitly initialize an identity
matrix and apply transforms to that.

This removes the full_vertex_t typedef for internal transformation code
and we just use ClutterVertex.

ClutterStage now implements apply_transform like any other actor now
and the code we had in _cogl_setup_viewport has been moved to the
stage's apply_transform instead.

ClutterStage now tracks an explicit projection matrix and viewport
geometry. The projection matrix is derived from the perspective whenever
that changes, and the viewport is updated when the stage gets a new
allocation. The SYNC_MATRICES mechanism has been removed in favour of
_clutter_stage_dirty_viewport/projection() APIs that get used when
switching between multiple stages to ensure cogl has the latest
information about the onscreen framebuffer.
2010-09-13 18:18:34 +01:00
Robert Bragg
bcf20955d3 ClutterX11TexturePixmap: Fix unbalanced error trapping
I think this is what commit 2cf1405506 intended to do since it
specifically mentioned cleaning up the trap in
clutter_x11_texture_pixmap_set_pixmap, but although it moved the untrap
to only be done in the case where Pixmap != None it left the position of
the trap itself unchanged. This meant the error trapping wouldn't be
balanced if pixmap == None since the untrap wouldn't be done. We now
only trap and untrap around the XGetGeometry call done when pixmap !=
None.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2303
2010-09-09 11:18:53 +01:00
Emmanuele Bassi
f8bd45dbce x11-texture-pixmap: Do not go through g_object_get()
The pixmap width and height are stored in our own private data
structure; going through g_object_get() is pointless overhead.
2010-09-08 17:39:04 +01:00
Owen W. Taylor
2cf1405506 Clean up CoglTexturePixmapX11 first
With currently distributed versions of Mesa, calling XFreePixmap()
before glxDestroyPixmap() will cause an X error from DRI. So, we
need to make sure that we get rid of the CoglTexturePixmapX11 before
we XFreePixmap().

clutter_x11_texture_pixmap_dispose(): Call
 clutter_x11_texture_pixmap_set_pixmap() instead of using XFreePixmap
 directly so that we leverage the text-clearing hack and destroy
 things in the right order.

clutter_x11_texture_pixmap_set_pixmap(): Don't do a pointless roundtrip
 and trap a pointless error when setting pixmap to None.

clutter_x11_texture_pixmap_set_pixmap(): Free damage resources when
 we are setting Pixmap to None.

clutter_x11_texture_pixmap_set_window(): When setting a new window
 or setting the window to None, immedediately  call
 cluter_x11_texture_pixmap_set_pixmap(). This means that set_window(None)
 immediately will free any referenced resources related to the window.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2303
2010-09-08 17:24:49 +01:00
Emmanuele Bassi
e4870ebaf4 Constify Event accessors and copy method
This is still C, but at least we can get some sort of safety net when
using the API correctly.
2010-09-08 15:15:57 +01:00
Emmanuele Bassi
ac6256ae60 docs: Add @Title to the X11TexturePixmap gtk-doc section 2010-08-28 21:17:23 +01:00
Neil Roberts
8d51617979 Conditionally use g_object_notify_by_pspec
This adds a wrapper macro to clutter-private that will use
g_object_notify_by_pspec if it's compiled against a version of GLib
that is sufficiently new. Otherwise it will notify by the property
name as before by extracting the name from the pspec. The objects can
then store a static array of GParamSpecs and notify using those as
suggested in the documentation for g_object_notify_by_pspec.

Note that the name of the variable used for storing the array of
GParamSpecs is obj_props instead of properties as used in the
documentation because some places in Clutter uses 'properties' as the
name of a local variable.

Mose of the classes in Clutter have been converted using the script in
the bug report. Some classes have not been modified even though the
script picked them up as described here:

json-generator:

 We probably don't want to modify the internal copy of JSON

behaviour-depth:
rectangle:
score:
stage-manager:

 These aren't using the separate GParamSpec* variable style.

blur-effect:
win32/device-manager:

 Don't actually define any properties even though it has the enum.

box-layout:
flow-layout:

  Have some per-child properties that don't work automatically with
  the script.

clutter-model:

  The script gets confused with ClutterModelIter

stage:

  Script gets confused because PROP_USER_RESIZE doesn't match
  "user-resizable"

test-layout:

  Don't really want to modify the tests

http://bugzilla.clutter-project.org/show_bug.cgi?id=2150
2010-08-10 17:12:06 +01:00
Emmanuele Bassi
fa54b7c60d docs: Further clarifications
Mention the XFixes extension for compositors using input regions to let
events "pass through" the stage.

Thanks to: Robert Bragg <robert@linux.intel.com>
2010-08-03 16:48:53 +01:00
Emmanuele Bassi
da6b2660ba docs: Clarify the event retrieval disable behaviour
When we disable the event retrieval, we now just disable the X11 event
source, not the event selection. We need to make that clear to
applications, especially compositors, which might expect complete
control over the selection.
2010-08-03 16:30:04 +01:00
Emmanuele Bassi
a20a509584 x11: Split out conditions and warnings
XGetGeometry is a great piece of API, since it gets a lot of stuff that
are moderately *not* geometry related - the root window, and the depth
being two.

Since we have multiple conditions depending on the result of that call
we should split them up depending on the actual error - and each of them
should have a separate error message. This makes debugging simpler.
2010-07-29 17:18:25 +01:00
Emmanuele Bassi
99d7d31318 docs: Improve the text of X11 event-related functions
We need to make sure that people disabling event handling in Clutter
call clutter_x11_handle_event() to update Clutter's internal state.
2010-07-22 10:48:21 +01:00
Emmanuele Bassi
eae4561929 Clean up the private flags for ClutterActor
Provide macros to quickly query a flag, and remove all namespacing
except the initial 'CLUTTER'.
2010-07-21 16:10:46 +01:00
Emmanuele Bassi
0dfbf010b8 x11: Add more checks to set_stage_foreign()
Check all the pre-requisites to avoid segfaults later on.
2010-07-21 15:21:08 +01:00
Emmanuele Bassi
8538e1bf58 x11: Clean up TexturePixmap header and private data structure
Align the header file and use bitfields instead of booleans.
2010-07-21 15:14:36 +01:00
Emmanuele Bassi
fd27ca7398 Mark property strings for translation
Both the nick and the blurb fields should be translatable, for UI
builders and other introspection-based tools.
2010-07-15 14:07:07 +01:00
Emmanuele Bassi
6c913aa55e x11: Use XKB to translate keycodes into key symbols
And fall back to XKeycodeToKeysym() if XKB is not available.
2010-07-13 11:54:44 +01:00
Emmanuele Bassi
1ea4c50041 x11: Use XKB to track the Locks state
For Caps Lock and Num Lock. Store the state of both in the
platform-specific per-event data structure. No accessors, yet.
2010-07-13 09:15:21 +01:00
Emmanuele Bassi
bf2f8d670d x11: Use XKB detectable auto-repeat
If we have XKB support then we should be using it to turn on the
detectable auto-repeat; this allows avoiding the peeking trick
that emulates it inside the event handling code.
2010-07-13 08:27:48 +01:00
Emmanuele Bassi
bea657d3d5 x11: Add a Keymap ancillary object
We should try to abstract everything that is related with the key mapping
to its own object, to avoid complicating ClutterBackendX11 any further.
2010-07-13 08:27:48 +01:00
Emmanuele Bassi
d345a61e6c x11: Store the group inside the event platform data
Now that we have private, per-event platform data, we can start putting
it to good use. The first, most simple use is to store the key group
given the event's modifiers. Since we assume a modern X11, we use XKB
to retrieve it, or we simply fall back to 0 by default.

The data is exposed as a ClutterX11-specific function, within the
sanctioned clutter_x11_* namespace.
2010-07-13 08:27:48 +01:00
Emmanuele Bassi
608a5a8ae6 x11: Clean up NET_WM_STATE modifiers
Use a separate function to avoid code duplication.
2010-07-07 14:52:19 +01:00
Emmanuele Bassi
eca398f113 x11: Do not swallow XSettings events
We might want pieces higher in the stack (like Mx) to handle XSettings
events as well, and swallowing them by removing them from the events
queue would make it impossible.
2010-07-07 14:52:19 +01:00
Chris Lord
8801c947d5 event: Typos in event code could cause crashes
A typo in clutter-event.c meant that the wrong struct location could be
used for the input device of key events. Also, a typo in the X11 event
code meant that key-presses would come from the pointer device (releases
would still come from the keyboard device).
2010-06-29 15:42:59 +01:00
Emmanuele Bassi
c81ef75942 x11: Add XSETTINGS watcher
If we want to be able to get live notification of system settings
changes, we need watch the window that the XSETTINGS client conjures
up for us.
2010-06-28 10:32:54 +01:00
Neil Roberts
5d860a9978 clutter-{glx,x11}-texture-pixmap: Use CoglTexturePixmapX11
The pixmap handling of both of the texture pixmap actors in Clutter is
now removed and instead it just creates a CoglTexturePixmapX11. Both
actors are now equivalent so there is no need to choose between the
two.
2010-06-22 12:22:48 +01:00
Neil Roberts
6ca13e54d8 Add -DCOGL_ENABLE_EXPERIMENTAL_API to Makefiles for Cogl and x11/glx
Cogl and Clutter should be able to use the experimental API so this
adds the required define to the CPPFLAGS in the Makefiles.
2010-06-22 12:22:47 +01:00
Neil Roberts
9cdcc155f3 Pass all Xlib events through Cogl
The Clutter X11 backend now passes all events through
_cogl_xlib_handle_event. This function can now internally be hooked
with _cogl_xlib_add_filter. These are added to a list of callbacks
which are all called in turn by _cogl_xlib_handle_event. This is
intended to be used internally in Cogl by any parts that need to see
Xlib events.

Cogl now also has an internally exposed function to set a pointer to
the Xlib display. This is stored in a global variable. The Clutter X11
backend sets this.

_cogl_xlib_handle_event and _cogl_xlib_set_display can be removed once
Cogl gains a proper window system abstraction.
2010-06-22 12:20:59 +01:00
Emmanuele Bassi
1eb7f57582 x11: Use the _clutter symbols for xsettings_* API
Instead of using the bare xsettings_* API; this maintains consistency.
2010-06-21 18:56:16 +01:00
Emmanuele Bassi
b470d6930d settings: freeze notification on XSETTINGS notify 2010-06-21 16:10:49 +01:00
Emmanuele Bassi
98c3c84c00 x11: Add the XSETTINGS machinery
Use the XSETTINGS machinery to get notification from foreign
environments about settings that might interest Clutter itself - namely:
the default font name, the font DPI, and the Xft font options that can
be mapped on cairo_font_options_t.
2010-06-21 15:55:36 +01:00
Emmanuele Bassi
b2c905ff50 Hide the marshallers
The marshallers we use for the signals are declared in a private header,
and it stands to reason that they should also be hidden in the shared
object by using the common '_' prefix. We are also using some direct
g_cclosure_marshal_* symbol from GLib, instead of consistently use the
clutter_marshal_* symbol.
2010-06-11 16:09:36 +01:00
Colin Walters
f0ded315e4 g_source_set_name on custom sources (if available)
Call g_source_set_name, if the versio of GLib is new enough.
This aids debugging, using e.g. SystemTap.  See
https://bugzilla.gnome.org/show_bug.cgi?id=620511
for more information

http://bugzilla.openedhand.com/show_bug.cgi?id=2151

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2010-06-07 12:05:24 +01:00
Damien Lespiau
ec59af290c analysis: None used in pointer context
While this is totally fine (None is 0L and, in the pointer context, will
be converted in the right internal NULL representation, which could be a
value with some bits to 1), I believe it's clearer to use NULL instead
of None when we talk about pointers.
2010-06-01 12:08:18 +01:00
Damien Lespiau
52a78a7220 analysis: FALSE/0 used in pointer context
While this is totally fine (0 in the pointer context will be converted
in the right internal NULL representation, which could be a value with
some bits to 1), I believe it's clearer to use NULL in the pointer
context.

It seems that, in most case, it's more an overlook than a deliberate
choice to use FALSE/0 as NULL, eg. copying a _COGL_GET_CONTEXT (ctx, 0)
or a g_return_val_if_fail (cond, 0) from a function returning a
gboolean.
2010-06-01 12:08:18 +01:00
Owen W. Taylor
f9072b8663 Call backend handle_event from clutter_x11_handle_event()
Whether events come from the main loop source or from
clutter_x11_handle_event(), we need to feed them to the backend
virtual handle_event function. This fixes problems with clients
using clutter_x11_handle_event() hanging because
GLXBufferSwapComplete events aren't received.

http://bugzilla.openedhand.com/show_bug.cgi?id=2101
2010-05-04 11:04:03 +01:00
Owen W. Taylor
6fcc8c5bce x11: Use has_allocation() in TfP actor
ClutterX11TexturePixmap calls get_allocation_box() when queueing a
clipped redraw. If the allocation is not valid, and if we queue a
lot of redraws in response to a series of damage events, the net
result is that we spend all our time in a re-layout. We can
short-circuit this by checking if the actor has a valid allocation, and
if not, just queue a redraw - the actor will be allocated by the time it
is going to be painted.

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2010-03-26 00:46:43 +00:00
Emmanuele Bassi
169ce1508b x11-texture-pixmap: Move signal handler override
The signal handling override for the ::queue-damage-redraw should be
done in the class initialization function, not in the instance one.
2010-03-03 17:46:53 +00:00
Robert Bragg
c0d5af5de5 Adds initial clipped redraw support to Clutter
A new (internal only currently) API, _clutter_actor_queue_clipped_redraw
can be used to queue a redraw along with a clip rectangle in actor
coordinates. This clip rectangle propagates up to the stage and clutter
backend which may optionally use the information to optimize stage
redraws. The GLX backend in particular may scissor the next redraw to
the clip rectangle and use GLX_MESA_copy_sub_buffer to present the stage
subregion.

The intention is that any actors that can naturally determine the bounds
of updates should queue clipped redraws to reduce the cost of updating
small regions of the screen.

Notes:
» If GLX_MESA_copy_sub_buffer isn't available then the GLX backend
  ignores any clip rectangles.

» queuing multiple clipped redraws will result in the bounding box of
  each clip rectangle being used.

» If a clipped redraw has a height > 300 pixels then it's promoted into
  a full stage redraw, so that the GPU doesn't end up blocking too long
  waiting for the vsync to reach the optimal position to avoid tearing.

  » Note: no empirical data was used to come up with this threshold so
    we may need to tune this.

» Currently only ClutterX11TexturePixmap makes use of this new API. This
  is done via a new "queue-damage-redraw" signal that is emitted when
  the pixmap is updated. The default handler queues a clipped redraw
  with the assumption that the pixmap is being painted as a rectangle
  covering the actors transformed allocation. If you subclass
  ClutterX11TexturePixmap and change how it's painted you now also
  need to override the signal handler and queue your own redraw.

  Technically this is a semantic break, but it's assumed that no one
  is currently doing this.

This still leaves a few unsolved issues with regards to optimizing sub
stage redraws that need to be addressed in further work so this can only
be considered a stepping stone a this point:

» Because we have no reliable way to determine if the painting of any
  given actor is being modified any optimizations implemented using
  _clutter_actor_queue_redraw_with_clip must be overridable by a
  subclass, and technically must be opt-in for existing classes to avoid
  a change in semantics. E.g. consider that a user connects to the paint
  signal for ClutterTexture and paints a circle instead of a rectangle.
  In this case any original logic to queue clipped redraws would be
  incorrect.

» Currently only the implementation of an actor has enough information
  with which to queue clipped redraws. E.g. It is not possible for
  generic code in clutter-actor.c to queue a clipped redraw when hiding
  an actor because actors have no way to report a "paint box". (remember
  actors can draw outside their allocation and actors with depth may
  also be projected outside of their allocation)

  » The current plan is to add a actor_class->get_paint_cuboid()
    virtual so actors can report a bounding cube for everything they
    would draw in their current state and use that to queue clipped
    redraws against the stage by projecting the paint cube into stage
    coordinates.

» Our heuristics for promoting clipped redraws into full redraws to
  avoid blocking the GPU while we wait for the vsync need improving:

  » vsync issues aren't relevant for redirected/composited applications
    so they should use different heuristics. In this case we instead
    need to trade off the cost of blitting when using glXCopySubBuffer
    vs promoting to a full redraw and flipping instead.
2010-03-02 17:19:11 +00:00
Emmanuele Bassi
74a27bbb1c docs: Documentation fixes
Let's see if we can get a 100% coverage for Clutter too.
2010-03-02 11:12:32 +00:00
Emmanuele Bassi
79acb088e7 Remove mentions of the FSF address
Since using addresses that might change is something that finally
the FSF acknowledge as a plausible scenario (after changing address
twice), the license blurb in the source files should use the URI
for getting the license in case the library did not come with it.

Not that URIs cannot possibly change, but at least it's easier to
set up a redirection at the same place.

As a side note: this commit closes the oldes bug in Clutter's bug
report tool.

http://bugzilla.openedhand.com/show_bug.cgi?id=521
2010-03-01 12:56:10 +00:00
Emmanuele Bassi
23867875a1 build: Remove unused checks on platform functions
There is no need for us to check for low-level functions and header
files, especially since we haven't been checking the results until
now. This makes cross-compiling slightly more bearable.
2010-03-01 11:12:16 +00:00
Emmanuele Bassi
ec0c7fcd9b build: Use the right headers when enumerating them
The installed _HEADERS should be the public ones and the enumeration
types; repeating clutter-x11-texture-pixmap.h breaks with automake 1.11
and doesn't strictly make any sense.

http://bugzilla.openedhand.com/show_bug.cgi?id=2002
2010-02-24 14:23:58 +00:00
Emmanuele Bassi
d54af2363d build: Use template for ClutterX11 enumerationt types
Clutter and Cogl use the template Makefile.am.enums for building the
enumeration GTypes from public headers, but ClutterX11 is not.
2010-02-24 10:20:10 +00:00
Emmanuele Bassi
b398292089 device: Impose per-backend DeviceManager
The DeviceManager class should be abstract in Clutter, and implemented
by each backend, as different backends will have different ways to
detect, initialize and list devices; the X11 backend alone has *two*
ways of dealing with devices.

This commit makes DeviceManager an abstract class and delegates the
device initialization and enumeration to per-backend sub-classes.

The responsible for creating the device manager is, obviously, the
backend singleton.

The X11 and Win32 backends have been updated to the new layout; the
Win32 backend has been updated blindly, so it might require additional
testing.
2010-02-17 17:46:48 +00:00
Chris Lord
0bf6d57ab1 [event-x11] Don't relayout on window move
ConfigureNotify is delivered on window movements too, but there is no
need to queue a relayout on these as the viewport hasn't changed size.
Check for the window actually changing size on ConfigureNotify before
queueing a relayout.

This fixes laggy window movement when moving a window in response to
Clutter mouse motion events.
2010-02-17 16:56:30 +00:00
Chris Lord
719e314b8e [stage-x11] Fix a warning due to a missing cast
I stupidly forgot to cast a ClutterStage to a ClutterActor and somehow
missed or didn't get the compiler warning. Fix.
2010-02-16 18:25:46 +00:00
Chris Lord
f9f03894a6 [stage-x11] Fix resizing for foreign windows
As well as manually setting the geometry size, we needed to queue a
relayout. This is what the ConfigureNotify handler would normally do,
but we don't get this event when using a foreign window (obviously).

This should fix resizing in things like gtk-clutter.
2010-02-16 18:17:55 +00:00
Chris Lord
df6e7aee73 [stage-x11] Set the geometry size for foreign wins
If we get into the resize function and it's a foreign window, set the
geometry size so that the allocate will set the backend size and call
glViewport.
2010-02-16 17:53:05 +00:00
Chris Lord
1117b6a9ac [stage-x11] Fix switching fullscreen mode
Setting/unsetting fullscreen on a mapped or unmapped window now works
correctly.

If you unfullscreen a window that was initially full-screened, it will
unset the fullscreen hint and the WM will likely push the size down to
the largest valid size.

If the window was previously un-fullscreened, Clutter will restore the
previous size.

Fullscreening also now works if the WM switches the hint without the
application's knowledge (as happens when you resize a window to the size
of the screen, for example, with stock metacity).
2010-02-16 14:55:53 +00:00
Chris Lord
2fcb644e4f [stage] Fix some races to do with window resizing
When we resize, we relied on the stage's allocate to re-initialise the
GL viewport. Unfortunately, if we resized within Clutter, the new size
was cached before the window is actually resized, so glViewport wasn't
being called after resizing (some of the time, it's a race condition).

Change the way resizing works slightly so that we only resize when the
geometry size doesn't match our preferred size, and queue a relayout on
ConfigureNotify so the glViewport gets called.

Also change window creation slightly so that setting the size of a
window before it's realized works correctly.
2010-02-15 18:56:50 +00:00
Emmanuele Bassi
d607400f01 x11: Do not set pid or title on foreign windows
If a StageX11 is using a foreign window we should not need to set the
_NET_WM_PID or the WM_TITLE properies.

http://bugzilla.openedhand.com/show_bug.cgi?id=1989
2010-02-15 11:50:04 +00:00
Emmanuele Bassi
78f1f508af analysis: x11: ClutterEvent
Remove an unused variable.
2010-02-12 14:57:55 +00:00
Robert Bragg
5d702853b8 glx backend: Adds support for GLX_INTEL_swap_event
If your OpenGL driver supports GLX_INTEL_swap_event that means when
glXSwapBuffers is called it returns immediatly and an XEvent is sent when
the actual swap has finished.

Clutter can use the events that notify swap completion as a means to
throttle rendering in the master clock without blocking the CPU and so it
should help improve the performance of CPU bound applications.
2010-02-09 22:19:41 +00:00
Chris Lord
c82c94e620 [stage-x11] Set the default size differently
We want to set the default size without triggering the layout machinary,
so change the window creation process slightly so we start with a
640x480 window.
2010-02-07 19:17:43 +01:00
Chris Lord
b968defae9 [stage] Set default size correctly
Due to the way the new sizing works, clutter stage must set its size in
init (to maintain old behaviour) and the properties on the X11 stage
must be initialised to 1x1 so that it actually goes ahead with the
resize.

Fixes stages that aren't user resizable and have no size set from
appearing at 1x1.
2010-02-07 14:18:14 +01:00
Chris Lord
8083dc418b Revert "[x11] Don't set actor size on ConfigureNotify"
This reverts commit 29cc027f06.

I misunderstood the problem, this commit breaks resizes coming from
outside of Clutter.
2010-02-06 16:57:37 +01:00
Chris Lord
29cc027f06 [x11] Don't set actor size on ConfigureNotify
Calling clutter_actor_set_size in response to ConfigureNotify makes
setting the size of the stage racy - the most common result of which
seems to be that you can't set the stage dimensions to anything less
than 640x480.

Instead, add a first_allocation bit to the private structure of the X11
stage and force the first resize (necessary or the default stage will be
a 1x1 window).
2010-02-06 16:47:22 +01:00
Chris Lord
4887707bb3 [stage-x11] make get_geometry always get geometry
Now that we have a minimum size getter on the stage object, change
get_geometry to actually always return the geometry. This fixes stages
that are set as user-resizable appearing at 1x1 size.

This will need changing in other back-ends too.
2010-02-06 15:34:55 +01:00
Chris Lord
fd11d3098f [stage] Add set/get_minumum_size
Add two functions to set/get the minimum stage size. This takes effect
when a stage is set to user resizable.
2010-02-06 11:23:37 +00:00
Emmanuele Bassi
8a4b647154 x11: Re-enable XI1 extension keyboards
The extension keyboard support in XInput 1.x is hopelessly broken.

Nevertheless, it's possible to use some bits of it, as we prefer the
core keyboard events to the XInput events, thus at least having proper
handling for X11 key events on the Stage window.
2010-01-20 19:40:58 +00:00
Emmanuele Bassi
94f9f3bd93 x11: Always handle core device events before XI events
The XI 1.0 layer is complementary to the X11 core devices handling; this
means that core events will still be emitted for the core pointer and
keyboard devices, and that secondary (floating) devices should be
handled on top of that.

Thus, the XI event handling code should be executed (if explicitly
compiled in and enabled) if the core device events have not been parsed.

Note: this is going away with XI2, which completely replaces both core and
XI1 events.
2010-01-20 00:39:18 +00:00
Emmanuele Bassi
d8e167f151 Always register core devices
Even with XInput support we should always register core devices. This
allows us to handle enter and leave events correctly on the Stage and
to have a working XInput 1.x support in Clutter.
2010-01-20 00:38:53 +00:00
Emmanuele Bassi
e0b8d63159 device: Remove unused is_default member
The is_default member of the InputDevice structure was not used
anywhere.
2010-01-20 00:38:53 +00:00
Emmanuele Bassi
66740e8000 x11: Fill out the :name property of the InputDevices
For the core pointer and keyboard we assign the names ourselves; for
devices coming from XI we can use the XDeviceInfo.name member.
2010-01-20 00:38:09 +00:00
Emmanuele Bassi
79ad2b6a72 x11: Store core devices on the X11 Backend singleton
Instead of overloading the device id of 0 and 1 we should treat the core
devices as special, and have a pointer inside the X11 backend singleton
structure, for fast access.
2010-01-20 00:38:09 +00:00
Emmanuele Bassi
25c6ebbb2c x11: Discard the LeaveNotify for off-stage ButtonRelease
If the user presses a button on a pointer device and then moves out the
Stage X11 will emit the following events:

  LeaveNotify ➔ MotionNotify ... ➔ ButtonRelease ➔ LeaveNotify

The second LeaveNotify differs from the first by the state field.

Unfortunately, ClutterCrossingEvent doesn't have a modifier_state field
like other events, so we cannot provide a way for programmatically
distinguishing them from a Clutter perspective. This is also an X11-ism
we might not even want to replicate on every backend with sane
enter/leave semantics.

For this reason we should check inside the X11 event processing if the
pointer device has already left the Stage and ignore the second
LeaveNotify.
2010-01-20 00:38:09 +00:00
Emmanuele Bassi
e30856a54d Whitespace and indentation fixes 2010-01-20 00:38:08 +00:00
Emmanuele Bassi
9506510d1c Move all picking-related operations inside InputDevice
The InputDevice objects stores pointer coordinates, state, stage and
the actor under the cursor, so if the current backend provides us with
one attached to the Event structure then we want the InputDevice itself
to update its state and give us the ClutterActor underneath the
pointer's cursor.
2010-01-20 00:38:08 +00:00
Emmanuele Bassi
d23dd9af6b device: Make InputDevice an object and subclass it for X11
ClutterInputDevice should be a type that we can subclass per-backend
to add functionality.
2010-01-20 00:38:08 +00:00
Emmanuele Bassi
157da20e86 x11: Always assign a device to pointer and key events
Even when we are not using XInput we now have fallback devices; the
X11 backend should always assign the default devices when translating
the X events to Clutter events.
2010-01-20 00:38:07 +00:00
Emmanuele Bassi
ca16446319 Add :is-default flag to InputDevice 2010-01-20 00:38:07 +00:00
Emmanuele Bassi
3027d4327a Port the X11 backend to the Device Manager
Use the device manager to store the input devices. Also, provide
two fallback devices when initializing the X11 backend: device 0
for the pointer and device 1 for the keyboard.
2010-01-20 00:38:07 +00:00
Emmanuele Bassi
e019547e8c x11: Fix typo in clutter_x11_set_use_argb_visual() declaration
The function should have a lowercase x11, not an uppercase X11 in its
name.
2010-01-15 14:48:42 +00:00
Emmanuele Bassi
5157da9fc8 x11: Switch back to RGB visuals by default
Since asking for ARGB by default is still somewhat experimental on X11
and not every toolkit or complex widgets (like WebKit) still do not like
dealing with ARGB visuals, we should switch back to RGB by default - now
that at least we know it works.

For applications (and toolkit integration libraries) that want to enable
the ClutterStage:use-alpha property there is a new function:

  void clutter_x11_set_use_argb_visual (gboolean use_argb);

which needs to be called before clutter_init().

The CLUTTER_DISABLE_ARGB_VISUAL environment variable can still be used
to force this value off at run-time.
2010-01-08 15:09:21 +00:00
Emmanuele Bassi
64c1294cc2 x11 tfp: Plug a leak
Destroy the dummy XImage we create even on success.

http://bugzilla.openedhand.com/show_bug.cgi?id=1918

Based on a patch by: Carlos Martín Nieto <carlos@cmartin.tk>

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2010-01-05 14:22:35 +00:00
Emmanuele Bassi
a09ac0b27c Merge branch 'stage-use-alpha' into ebassi-next
* stage-use-alpha:
  tests: Use accessor methods for :use-alpha
  stage: Add accessors for :use-alpha
  tests: Allow setting the stage opacity in test-paint-wrapper
  stage: Premultiply the stage color
  stage: Composite the opacity with the alpha channel
  glx: Always request an ARGB visual
  stage: Add :use-alpha property
  materials: Get the right blend function for alpha
2009-12-20 17:39:12 +00:00
Emmanuele Bassi
86ce92eec1 x11: Emulate XKB's detectable key auto-repeat
Old-style X11 terminals require that even modern X11 send KeyPress
and KeyRelease pairs when auto-repeating. For this reason modern(-ish)
API like XKB has a way to detect auto-repeat and do a single KeyRelease
at the end of a KeyPress sequence.

The newly added check emulates XKB's detectable auto-repeat by peeking
the next event after a KeyRelease and checking if it's a KeyPress for
the same key and timestamp - and then ignoring the KeyRelease if it
matches.
2009-12-09 18:46:25 +00:00
Emmanuele Bassi
e957e277b8 x11: Do not manage a foreign window
If a Stage has been set to use a foreign Window then Clutter should not
be managing it; calling XWithdrawWindow and XMapWindow should be
reserved to the windows we manage ourselves.
2009-12-08 18:24:30 +00:00
Emmanuele Bassi
e6ca2d891a glx: Always request an ARGB visual
When requesting the GLXFBConfig for creating the GLX context, we should
always request one that links to an ARGB visual instead of a plain RGB
one.

By using an ARGB visual we allow the ClutterStage:use-alpha property to
work as intended when running Clutter under a compositing manager.

The default behaviour of requesting an ARGB visual can be disabled by
using the:

  CLUTTER_DISABLE_ARGB_VISUAL

Environment variable.
2009-12-01 16:25:54 +00:00
Neil Roberts
7a011af974 docs: Fix the 'Since' annotation for some functions
The 'Since' annotation needs to have a colon after it or gtk-doc won't
pick it up.
2009-11-19 11:51:21 +00:00
Robert Bragg
f8f8873714 [stage-x11] Ensure viewport is initialized before first stage paint
This ensures that glViewport is called before the first stage paint.
Previously _clutter_stage_maybe_setup_viewport (which is done before we
start painting) was bailing out without calling cogl_setup_viewport because
the CLUTTER_STAGE_IN_RESIZE flag may be set if the stage was resized before
the first paint.  (NB: The CLUTTER_STAGE_IN_RESIZE flag isn't removed until
we get an explicit event back from the X server since the window manager may
choose to deny/alter the resize.)

We now special case the first resize - where the viewport hasn't previously
been initialized and use the requested geometry to initialize the
glViewport without waiting for a reply from the server.
2009-11-02 16:55:02 +00:00
Robert Bragg
43efab46bc Intial Re-layout of the Cogl source code and introduction of a Cogl Winsys
As part of an incremental process to have Cogl be a standalone project we
want to re-consider how we organise the Cogl source code.

Currently this is the structure I'm aiming for:
cogl/
    cogl/
	<put common source here>
	winsys/
	   cogl-glx.c
	   cogl-wgl.c
	driver/
	    gl/
	    gles/
	os/ ?
    utils/
	cogl-fixed
	cogl-matrix-stack?
        cogl-journal?
        cogl-primitives?
    pango/

The new winsys component is a starting point for migrating window system
code (i.e.  x11,glx,wgl,osx,egl etc) from Clutter to Cogl.

The utils/ and pango/ directories aren't added by this commit, but they are
noted because I plan to add them soon.

Overview of the planned structure:

* The winsys/ API is the API that binds OpenGL to a specific window system,
  be that X11 or win32 etc.  Example are glx, wgl and egl. Much of the logic
  under clutter/{glx,osx,win32 etc} should migrate here.

* Note there is also the idea of a winsys-base that may represent a window
  system for which there are multiple winsys APIs.  An example of this is
  x11, since glx and egl may both be used with x11.  (currently only Clutter
  has the idea of a winsys-base)

* The driver/ represents a specific varient of OpenGL. Currently we have "gl"
  representing OpenGL 1.4-2.1 (mostly fixed function) and "gles" representing
  GLES 1.1 (fixed funciton) and 2.0 (fully shader based)

* Everything under cogl/ should fundamentally be supporting access to the
  GPU.  Essentially Cogl's most basic requirement is to provide a nice GPU
  Graphics API and drawing a line between this and the utility functionality
  we add to support Clutter should help keep this lean and maintainable.

* Code under utils/ as suggested builds on cogl/ adding more convenient
  APIs or mechanism to optimize special cases. Broadly speaking you can
  compare cogl/ to OpenGL and utils/ to GLU.

* clutter/pango will be moved to clutter/cogl/pango

How some of the internal configure.ac/pkg-config terminology has changed:
backendextra -> CLUTTER_WINSYS_BASE # e.g. "x11"
backendextralib -> CLUTTER_WINSYS_BASE_LIB # e.g. "x11/libclutter-x11.la"
clutterbackend -> {CLUTTER,COGL}_WINSYS # e.g. "glx"
CLUTTER_FLAVOUR -> {CLUTTER,COGL}_WINSYS
clutterbackendlib -> CLUTTER_WINSYS_LIB
CLUTTER_COGL -> COGL_DRIVER # e.g. "gl"

Note: The CLUTTER_FLAVOUR and CLUTTER_COGL defines are kept for apps

As the first thing to take advantage of the new winsys component in Cogl;
cogl_get_proc_address() has been moved from cogl/{gl,gles}/cogl.c into
cogl/common/cogl.c and this common implementation first trys
_cogl_winsys_get_proc_address() but if that fails then it falls back to
gmodule.
2009-10-16 18:58:50 +01:00
Robert Bragg
3187e19642 [x11 backend] remove data duplicated between backends and stages
Make backends the canonical point of reference for the xdisplay, the xscreen
number, the x root window and the xvisinfo for creating foreign stages.
2009-10-16 18:58:48 +01:00
Robert Bragg
15d7a86621 [backends] Remove the idea of offscreen stages from all backends
The only backend that tried to implement offscreen stages was the GLX backend
and even this has apparently be broken for some time without anyone noticing.

The property still remains and since the property already clearly states that
it may not work I don't expect anyone to notice.

This simplifies quite a bit of the GLX code which is very desireable from the
POV that we want to start migrating window system code down to Cogl and the
simpler the code is the more straight forward this work will be.

In the future when Cogl has a nicely designed API for framebuffer objects then
re-implementing offscreen stages cleanly for *all* backends should be quite
straightforward.
2009-10-16 18:58:47 +01:00
Emmanuele Bassi
72243081b5 Merge branch 'stage-window-object'
* stage-window-object:
  [x11] Fix Stage user-initiated resize
  [x11] Remove a useless forced paint
  [stage] Rework the Stage implementation class
2009-10-05 12:37:08 +01:00