Commit Graph

246 Commits

Author SHA1 Message Date
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
Emmanuele Bassi
111512a2a0 [x11] Fix Stage user-initiated resize
The user-initiated resize is conflicting with the allocated size. This
happens because we change the size of the stage's X Window behind the
back of the size allocation machinery.

Instead, we should change the size of the actor whenever we receive a
ConfigureNotify event to reflect the new size of the actor.
2009-10-05 12:24:19 +01:00
Emmanuele Bassi
e3c2ed0009 [x11] Remove a useless forced paint
We force the redraw before mapping, in the hope that when a composited
window manager maps the window it will have its contents ready; that is
not going to work: the solution for this problem requires the implementation
of a protocol for compositors, and not a hack.

Moreover, painting before mapping will cause a paint with the wrong
GL viewport size, which is the wrong thing to do on GLX.
2009-10-05 12:21:02 +01:00
Emmanuele Bassi
ecfa0c4f92 [build] Split out the custom silent rules
The silent rules we use for custom targets should be moved into a
separate Makefile.am that gets included from all the others.
2009-09-16 17:47:59 +01:00
Emmanuele Bassi
6988744db7 [stage] Rework the Stage implementation class
Instead of using ClutterActor for the base class of the Stage
implementation we should extend the StageWindow interface with
the required bits (geometry, realization) and use a simple object
class.

This require a wee bit of changes across Backend, Stage and
StageWindow, even though it's mostly re-shuffling.

First of all, StageWindow should get new virtual functions:

  * geometry:
    - resize()
    - get_geometry()

  * realization
    - realize()
    - unrealize()

This covers all the bits that we use from ClutterActor currently
inside the stage implementations.

The ClutterBackend::create_stage() virtual function should create
a StageWindow, and not an Actor (it should always have been; the
fact that it returned an Actor was a leak of the black magic going
on underneath). Since we never guaranteed ABI compatibility for
the Backend class, this is not a problem.

Internally to ClutterStage we can finally drop the shenanigans of
setting/unsetting actor flags on the implementation: if the realization
succeeds, for instance, we set the REALIZED flag on the Stage and
we're done.

As an initial proof of concept, the X11 and GLX stage implementations
have been ported to the New World Order(tm) and show no regressions.
2009-09-08 10:52:58 +01:00
Xu Li
f7edc97d8d Add new Atom atom_NET_WM_PID to set pid info
Clutter advertises itself on X11 as implementing the _NET_WM_PING protocol,
which is needed to be able to detect frozen applications; this allows us to
stop the destruction of the stage by blocking the CLUTTER_DELETE event and
wait for user feedback without the Window Manager thinking that the app has
gone unresponsive.

In order to implement the _NET_WM_PING protocol properly, though, we need
to add the _NET_WM_PID property on the Stage window, since the EWMH states:

  [_NET_WM_PID] MAY be used by the Window Manager to kill windows which
  do not respond to the _NET_WM_PING protocol.

Meaning that an unresponsive Clutter application might not be killable by
the window manager.

Fixes bug:

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

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2009-08-14 12:41:01 +01:00
Emmanuele Bassi
420ed353b5 [x11] Do not ask to destroy an empty Window
The fix for bug 1750 inside commit b190448e made Clutter-GTK spew
BadWindow errors. The reason for that is that we call XDestroyWindow()
without checking if the old Window is None; this happens if we call
clutter_x11_set_stage_foreign() on a new ClutterStage before it has
been realized.

Since Clutter-GTK does not need to realize the Stage it is going to
embed anymore (the only reason for that was to obtain a proper Visual
but now there's ClutterBackendX11 API for that), the set_stage_foreign()
call is effectively setting the StageX11 Window for the first time.
2009-08-07 08:26:18 +01:00
Emmanuele Bassi
b190448ed4 [x11] Destroy the Window we own when setting a foreign one
When we replace the stage Window using a foreign one we also need to
destroy the Window we created, if needed, to avoid leaking resources
all around.

Fixes bug:

  http://bugzilla.openedhand.com/show_bug.cgi?id=1750
2009-08-04 16:59:15 +01:00
Damien Lespiau
94b35a4a5e [build] GCC_FLAGS is no more, MAINTAINER_CFLAGS is the One.
CC_FLAGS was a left over from the 0.8.x age. Killed it and use the
newer MAINTAINER_CFLAGS variable instead.
2009-08-03 14:25:08 +01:00
Emmanuele Bassi
ae2a861a0b [x11] Force a redraw before mapping the stage
Does as it says on the tin: run a paint cycle before calling
XMapWindow().
2009-07-31 10:29:33 +01:00
Owen W. Taylor
894fe4ba93 Always create the Damage object for ClutterX11TexturePixmap auto updates
If clutter_x11_texture_set_window() was called after
clutter_x11_texture_pixmap_set_automatic(), then the Damage object would
not be properly created so updates to the window were ignored.

Refactor creation of the damage object to a separate function, and
call it from clutter_x11_texture_set_window() and clutter_x11_texture_set_pixmap()
as appropriate. Addition and removal of the filter function is made
conditional on priv->damage to make free_damage_resources() cleanly
idempotent.

See: http://bugzilla.gnome.org/show_bug.cgi?id=587189 for the original
bug report.

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

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2009-07-27 10:49:38 +01:00
Neil Roberts
7b811f8be4 [stage] Force an allocation before showing the stage
A lot of applications change the size of the stage from the default
before the stage is initially shown. The size change won't take affect
until the first allocation run. However we want the window to be at
the correct size when we first map it so we should force an allocation
run before showing the stage.

There was an explicit call to XResizeWindow in
clutter_stage_x11_show. This is not needed anymore because
XResizeWindow will already have been called by the allocate method.
2009-07-17 12:43:52 +01:00
Xu Li
13f31d8319 [x11] update_wm_hints after unsetting WITHDRAWN
Updating the WM hints on the stage window shortcircuits if the stage
is in WITHDRAWN state, so we need to move the update_wm_hints() call
after the flag has been unset.

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2009-07-13 15:33:21 +01:00
Emmanuele Bassi
250b775926 [x11] Fix the race between resize and glViewport calls
The race we were experiencing in the X11 backends is apparently
back after the fix in commit 00a3c698.

This time, just delaying the setting of the SYNC_MATRICES flag
is not enough, so we can resume the use of a STAGE_IN_RESIZE
private flag.

This should also fix bug:

  http://bugzilla.openedhand.com/show_bug.cgi?id=1668
2009-07-01 15:30:21 +01:00
Emmanuele Bassi
cb4e5c9083 [x11] Simplify the XInput support
Instead of using a specific function to check whether the X
server supports the XInput extension we can use the generic
Xlib function XQueryExtension(). This cuts down the extra
checks inside the configure.ac and simplifies the code inside
clutter_x11_register_xinput().
2009-06-19 15:12:32 +01:00
Emmanuele Bassi
21608fe5f7 [x11] Add a command line switch for enabling XInput
Currently, XInput support requires a function call. In order to
make it easier for people to test it, we can also add a command
line switch that moves the pointer device detection and handling
to XInput. This should ensure that, at least for people building
Clutter with --enable-xinput, applications can be easily migrated
and regressions can be caught.
2009-06-19 14:32:37 +01:00
Emmanuele Bassi
a6b4697367 [backend] Do not store the stage manager singleton
The StageManager singleton instance is already kept around
by the clutter_stage_manager_get_default() function; there is
no need to have it inside the main Clutter context as well.
2009-06-19 14:19:39 +01:00
Emmanuele Bassi
b6e404a406 [x11] Use _clutter_context_is_initialized()
Instead of using _clutter_context_get_default() and checking the
is_initialized flag, we should use the newly added private function
that does not cause side effects, especially for functions that have
to be called before any other Clutter function.
2009-06-19 14:12:36 +01:00
Emmanuele Bassi
184df2a5fa [input] Rework input device API
The input device API is split halfway thorugh the backends in a very
weird way. The data structures are private, as they should, but most
of the information should be available in the main API since it's
generic enough.

The device type enumeration, for instance, should be common across
every backend; the accessors for device type and id should live in the
core API. The internal API should always use ClutterInputDevice and
not the private X11 implementation when dealing with public structures
like ClutterEvent.

By adding accessors for the device type and id, and by moving the
device type enumeration into the core API we can cut down the amount
of symbols private and/or visible only to the X11 backends; this way
when other backends start implementing multi-pointer support we can
share the same API across the code.
2009-06-19 13:12:05 +01:00
Emmanuele Bassi
c6fba47a52 Hide clutter_context_get_default()
The clutter_context_get_default() function is private, but shared
across Clutter. For this reason, it should be prefixed by '_' so
that the symbol is hidden from the shared object.
2009-06-18 14:20:28 +01:00
Owen W. Taylor
795e005566 Fix handling of not-visible texture pixmaps
If we have an not-visible texture pixmap, we need to:

 - Still update it if it is realized, since it won't be
   updated when shown. And it might be also be cloned.

 - Queue a redraw if even if not visible, since it
   it might be cloned.

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

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2009-06-15 11:29:37 +01:00
Owen W. Taylor
4dcd5f6134 Use correct texture format for pixmap textures and FBO's
RGBA data in X pixmaps and in FBOs is already premultiplied; use
the right format when creating cogl textures.

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

Signed-off-by: Robert Bragg <robert@linux.intel.com>
2009-06-11 14:17:51 +01:00
Emmanuele Bassi
7c89a0ccfa [stage] Rename :fullscreen to :fullscreen-set
The :fullscreen property is very much confusing as it is implemented.
It can be written to a value, but the whole process might fail. If we
set:

  g_object_set (stage, "fullscreen", TRUE, NULL);

and the fullscreen process fails or it is not implemented, the value
will be reset to FALSE (if we're lucky) or left TRUE (most of the
times).

The writability is just a shorthand for invoking clutter_stage_fullscreen()
or clutter_stage_unfullscreen() depending on a boolean value without
using an if.

The :fullscreen property also greatly confuses high level languages,
since the same symbol is used:

  - for a method name (Clutter.Stage.fullscreen())
  - for a property name (Clutter.Stage.fullscreen)
  - for a signal (Clutter.Stage::fullscreen)

For these reasons, the :fullscreen should be renamed to :fullscreen-set
and be read-only. Implementations of the Stage should only emit the
StageState event to change from normal to fullscreen, and the Stage
will automatically update the value of the property and emit a notify
signal for it.
2009-06-09 14:07:35 +01:00
Owen W. Taylor
d28c9e5db1 Remove unnecessary setting of CLUTTER_ACTOR_REALIZED flag
An implementaton of realize() never needs to set the
CLUTTER_ACTOR_REALIZED flag, though it can unset the flag if
things fail unexpectedly. (Previously, stage backend implementations
had to do this since clutter_actor_realize() wasn't used; this
is no longer the case.)

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

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2009-06-08 11:07:33 +01:00
Emmanuele Bassi
12b4e0400c [x11] Do not forcibly set the stage size on fullscreen
Setting the stage size using clutter_actor_set_size() is almost always
wrong: the X11 stage implementation should save the size and queue a
relayout -- like it does when receiving a ConfigureNotify. The same
should happen when setting it to be full screen.
2009-06-08 02:04:27 +01:00
Emmanuele Bassi
cbb748f7c0 [x11] Disable XInput by default
The XInput support in Clutter is still using XI 1.x. This will never
work correctly, and we are all waiting for XInput 2 anyway. The changes
internally should be minimal, so we can leave everything in place, but
it's better to disable XInput support by default -- at least for the
time being.
2009-06-05 12:30:08 +01:00
Emmanuele Bassi
745ca8a62c [xinput] Invert the XI extension version check
Since having XQueryInputVersion means also having XGetExtensionVersion
we need to check the former first to avoid the deprecation warning.
2009-06-05 12:08:41 +01:00
Emmanuele Bassi
e4ff24bcff [x11] Rework map/unmap and resizing
The mapping and unmapping of the X11 stage implementation is
a bit bong. It's asynchronous, for starters, when it really
can avoid it by tracking the state internally.

The ordering of the map/unmap sequence is also broken with
respect to the resizing.

By tracking the state internally into StageX11 we can safely
remove the MapNotify and UnmapNotify X event handling.

In theory, we should use _NET_WM_STATE a lot more, and reuse
the X11 state flags for fullscreening as well.
2009-06-04 16:30:32 +01:00
Emmanuele Bassi
0a4a28a950 [xinput] Check for the XInput entry points
Apparently, the XInput extension is using the same pkg-config
file ('xi') for both the 1.x and the 2.x API, so we need to
check for both the 1.x XGetExtensionVersion and the 2.x
XQueryInputVersion.
2009-06-04 16:30:31 +01:00
Emmanuele Bassi
0187bb3965 [actor] Use flags to control allocations
Instead of passing a boolean value, the ::allocate virtual function
should use a bitmask and flags. This gives us room for expansion
without breaking API/ABI, and allows to encode more information to
the allocation process instead of just changes of absolute origin.
2009-06-04 16:30:31 +01:00
Emmanuele Bassi
046e571bae Remove usage of Units and macros
The ClutterUnit and relative macros should not be used when dealing
with pixels -- which is to say, all the time when inside Clutter.
2009-06-04 16:30:30 +01:00
Emmanuele Bassi
f8f54989be Merge commit 'origin/master' into 1.0-integration
Conflicts:
	clutter/clutter-texture.c
	clutter/cogl/gl/cogl-fbo.c
2009-05-20 16:49:22 +01:00