2003-11-15 23:35:16 -05:00
|
|
|
/*
|
2006-01-20 16:43:13 -05:00
|
|
|
* Copyright (C) 2003, 2004, 2005, 2006 Red Hat, Inc.
|
2003-11-23 13:16:01 -05:00
|
|
|
* Copyright (C) 2003 Keith Packard
|
2003-11-15 23:35:16 -05:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License as
|
|
|
|
* published by the Free Software Foundation; either version 2 of the
|
|
|
|
* License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
|
|
|
* 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
#include "compositor.h"
|
2003-11-23 13:16:01 -05:00
|
|
|
#include "screen.h"
|
|
|
|
#include "errors.h"
|
2003-11-29 22:30:27 -05:00
|
|
|
#include "window.h"
|
|
|
|
#include "frame.h"
|
2006-01-13 14:41:01 -05:00
|
|
|
#include "workspace.h"
|
|
|
|
|
|
|
|
#include <math.h>
|
2006-02-15 14:50:12 -05:00
|
|
|
#include <stdlib.h>
|
2006-01-13 14:41:01 -05:00
|
|
|
|
2006-01-14 16:51:46 -05:00
|
|
|
#ifdef HAVE_COMPOSITE_EXTENSIONS
|
2006-01-13 14:41:01 -05:00
|
|
|
#include <cm/node.h>
|
|
|
|
#include <cm/drawable-node.h>
|
|
|
|
#include <GL/gl.h>
|
|
|
|
#include <GL/glu.h>
|
|
|
|
#include <GL/glx.h>
|
|
|
|
|
|
|
|
#include <cm/ws.h>
|
|
|
|
#include <cm/wsint.h>
|
2006-02-28 14:51:45 -05:00
|
|
|
#include <cm/stacker.h>
|
|
|
|
#include <cm/cube.h>
|
|
|
|
#include <cm/rotation.h>
|
2006-01-13 14:41:01 -05:00
|
|
|
|
2006-01-14 16:51:46 -05:00
|
|
|
#include <X11/extensions/shape.h>
|
2003-11-15 23:35:16 -05:00
|
|
|
#include <X11/extensions/Xcomposite.h>
|
|
|
|
#include <X11/extensions/Xdamage.h>
|
2006-01-14 16:51:46 -05:00
|
|
|
#include <X11/extensions/Xfixes.h>
|
2003-11-15 23:35:16 -05:00
|
|
|
#include <X11/extensions/Xrender.h>
|
2006-02-25 11:54:39 -05:00
|
|
|
#include "spring-model.h"
|
2006-02-28 14:51:45 -05:00
|
|
|
#include <cm/state.h>
|
2006-03-03 10:53:10 -05:00
|
|
|
|
2006-05-22 17:46:14 -04:00
|
|
|
#include "effects.h"
|
|
|
|
|
2006-03-03 10:53:10 -05:00
|
|
|
#include "c-screen.h"
|
2003-11-15 23:35:16 -05:00
|
|
|
#endif /* HAVE_COMPOSITE_EXTENSIONS */
|
|
|
|
|
2003-11-29 22:30:27 -05:00
|
|
|
#define FRAME_INTERVAL_MILLISECONDS ((int)(1000.0/40.0))
|
|
|
|
|
2006-01-14 16:51:46 -05:00
|
|
|
#ifdef HAVE_COMPOSITE_EXTENSIONS
|
2003-11-15 23:35:16 -05:00
|
|
|
|
2006-03-03 10:53:10 -05:00
|
|
|
/* Screen specific information */
|
2006-02-25 11:54:39 -05:00
|
|
|
typedef struct MoveInfo MoveInfo;
|
|
|
|
|
2003-11-15 23:35:16 -05:00
|
|
|
struct MetaCompositor
|
|
|
|
{
|
2006-01-19 16:51:54 -05:00
|
|
|
MetaDisplay *meta_display;
|
2006-01-13 14:41:01 -05:00
|
|
|
|
2006-01-19 16:51:54 -05:00
|
|
|
WsDisplay *display;
|
2003-11-23 13:16:01 -05:00
|
|
|
|
|
|
|
guint repair_idle;
|
2003-11-15 23:35:16 -05:00
|
|
|
|
|
|
|
guint enabled : 1;
|
2003-11-24 18:00:52 -05:00
|
|
|
guint have_composite : 1;
|
|
|
|
guint have_damage : 1;
|
|
|
|
guint have_fixes : 1;
|
2004-08-26 23:27:43 -04:00
|
|
|
guint have_name_window_pixmap : 1;
|
2006-01-13 14:41:01 -05:00
|
|
|
guint debug_updates : 1;
|
2003-11-23 13:16:01 -05:00
|
|
|
|
2006-01-13 14:41:01 -05:00
|
|
|
GList *ignored_damage;
|
|
|
|
};
|
2006-01-14 16:51:46 -05:00
|
|
|
#endif /* HAVE_COMPOSITE_EXTENSIONS */
|
2003-11-23 13:16:01 -05:00
|
|
|
|
|
|
|
#ifdef HAVE_COMPOSITE_EXTENSIONS
|
|
|
|
|
2006-02-15 18:44:15 -05:00
|
|
|
static WsDisplay *compositor_display;
|
2006-02-16 16:03:02 -05:00
|
|
|
#endif /* HAVE_COMPOSITE_EXTENSIONS */
|
2006-02-15 18:44:15 -05:00
|
|
|
|
2006-03-03 10:53:10 -05:00
|
|
|
#ifdef HAVE_COMPOSITE_EXTENSIONS
|
|
|
|
static void
|
|
|
|
handle_error (Display *dpy, XErrorEvent *ev, gpointer data)
|
|
|
|
{
|
|
|
|
WsDisplay *display = data;
|
|
|
|
|
2006-05-02 17:15:32 -04:00
|
|
|
ws_display_process_xerror (display, ev);
|
2006-03-03 10:53:10 -05:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2006-05-22 17:46:14 -04:00
|
|
|
static Window
|
|
|
|
get_xid (MetaWindow *window)
|
|
|
|
{
|
|
|
|
if (window->frame)
|
|
|
|
return window->frame->xwindow;
|
|
|
|
else
|
|
|
|
return window->xwindow;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
do_effect (MetaEffect *effect,
|
|
|
|
gpointer data)
|
|
|
|
{
|
2006-05-23 17:42:34 -04:00
|
|
|
/* XXX screen and window should be easier to get than this... */
|
2006-05-22 17:46:14 -04:00
|
|
|
switch (effect->type)
|
|
|
|
{
|
|
|
|
case META_EFFECT_MINIMIZE:
|
|
|
|
{
|
|
|
|
MetaCompScreen *screen = meta_comp_screen_get_by_xwindow (
|
|
|
|
get_xid (effect->u.minimize.window));
|
|
|
|
MetaCompWindow *window =
|
|
|
|
meta_comp_screen_lookup_window (screen, effect->u.minimize.window->frame->xwindow);
|
|
|
|
|
2006-05-23 17:42:34 -04:00
|
|
|
/* meta_comp_window_shrink (window, effect); */
|
2006-05-22 17:46:14 -04:00
|
|
|
meta_comp_window_explode (window, effect);
|
|
|
|
break;
|
|
|
|
}
|
2006-05-23 17:42:34 -04:00
|
|
|
#if 0
|
|
|
|
case META_EFFECT_RESTORE:
|
|
|
|
{
|
|
|
|
MetaCompScreen *screen = meta_comp_screen_get_by_xwindow (
|
|
|
|
get_xid (effect->u.restore.window));
|
|
|
|
MetaCompWindow *window = meta_comp_screen_lookup_window (
|
|
|
|
screen, effect->u.restore.window->frame->xwindow);
|
|
|
|
meta_comp_window_unshrink (window, effect);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
#endif
|
2006-05-23 16:38:18 -04:00
|
|
|
case META_EFFECT_CLOSE:
|
|
|
|
{
|
|
|
|
MetaCompScreen *screen = meta_comp_screen_get_by_xwindow (
|
|
|
|
get_xid (effect->u.minimize.window));
|
|
|
|
MetaCompWindow *window =
|
|
|
|
meta_comp_screen_lookup_window (screen, effect->u.minimize.window->frame->xwindow);
|
|
|
|
|
2006-05-24 12:58:20 -04:00
|
|
|
meta_comp_window_set_updates (window, FALSE);
|
2006-05-23 16:38:18 -04:00
|
|
|
meta_comp_window_explode (window, effect);
|
|
|
|
break;
|
|
|
|
}
|
2006-05-22 17:46:14 -04:00
|
|
|
default:
|
|
|
|
{
|
|
|
|
g_assert_not_reached();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-03-03 10:53:10 -05:00
|
|
|
MetaCompositor *
|
2003-11-15 23:35:16 -05:00
|
|
|
meta_compositor_new (MetaDisplay *display)
|
|
|
|
{
|
|
|
|
#ifdef HAVE_COMPOSITE_EXTENSIONS
|
|
|
|
MetaCompositor *compositor;
|
2006-01-13 14:41:01 -05:00
|
|
|
|
2003-11-15 23:35:16 -05:00
|
|
|
compositor = g_new0 (MetaCompositor, 1);
|
|
|
|
|
2006-02-15 18:44:15 -05:00
|
|
|
if (!compositor_display)
|
2006-02-17 11:58:08 -05:00
|
|
|
{
|
|
|
|
gboolean has_extensions;
|
|
|
|
|
|
|
|
compositor_display = ws_display_new (NULL);
|
2006-03-03 10:53:10 -05:00
|
|
|
|
|
|
|
meta_errors_register_foreign_display (
|
|
|
|
compositor_display->xdisplay, handle_error, compositor_display);
|
2006-02-25 11:54:39 -05:00
|
|
|
|
2006-02-17 11:58:08 -05:00
|
|
|
has_extensions =
|
|
|
|
ws_display_init_composite (compositor_display) &&
|
|
|
|
ws_display_init_damage (compositor_display) &&
|
|
|
|
ws_display_init_fixes (compositor_display) &&
|
|
|
|
ws_display_init_test (compositor_display);
|
|
|
|
|
|
|
|
if (!has_extensions)
|
|
|
|
{
|
|
|
|
g_warning ("Disabling compositor since the server is missing at "
|
|
|
|
"least one of the COMPOSITE, DAMAGE, FIXES or TEST "
|
|
|
|
"extensions");
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
2006-02-25 11:54:39 -05:00
|
|
|
|
2006-02-23 15:41:53 -05:00
|
|
|
ws_display_set_ignore_grabs (compositor_display, TRUE);
|
2006-02-17 11:58:08 -05:00
|
|
|
}
|
|
|
|
|
2006-02-15 18:44:15 -05:00
|
|
|
compositor->display = compositor_display;
|
|
|
|
|
|
|
|
ws_display_set_synchronize (compositor_display,
|
2006-02-02 18:02:21 -05:00
|
|
|
getenv ("METACITY_SYNC") != NULL);
|
2003-11-15 23:35:16 -05:00
|
|
|
|
2006-01-19 16:51:54 -05:00
|
|
|
compositor->meta_display = display;
|
2003-11-15 23:35:16 -05:00
|
|
|
|
|
|
|
compositor->enabled = TRUE;
|
2006-03-03 10:53:10 -05:00
|
|
|
|
2006-05-22 17:46:14 -04:00
|
|
|
meta_push_effect_handler (do_effect, compositor);
|
|
|
|
|
2003-11-15 23:35:16 -05:00
|
|
|
return compositor;
|
|
|
|
#else /* HAVE_COMPOSITE_EXTENSIONS */
|
2006-01-13 14:41:01 -05:00
|
|
|
return NULL;
|
2003-11-15 23:35:16 -05:00
|
|
|
#endif /* HAVE_COMPOSITE_EXTENSIONS */
|
|
|
|
}
|
|
|
|
|
2006-01-13 14:41:01 -05:00
|
|
|
void
|
|
|
|
meta_compositor_set_debug_updates (MetaCompositor *compositor,
|
|
|
|
gboolean debug_updates)
|
|
|
|
{
|
2006-01-14 16:51:46 -05:00
|
|
|
#ifdef HAVE_COMPOSITE_EXTENSIONS
|
2006-01-13 14:41:01 -05:00
|
|
|
compositor->debug_updates = !!debug_updates;
|
2006-01-14 16:51:46 -05:00
|
|
|
#endif /* HAVE_COMPOSITE_EXTENSIONS */
|
2006-01-13 14:41:01 -05:00
|
|
|
}
|
|
|
|
|
2003-11-23 13:16:01 -05:00
|
|
|
#ifdef HAVE_COMPOSITE_EXTENSIONS
|
|
|
|
static void
|
|
|
|
remove_repair_idle (MetaCompositor *compositor)
|
|
|
|
{
|
2006-01-13 14:41:01 -05:00
|
|
|
if (compositor->repair_idle)
|
2003-11-23 13:16:01 -05:00
|
|
|
{
|
2006-01-13 14:41:01 -05:00
|
|
|
meta_topic (META_DEBUG_COMPOSITOR, "Damage idle removed\n");
|
|
|
|
|
2003-11-23 13:16:01 -05:00
|
|
|
g_source_remove (compositor->repair_idle);
|
|
|
|
compositor->repair_idle = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif /* HAVE_COMPOSITE_EXTENSIONS */
|
|
|
|
|
2003-11-15 23:35:16 -05:00
|
|
|
void
|
|
|
|
meta_compositor_unref (MetaCompositor *compositor)
|
|
|
|
{
|
|
|
|
#ifdef HAVE_COMPOSITE_EXTENSIONS
|
|
|
|
/* There isn't really a refcount at the moment since
|
|
|
|
* there's no ref()
|
|
|
|
*/
|
2003-11-23 13:16:01 -05:00
|
|
|
remove_repair_idle (compositor);
|
2006-01-13 14:41:01 -05:00
|
|
|
|
2003-11-15 23:35:16 -05:00
|
|
|
g_free (compositor);
|
|
|
|
#endif /* HAVE_COMPOSITE_EXTENSIONS */
|
|
|
|
}
|
|
|
|
|
2003-11-23 13:16:01 -05:00
|
|
|
#ifdef HAVE_COMPOSITE_EXTENSIONS
|
|
|
|
|
|
|
|
static void
|
|
|
|
process_configure_notify (MetaCompositor *compositor,
|
|
|
|
XConfigureEvent *event)
|
|
|
|
{
|
2006-05-04 13:32:26 -04:00
|
|
|
MetaCompScreen *minfo = meta_comp_screen_get_by_xwindow (event->window);
|
2006-03-03 10:53:10 -05:00
|
|
|
|
2006-02-02 18:02:21 -05:00
|
|
|
#if 0
|
2006-03-03 10:53:10 -05:00
|
|
|
g_print ("minfo: %lx => %p\n", event->window, minfo);
|
2006-03-15 16:31:12 -05:00
|
|
|
#endif
|
2006-03-03 10:53:10 -05:00
|
|
|
|
2006-03-15 16:31:12 -05:00
|
|
|
#if 0
|
|
|
|
g_print ("configure on %lx (above: %lx) %d %d %d %d\n", event->window, event->above,
|
|
|
|
event->x, event->y, event->width, event->height);
|
2006-02-02 18:02:21 -05:00
|
|
|
#endif
|
|
|
|
|
2006-03-03 10:53:10 -05:00
|
|
|
if (!minfo)
|
|
|
|
{
|
2006-02-02 18:02:21 -05:00
|
|
|
#if 0
|
2006-03-03 10:53:10 -05:00
|
|
|
g_print (" --- ignoring configure (no screen info)\n");
|
2006-02-02 18:02:21 -05:00
|
|
|
#endif
|
2006-03-03 10:53:10 -05:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-05-04 13:32:26 -04:00
|
|
|
meta_comp_screen_restack (minfo, event->window, event->above);
|
|
|
|
meta_comp_screen_set_size (minfo,
|
2006-03-03 10:53:10 -05:00
|
|
|
event->window,
|
|
|
|
event->x, event->y,
|
|
|
|
event->width, event->height);
|
2003-11-23 13:16:01 -05:00
|
|
|
}
|
|
|
|
#endif /* HAVE_COMPOSITE_EXTENSIONS */
|
|
|
|
|
2003-11-29 22:30:27 -05:00
|
|
|
|
|
|
|
#ifdef HAVE_COMPOSITE_EXTENSIONS
|
|
|
|
static void
|
|
|
|
process_expose (MetaCompositor *compositor,
|
|
|
|
XExposeEvent *event)
|
|
|
|
{
|
2006-01-13 14:41:01 -05:00
|
|
|
/* FIXME: queue repaint */
|
2003-11-29 22:30:27 -05:00
|
|
|
}
|
2006-01-13 14:41:01 -05:00
|
|
|
|
2003-11-29 22:30:27 -05:00
|
|
|
#endif /* HAVE_COMPOSITE_EXTENSIONS */
|
|
|
|
|
2006-02-07 00:58:52 -05:00
|
|
|
#ifdef HAVE_COMPOSITE_EXTENSIONS
|
2006-02-06 17:47:13 -05:00
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
2006-02-15 18:44:15 -05:00
|
|
|
CmDrawableNode *node;
|
|
|
|
GTimer *timer;
|
2006-02-06 17:47:13 -05:00
|
|
|
} FadeInfo;
|
|
|
|
|
|
|
|
#define FADE_TIME 0.3
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
fade_out (gpointer data)
|
|
|
|
{
|
2006-02-15 18:44:15 -05:00
|
|
|
FadeInfo *info = data;
|
|
|
|
gdouble elapsed = g_timer_elapsed (info->timer, NULL);
|
|
|
|
gdouble alpha;
|
|
|
|
|
|
|
|
if (elapsed > FADE_TIME)
|
|
|
|
alpha = 0.0;
|
|
|
|
else
|
|
|
|
alpha = 1 - (elapsed / FADE_TIME);
|
|
|
|
|
|
|
|
cm_drawable_node_set_alpha (info->node, alpha);
|
|
|
|
|
2006-02-15 14:50:12 -05:00
|
|
|
#if 0
|
2006-02-15 18:44:15 -05:00
|
|
|
g_print ("fade out: %f\n", alpha);
|
2006-02-15 14:50:12 -05:00
|
|
|
#endif
|
2006-02-15 18:44:15 -05:00
|
|
|
|
|
|
|
if (elapsed >= FADE_TIME)
|
2006-02-06 17:47:13 -05:00
|
|
|
{
|
2006-03-03 10:53:10 -05:00
|
|
|
g_object_unref (info->node);
|
|
|
|
|
|
|
|
cm_drawable_node_set_viewable (info->node, FALSE);
|
|
|
|
|
|
|
|
return FALSE;
|
2006-02-06 17:47:13 -05:00
|
|
|
}
|
2006-02-15 18:44:15 -05:00
|
|
|
else
|
2006-02-06 17:47:13 -05:00
|
|
|
{
|
2006-02-15 18:44:15 -05:00
|
|
|
return TRUE;
|
2006-02-06 17:47:13 -05:00
|
|
|
}
|
|
|
|
}
|
2006-02-07 00:58:52 -05:00
|
|
|
#endif
|
2006-02-06 17:47:13 -05:00
|
|
|
|
2003-12-25 19:05:26 -05:00
|
|
|
#ifdef HAVE_COMPOSITE_EXTENSIONS
|
|
|
|
static void
|
|
|
|
process_map (MetaCompositor *compositor,
|
|
|
|
XMapEvent *event)
|
|
|
|
{
|
|
|
|
MetaScreen *screen;
|
2006-02-15 18:44:15 -05:00
|
|
|
|
2006-01-20 16:43:13 -05:00
|
|
|
/* FIXME: do we sometimes get mapnotifies for windows that are
|
|
|
|
* not (direct) children of the root?
|
|
|
|
*/
|
2006-01-13 14:41:01 -05:00
|
|
|
|
2003-12-25 19:05:26 -05:00
|
|
|
/* See if window was mapped as child of root */
|
2006-01-19 16:51:54 -05:00
|
|
|
screen = meta_display_screen_for_root (compositor->meta_display,
|
2006-01-13 14:41:01 -05:00
|
|
|
event->event);
|
2006-02-15 18:44:15 -05:00
|
|
|
|
2006-01-13 14:41:01 -05:00
|
|
|
if (screen == NULL)
|
2003-12-25 21:42:38 -05:00
|
|
|
{
|
|
|
|
meta_topic (META_DEBUG_COMPOSITOR,
|
2006-01-13 14:41:01 -05:00
|
|
|
"MapNotify received on non-root 0x%lx for 0x%lx\n",
|
|
|
|
event->event, event->window);
|
2003-12-25 19:05:26 -05:00
|
|
|
|
2006-03-03 10:53:10 -05:00
|
|
|
/* MapNotify wasn't for a child of the root */
|
|
|
|
return;
|
2003-12-25 19:05:26 -05:00
|
|
|
}
|
2006-02-15 18:44:15 -05:00
|
|
|
|
2006-05-04 13:32:26 -04:00
|
|
|
meta_comp_screen_add_window (screen->compositor_data,
|
2006-03-03 10:53:10 -05:00
|
|
|
event->window);
|
2003-12-25 19:05:26 -05:00
|
|
|
}
|
2006-03-03 10:53:10 -05:00
|
|
|
|
2003-12-25 19:05:26 -05:00
|
|
|
#endif /* HAVE_COMPOSITE_EXTENSIONS */
|
|
|
|
|
|
|
|
#ifdef HAVE_COMPOSITE_EXTENSIONS
|
|
|
|
static void
|
|
|
|
process_unmap (MetaCompositor *compositor,
|
|
|
|
XUnmapEvent *event)
|
|
|
|
{
|
|
|
|
MetaScreen *screen;
|
2006-02-15 18:44:15 -05:00
|
|
|
|
2003-12-25 19:05:26 -05:00
|
|
|
/* See if window was unmapped as child of root */
|
2006-01-19 16:51:54 -05:00
|
|
|
screen = meta_display_screen_for_root (compositor->meta_display,
|
2006-01-13 14:41:01 -05:00
|
|
|
event->event);
|
|
|
|
|
|
|
|
if (screen == NULL)
|
2003-12-25 21:42:38 -05:00
|
|
|
{
|
|
|
|
meta_topic (META_DEBUG_COMPOSITOR,
|
2006-01-13 14:41:01 -05:00
|
|
|
"UnmapNotify received on non-root 0x%lx for 0x%lx\n",
|
|
|
|
event->event, event->window);
|
2006-02-06 17:47:13 -05:00
|
|
|
|
2006-03-03 10:53:10 -05:00
|
|
|
/* UnmapNotify wasn't for a child of the root */
|
|
|
|
return;
|
2003-12-25 19:05:26 -05:00
|
|
|
}
|
2006-03-03 10:53:10 -05:00
|
|
|
|
2006-05-04 13:32:26 -04:00
|
|
|
meta_comp_screen_unmap (screen->compositor_data, event->window);
|
2003-12-25 19:05:26 -05:00
|
|
|
}
|
2006-03-03 10:53:10 -05:00
|
|
|
|
2003-12-25 19:05:26 -05:00
|
|
|
#endif /* HAVE_COMPOSITE_EXTENSIONS */
|
|
|
|
|
|
|
|
#ifdef HAVE_COMPOSITE_EXTENSIONS
|
|
|
|
static void
|
|
|
|
process_create (MetaCompositor *compositor,
|
|
|
|
XCreateWindowEvent *event)
|
|
|
|
{
|
|
|
|
MetaScreen *screen;
|
|
|
|
XWindowAttributes attrs;
|
2006-01-13 14:41:01 -05:00
|
|
|
|
2006-01-19 16:51:54 -05:00
|
|
|
screen = meta_display_screen_for_root (compositor->meta_display,
|
2006-01-13 14:41:01 -05:00
|
|
|
event->parent);
|
|
|
|
|
|
|
|
if (screen == NULL)
|
2003-12-25 21:42:38 -05:00
|
|
|
{
|
|
|
|
meta_topic (META_DEBUG_COMPOSITOR,
|
2006-01-13 14:41:01 -05:00
|
|
|
"CreateNotify received on non-root 0x%lx for 0x%lx\n",
|
|
|
|
event->parent, event->window);
|
2003-12-25 21:42:38 -05:00
|
|
|
return;
|
|
|
|
}
|
2006-01-13 14:41:01 -05:00
|
|
|
|
2006-01-19 16:51:54 -05:00
|
|
|
meta_error_trap_push_with_return (compositor->meta_display);
|
2003-12-25 19:05:26 -05:00
|
|
|
|
2006-01-19 16:51:54 -05:00
|
|
|
XGetWindowAttributes (compositor->meta_display->xdisplay,
|
2006-01-13 14:41:01 -05:00
|
|
|
event->window, &attrs);
|
2003-12-25 19:05:26 -05:00
|
|
|
|
2006-01-19 16:51:54 -05:00
|
|
|
if (meta_error_trap_pop_with_return (compositor->meta_display, TRUE) != Success)
|
2003-12-25 19:05:26 -05:00
|
|
|
{
|
|
|
|
meta_topic (META_DEBUG_COMPOSITOR, "Failed to get attributes for window 0x%lx\n",
|
2006-01-13 14:41:01 -05:00
|
|
|
event->window);
|
2003-12-25 19:05:26 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-02-15 14:50:12 -05:00
|
|
|
#if 0
|
2006-02-15 18:44:15 -05:00
|
|
|
g_print (//META_DEBUG_COMPOSITOR,
|
|
|
|
"Create window 0x%lx, adding\n", event->window);
|
2006-02-15 14:50:12 -05:00
|
|
|
#endif
|
2003-12-25 19:05:26 -05:00
|
|
|
meta_compositor_add_window (compositor,
|
2006-01-13 14:41:01 -05:00
|
|
|
event->window, &attrs);
|
2003-12-25 19:05:26 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif /* HAVE_COMPOSITE_EXTENSIONS */
|
|
|
|
|
|
|
|
#ifdef HAVE_COMPOSITE_EXTENSIONS
|
|
|
|
static void
|
|
|
|
process_destroy (MetaCompositor *compositor,
|
|
|
|
XDestroyWindowEvent *event)
|
|
|
|
{
|
|
|
|
MetaScreen *screen;
|
2006-01-13 14:41:01 -05:00
|
|
|
|
2006-01-19 16:51:54 -05:00
|
|
|
screen = meta_display_screen_for_root (compositor->meta_display,
|
2006-01-13 14:41:01 -05:00
|
|
|
event->event);
|
2006-03-22 13:34:18 -05:00
|
|
|
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
g_print ("destroywindow\n");
|
|
|
|
#endif
|
2006-01-13 14:41:01 -05:00
|
|
|
|
|
|
|
if (screen == NULL)
|
2003-12-25 21:42:38 -05:00
|
|
|
{
|
2006-03-22 13:34:18 -05:00
|
|
|
#if 0
|
|
|
|
g_print ("ignoring\n");
|
|
|
|
#endif
|
2003-12-25 21:42:38 -05:00
|
|
|
meta_topic (META_DEBUG_COMPOSITOR,
|
2006-01-13 14:41:01 -05:00
|
|
|
"DestroyNotify received on non-root 0x%lx for 0x%lx\n",
|
|
|
|
event->event, event->window);
|
2003-12-25 21:42:38 -05:00
|
|
|
return;
|
|
|
|
}
|
2006-01-13 14:41:01 -05:00
|
|
|
|
2003-12-25 21:42:38 -05:00
|
|
|
meta_topic (META_DEBUG_COMPOSITOR,
|
2006-01-13 14:41:01 -05:00
|
|
|
"Destroy window 0x%lx\n", event->window);
|
2003-12-25 19:05:26 -05:00
|
|
|
meta_compositor_remove_window (compositor, event->window);
|
|
|
|
}
|
|
|
|
#endif /* HAVE_COMPOSITE_EXTENSIONS */
|
|
|
|
|
2003-12-25 21:42:38 -05:00
|
|
|
|
|
|
|
#ifdef HAVE_COMPOSITE_EXTENSIONS
|
|
|
|
static void
|
|
|
|
process_reparent (MetaCompositor *compositor,
|
|
|
|
XReparentEvent *event)
|
|
|
|
{
|
|
|
|
/* Reparent from one screen to another doesn't happen now, but
|
|
|
|
* it's been suggested as a future extension
|
|
|
|
*/
|
|
|
|
MetaScreen *event_screen;
|
|
|
|
MetaScreen *parent_screen;
|
|
|
|
|
2006-01-19 16:51:54 -05:00
|
|
|
event_screen = meta_display_screen_for_root (compositor->meta_display,
|
2006-01-13 14:41:01 -05:00
|
|
|
event->event);
|
2006-02-15 18:44:15 -05:00
|
|
|
|
2006-01-13 14:41:01 -05:00
|
|
|
if (event_screen == NULL)
|
2003-12-25 21:42:38 -05:00
|
|
|
{
|
|
|
|
meta_topic (META_DEBUG_COMPOSITOR,
|
2006-01-13 14:41:01 -05:00
|
|
|
"ReparentNotify received on non-root 0x%lx for 0x%lx\n",
|
|
|
|
event->event, event->window);
|
2003-12-25 21:42:38 -05:00
|
|
|
return;
|
|
|
|
}
|
2006-03-03 10:53:10 -05:00
|
|
|
|
2006-01-19 16:51:54 -05:00
|
|
|
parent_screen = meta_display_screen_for_root (compositor->meta_display,
|
2006-01-13 14:41:01 -05:00
|
|
|
event->parent);
|
2003-12-25 21:42:38 -05:00
|
|
|
|
|
|
|
if (parent_screen == NULL)
|
|
|
|
{
|
|
|
|
meta_topic (META_DEBUG_COMPOSITOR,
|
2006-01-13 14:41:01 -05:00
|
|
|
"ReparentNotify 0x%lx to a non-screen or unmanaged screen 0x%lx\n",
|
|
|
|
event->window, event->parent);
|
2006-03-03 10:53:10 -05:00
|
|
|
|
2003-12-25 21:42:38 -05:00
|
|
|
meta_compositor_remove_window (compositor, event->window);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-05-04 13:32:26 -04:00
|
|
|
meta_comp_screen_raise_window (parent_screen->compositor_data,
|
2006-03-03 10:53:10 -05:00
|
|
|
event->window);
|
2003-12-25 21:42:38 -05:00
|
|
|
}
|
|
|
|
}
|
2006-03-03 10:53:10 -05:00
|
|
|
|
2003-12-25 21:42:38 -05:00
|
|
|
#endif /* HAVE_COMPOSITE_EXTENSIONS */
|
|
|
|
|
2003-11-15 23:35:16 -05:00
|
|
|
void
|
|
|
|
meta_compositor_process_event (MetaCompositor *compositor,
|
2003-11-23 13:16:01 -05:00
|
|
|
XEvent *event,
|
2003-11-15 23:35:16 -05:00
|
|
|
MetaWindow *window)
|
|
|
|
{
|
|
|
|
#ifdef HAVE_COMPOSITE_EXTENSIONS
|
|
|
|
if (!compositor->enabled)
|
|
|
|
return; /* no extension */
|
2006-01-13 14:41:01 -05:00
|
|
|
|
2003-12-25 21:42:38 -05:00
|
|
|
/* FIXME support CirculateNotify */
|
|
|
|
|
2006-01-13 14:41:01 -05:00
|
|
|
if (event->type == ConfigureNotify)
|
2003-11-23 13:16:01 -05:00
|
|
|
{
|
|
|
|
process_configure_notify (compositor,
|
2006-01-13 14:41:01 -05:00
|
|
|
(XConfigureEvent*) event);
|
2003-11-23 13:16:01 -05:00
|
|
|
}
|
2003-11-29 22:30:27 -05:00
|
|
|
else if (event->type == Expose)
|
|
|
|
{
|
|
|
|
process_expose (compositor,
|
2006-01-13 14:41:01 -05:00
|
|
|
(XExposeEvent*) event);
|
2003-11-29 22:30:27 -05:00
|
|
|
}
|
2003-12-25 19:05:26 -05:00
|
|
|
else if (event->type == UnmapNotify)
|
|
|
|
{
|
|
|
|
process_unmap (compositor,
|
2006-01-13 14:41:01 -05:00
|
|
|
(XUnmapEvent*) event);
|
2003-12-25 19:05:26 -05:00
|
|
|
}
|
|
|
|
else if (event->type == MapNotify)
|
|
|
|
{
|
|
|
|
process_map (compositor,
|
2006-01-13 14:41:01 -05:00
|
|
|
(XMapEvent*) event);
|
2003-12-25 19:05:26 -05:00
|
|
|
}
|
2003-12-25 21:42:38 -05:00
|
|
|
else if (event->type == ReparentNotify)
|
|
|
|
{
|
|
|
|
process_reparent (compositor,
|
2006-01-13 14:41:01 -05:00
|
|
|
(XReparentEvent*) event);
|
2003-12-25 21:42:38 -05:00
|
|
|
}
|
2003-12-25 19:05:26 -05:00
|
|
|
else if (event->type == CreateNotify)
|
|
|
|
{
|
|
|
|
process_create (compositor,
|
2006-01-13 14:41:01 -05:00
|
|
|
(XCreateWindowEvent*) event);
|
2003-12-25 19:05:26 -05:00
|
|
|
}
|
|
|
|
else if (event->type == DestroyNotify)
|
|
|
|
{
|
|
|
|
process_destroy (compositor,
|
2006-01-13 14:41:01 -05:00
|
|
|
(XDestroyWindowEvent*) event);
|
2003-12-25 19:05:26 -05:00
|
|
|
}
|
|
|
|
|
2003-11-15 23:35:16 -05:00
|
|
|
#endif /* HAVE_COMPOSITE_EXTENSIONS */
|
|
|
|
}
|
|
|
|
|
2006-02-28 14:51:45 -05:00
|
|
|
static GTimer *timer;
|
|
|
|
|
2006-02-02 18:02:21 -05:00
|
|
|
#ifdef HAVE_COMPOSITE_EXTENSIONS
|
|
|
|
static void
|
|
|
|
dump_stacking_order (GList *nodes)
|
|
|
|
{
|
2006-02-15 18:44:15 -05:00
|
|
|
GList *list;
|
|
|
|
|
|
|
|
for (list = nodes; list != NULL; list = list->next)
|
2006-02-02 18:02:21 -05:00
|
|
|
{
|
2006-02-15 18:44:15 -05:00
|
|
|
CmDrawableNode *node = list->data;
|
|
|
|
|
|
|
|
g_print ("%lx, ", WS_RESOURCE_XID (node->drawable));
|
2006-02-02 18:02:21 -05:00
|
|
|
}
|
2006-02-15 18:44:15 -05:00
|
|
|
g_print ("\n");
|
2006-02-02 18:02:21 -05:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2003-11-15 23:35:16 -05:00
|
|
|
/* This is called when metacity does its XQueryTree() on startup
|
2003-11-23 13:16:01 -05:00
|
|
|
* and when a new window is mapped.
|
2003-11-15 23:35:16 -05:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
meta_compositor_add_window (MetaCompositor *compositor,
|
|
|
|
Window xwindow,
|
|
|
|
XWindowAttributes *attrs)
|
|
|
|
{
|
|
|
|
#ifdef HAVE_COMPOSITE_EXTENSIONS
|
2006-03-03 10:53:10 -05:00
|
|
|
MetaScreen *screen = meta_screen_for_x_screen (attrs->screen);
|
2006-05-04 13:32:26 -04:00
|
|
|
MetaCompScreen *minfo = screen->compositor_data;
|
2006-02-15 18:44:15 -05:00
|
|
|
|
2006-05-04 13:32:26 -04:00
|
|
|
meta_comp_screen_add_window (minfo, xwindow);
|
2006-02-23 15:41:53 -05:00
|
|
|
#endif
|
2003-11-15 23:35:16 -05:00
|
|
|
}
|
2006-03-03 10:53:10 -05:00
|
|
|
|
2003-11-20 21:32:05 -05:00
|
|
|
void
|
|
|
|
meta_compositor_remove_window (MetaCompositor *compositor,
|
|
|
|
Window xwindow)
|
|
|
|
{
|
|
|
|
#ifdef HAVE_COMPOSITE_EXTENSIONS
|
2006-05-04 13:32:26 -04:00
|
|
|
MetaCompScreen *minfo;
|
2003-11-23 13:16:01 -05:00
|
|
|
|
2006-05-04 13:32:26 -04:00
|
|
|
minfo = meta_comp_screen_get_by_xwindow (xwindow);
|
2006-03-22 13:34:18 -05:00
|
|
|
|
|
|
|
if (minfo)
|
2006-05-04 13:32:26 -04:00
|
|
|
meta_comp_screen_remove_window (minfo, xwindow);
|
2003-11-20 21:32:05 -05:00
|
|
|
#endif /* HAVE_COMPOSITE_EXTENSIONS */
|
|
|
|
}
|
2003-11-15 23:35:16 -05:00
|
|
|
|
2003-11-20 21:32:05 -05:00
|
|
|
void
|
|
|
|
meta_compositor_manage_screen (MetaCompositor *compositor,
|
|
|
|
MetaScreen *screen)
|
|
|
|
{
|
|
|
|
#ifdef HAVE_COMPOSITE_EXTENSIONS
|
2006-05-04 13:32:26 -04:00
|
|
|
MetaCompScreen *info;
|
2006-03-03 10:53:10 -05:00
|
|
|
|
|
|
|
if (screen->compositor_data)
|
|
|
|
return;
|
|
|
|
|
2006-05-04 13:32:26 -04:00
|
|
|
info = meta_comp_screen_new (compositor->display, screen);
|
2006-03-03 10:53:10 -05:00
|
|
|
|
|
|
|
screen->compositor_data = info;
|
|
|
|
|
2006-05-04 13:32:26 -04:00
|
|
|
meta_comp_screen_redirect (info);
|
2006-01-13 14:41:01 -05:00
|
|
|
#endif
|
2003-11-20 21:32:05 -05:00
|
|
|
}
|
2003-11-15 23:35:16 -05:00
|
|
|
|
2003-11-20 21:32:05 -05:00
|
|
|
void
|
|
|
|
meta_compositor_unmanage_screen (MetaCompositor *compositor,
|
|
|
|
MetaScreen *screen)
|
|
|
|
{
|
2006-03-03 10:53:10 -05:00
|
|
|
#ifdef HAVE_COMPOSITE_EXTENSIONS
|
2006-05-04 13:32:26 -04:00
|
|
|
MetaCompScreen *info = screen->compositor_data;
|
2006-02-15 18:44:15 -05:00
|
|
|
|
2006-05-04 13:32:26 -04:00
|
|
|
meta_comp_screen_unredirect (info);
|
2006-02-15 18:44:15 -05:00
|
|
|
screen->compositor_data = NULL;
|
2006-03-03 10:53:10 -05:00
|
|
|
#endif
|
2003-11-20 21:32:05 -05:00
|
|
|
}
|
2003-11-15 23:35:16 -05:00
|
|
|
|
2006-01-14 16:51:46 -05:00
|
|
|
#ifdef HAVE_COMPOSITE_EXTENSIONS
|
2006-02-15 14:50:12 -05:00
|
|
|
#endif
|
2003-11-29 22:30:27 -05:00
|
|
|
|
2006-01-13 14:41:01 -05:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
double x;
|
|
|
|
double y;
|
|
|
|
double width;
|
|
|
|
double height;
|
|
|
|
} DoubleRect;
|
|
|
|
|
2006-02-06 17:47:13 -05:00
|
|
|
#if 0
|
2006-01-13 14:41:01 -05:00
|
|
|
static gdouble
|
|
|
|
interpolate (gdouble t, gdouble begin, gdouble end, double power)
|
|
|
|
{
|
|
|
|
return (begin + (end - begin) * pow (t, power));
|
|
|
|
}
|
2006-02-06 17:47:13 -05:00
|
|
|
#endif
|
2006-01-13 14:41:01 -05:00
|
|
|
|
2006-02-02 18:02:21 -05:00
|
|
|
#if 0
|
2006-01-13 14:41:01 -05:00
|
|
|
static gboolean
|
|
|
|
stop_minimize (gpointer data)
|
|
|
|
{
|
|
|
|
MiniInfo *info = data;
|
|
|
|
|
2006-01-20 16:43:13 -05:00
|
|
|
g_source_remove (info->repaint_id);
|
2006-01-13 14:41:01 -05:00
|
|
|
|
2006-01-20 16:43:13 -05:00
|
|
|
cm_drawable_node_set_deformation_func (info->node, NULL, NULL);
|
2006-02-15 18:44:15 -05:00
|
|
|
|
2006-01-13 14:41:01 -05:00
|
|
|
if (info->finished_func)
|
|
|
|
info->finished_func (info->finished_data);
|
2006-02-15 18:44:15 -05:00
|
|
|
|
2006-01-13 14:41:01 -05:00
|
|
|
g_free (info);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
2006-02-02 18:02:21 -05:00
|
|
|
#endif
|
2006-01-13 14:41:01 -05:00
|
|
|
|
2006-02-02 18:02:21 -05:00
|
|
|
#if 0
|
2006-01-13 14:41:01 -05:00
|
|
|
static void
|
|
|
|
minimize_deformation (gdouble time,
|
|
|
|
double in_x,
|
|
|
|
double in_y,
|
|
|
|
double *out_x,
|
|
|
|
double *out_y,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
#define MINIMIZE_TIME 0.5
|
|
|
|
MiniInfo *info = data;
|
|
|
|
gdouble elapsed;
|
|
|
|
gdouble pos;
|
|
|
|
|
|
|
|
if (info->start_time == -1)
|
|
|
|
info->start_time = time;
|
|
|
|
|
|
|
|
elapsed = time - info->start_time;
|
|
|
|
pos = elapsed / MINIMIZE_TIME;
|
|
|
|
|
|
|
|
*out_x = interpolate (pos, in_x, info->target.x + info->target.width * ((in_x - info->start.x) / info->start.width), 10 * in_y);
|
|
|
|
*out_y = interpolate (pos, in_y, info->target.y + info->target.height * ((in_y - info->start.y) / info->start.height), 1.0);
|
2006-02-15 18:44:15 -05:00
|
|
|
|
2006-01-13 14:41:01 -05:00
|
|
|
if (elapsed > MINIMIZE_TIME)
|
|
|
|
{
|
|
|
|
g_assert (info->node);
|
|
|
|
if (!info->idle_id)
|
|
|
|
info->idle_id = g_idle_add (stop_minimize, info);
|
|
|
|
}
|
|
|
|
}
|
2006-02-16 19:00:24 -05:00
|
|
|
#endif
|
|
|
|
|
2006-02-15 14:50:12 -05:00
|
|
|
void
|
|
|
|
meta_compositor_set_updates (MetaCompositor *compositor,
|
|
|
|
MetaWindow *window,
|
|
|
|
gboolean updates)
|
|
|
|
{
|
2006-02-16 16:03:02 -05:00
|
|
|
#ifdef HAVE_COMPOSITE_EXTENSIONS
|
2006-05-04 13:32:26 -04:00
|
|
|
MetaCompScreen *info = window->screen->compositor_data;
|
2006-02-15 18:44:15 -05:00
|
|
|
|
2006-05-04 13:32:26 -04:00
|
|
|
meta_comp_screen_set_updates (info, get_xid (window), updates);
|
2006-02-16 16:03:02 -05:00
|
|
|
#endif
|
2006-02-15 14:50:12 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef HAVE_COMPOSITE_EXTENSIONS
|
|
|
|
|
|
|
|
#define BALLOON_TIME 2
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
CmDrawableNode *node;
|
|
|
|
MetaAnimationFinishedFunc finished;
|
|
|
|
gpointer finished_data;
|
|
|
|
GTimer *timer;
|
|
|
|
} BalloonInfo;
|
|
|
|
|
2006-02-16 16:03:02 -05:00
|
|
|
#endif
|
2006-02-15 18:44:15 -05:00
|
|
|
|
|
|
|
void
|
|
|
|
meta_compositor_destroy (MetaCompositor *compositor)
|
|
|
|
{
|
|
|
|
#ifdef HAVE_COMPOSITE_EXTENSIONS
|
|
|
|
g_free (compositor);
|
|
|
|
#endif
|
|
|
|
}
|
2006-02-25 11:54:39 -05:00
|
|
|
|
|
|
|
#ifdef HAVE_COMPOSITE_EXTENSIONS
|
|
|
|
|
|
|
|
struct MoveInfo
|
|
|
|
{
|
|
|
|
GTimer *timer;
|
|
|
|
gboolean finished;
|
|
|
|
Model *model;
|
|
|
|
MetaScreen *screen;
|
2006-03-03 10:53:10 -05:00
|
|
|
MetaWindow *window;
|
2006-02-25 11:54:39 -05:00
|
|
|
gdouble last_time;
|
2006-03-14 12:00:56 -05:00
|
|
|
gboolean window_destroyed;
|
2006-03-30 16:39:00 -05:00
|
|
|
MetaCompositor *compositor;
|
2006-02-25 11:54:39 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_COMPOSITE_EXTENSIONS
|
|
|
|
|
2006-03-03 10:53:10 -05:00
|
|
|
static void
|
|
|
|
get_patch_points (Model *model,
|
|
|
|
CmPoint points[4][4])
|
|
|
|
{
|
|
|
|
int i, j;
|
|
|
|
|
|
|
|
for (i = 0; i < 4; i++)
|
|
|
|
{
|
|
|
|
for (j = 0; j < 4; j++)
|
|
|
|
{
|
|
|
|
double obj_x, obj_y;
|
|
|
|
|
|
|
|
model_get_position (model, i, j, &obj_x, &obj_y);
|
|
|
|
|
|
|
|
points[j][i].x = obj_x;
|
|
|
|
points[j][i].y = obj_y;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-03-30 17:01:45 -05:00
|
|
|
static GList *move_infos;
|
|
|
|
|
2006-02-25 11:54:39 -05:00
|
|
|
static gboolean
|
|
|
|
wobble (gpointer data)
|
|
|
|
{
|
|
|
|
MoveInfo *info = data;
|
2006-05-04 13:32:26 -04:00
|
|
|
MetaCompScreen *minfo = info->screen->compositor_data;
|
2006-02-25 11:54:39 -05:00
|
|
|
double t = g_timer_elapsed (info->timer, NULL);
|
2006-03-14 12:00:56 -05:00
|
|
|
|
2006-03-30 16:14:56 -05:00
|
|
|
#if 0
|
2006-03-14 12:00:56 -05:00
|
|
|
g_print ("info->window_destroyed: %d\n",
|
|
|
|
info->window_destroyed);
|
2006-03-30 16:14:56 -05:00
|
|
|
#endif
|
2006-03-14 12:00:56 -05:00
|
|
|
if ((info->finished && model_is_calm (info->model)) ||
|
|
|
|
info->window_destroyed)
|
2006-02-25 11:54:39 -05:00
|
|
|
{
|
2006-03-14 12:00:56 -05:00
|
|
|
if (!info->window_destroyed)
|
2006-05-04 13:32:26 -04:00
|
|
|
meta_comp_screen_unset_patch (minfo, get_xid (info->window));
|
2006-03-30 17:01:45 -05:00
|
|
|
|
|
|
|
move_infos = g_list_remove (move_infos, info);
|
2006-02-25 11:54:39 -05:00
|
|
|
g_free (info);
|
2006-03-30 17:01:45 -05:00
|
|
|
#if 0
|
2006-03-03 10:53:10 -05:00
|
|
|
g_print ("stop wobb\n");
|
2006-03-30 17:01:45 -05:00
|
|
|
#endif
|
2006-02-25 11:54:39 -05:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int n_steps;
|
2006-03-03 10:53:10 -05:00
|
|
|
CmPoint points[4][4];
|
2006-02-25 11:54:39 -05:00
|
|
|
n_steps = floor ((t - info->last_time) * 75);
|
|
|
|
|
|
|
|
for (i = 0; i < n_steps; ++i)
|
|
|
|
model_step (info->model);
|
2006-03-03 10:53:10 -05:00
|
|
|
|
2006-02-25 11:54:39 -05:00
|
|
|
if (i > 0)
|
|
|
|
info->last_time = t;
|
|
|
|
|
2006-03-03 10:53:10 -05:00
|
|
|
get_patch_points (info->model, points);
|
2006-05-04 13:32:26 -04:00
|
|
|
meta_comp_screen_set_patch (minfo,
|
2006-03-03 10:53:10 -05:00
|
|
|
get_xid (info->window),
|
|
|
|
points);
|
2006-02-25 11:54:39 -05:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static void
|
|
|
|
compute_window_rect (MetaWindow *window,
|
|
|
|
MetaRectangle *rect)
|
|
|
|
{
|
|
|
|
/* FIXME: does metacity include this function somewhere? */
|
|
|
|
|
|
|
|
if (window->frame)
|
|
|
|
{
|
|
|
|
*rect = window->frame->rect;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*rect = window->user_rect;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
meta_compositor_begin_move (MetaCompositor *compositor,
|
|
|
|
MetaWindow *window,
|
|
|
|
MetaRectangle *initial,
|
|
|
|
int grab_x, int grab_y)
|
|
|
|
{
|
|
|
|
#ifdef HAVE_COMPOSITE_EXTENSIONS
|
|
|
|
MetaRectangle rect;
|
2006-03-30 17:01:45 -05:00
|
|
|
MoveInfo *move_info;
|
2006-03-03 10:53:10 -05:00
|
|
|
|
2006-03-31 12:25:02 -05:00
|
|
|
#if 0
|
2006-03-03 10:53:10 -05:00
|
|
|
g_print ("begin move\n");
|
2006-03-31 12:25:02 -05:00
|
|
|
#endif
|
|
|
|
|
|
|
|
if (!g_getenv ("USE_WOBBLY"))
|
|
|
|
return;
|
2006-02-25 11:54:39 -05:00
|
|
|
|
2006-03-30 17:01:45 -05:00
|
|
|
move_info = g_new0 (MoveInfo, 1);
|
|
|
|
|
|
|
|
move_infos = g_list_prepend (move_infos, move_info);
|
2006-02-25 11:54:39 -05:00
|
|
|
|
2006-03-30 17:01:45 -05:00
|
|
|
move_info->compositor = compositor;
|
|
|
|
move_info->last_time = 0.0;
|
|
|
|
move_info->timer = g_timer_new ();
|
|
|
|
move_info->window_destroyed = FALSE;
|
2006-02-25 11:54:39 -05:00
|
|
|
|
|
|
|
compute_window_rect (window, &rect);
|
|
|
|
|
2006-03-30 16:39:00 -05:00
|
|
|
#if 0
|
2006-02-25 11:54:39 -05:00
|
|
|
g_print ("init: %d %d\n", initial->x, initial->y);
|
|
|
|
g_print ("window: %d %d\n", window->rect.x, window->rect.y);
|
|
|
|
g_print ("frame: %d %d\n", rect.x, rect.y);
|
|
|
|
g_print ("grab: %d %d\n", grab_x, grab_y);
|
2006-03-30 16:39:00 -05:00
|
|
|
#endif
|
2006-02-25 11:54:39 -05:00
|
|
|
|
2006-03-30 17:01:45 -05:00
|
|
|
move_info->model = model_new (&rect, TRUE);
|
|
|
|
move_info->window = window;
|
|
|
|
move_info->screen = window->screen;
|
2006-02-25 11:54:39 -05:00
|
|
|
|
2006-03-30 17:01:45 -05:00
|
|
|
model_begin_move (move_info->model, grab_x, grab_y);
|
2006-02-25 11:54:39 -05:00
|
|
|
|
2006-03-30 17:01:45 -05:00
|
|
|
g_idle_add (wobble, move_info);
|
2006-02-25 11:54:39 -05:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2006-03-30 17:01:45 -05:00
|
|
|
#ifdef HAVE_COMPOSITE_EXTENSIONS
|
|
|
|
static MoveInfo *
|
|
|
|
find_info (MetaWindow *window)
|
|
|
|
{
|
|
|
|
GList *list;
|
|
|
|
|
|
|
|
for (list = move_infos; list != NULL; list = list->next)
|
|
|
|
{
|
|
|
|
MoveInfo *info = list->data;
|
|
|
|
|
|
|
|
if (info->window == window)
|
|
|
|
return info;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2006-02-25 11:54:39 -05:00
|
|
|
void
|
|
|
|
meta_compositor_update_move (MetaCompositor *compositor,
|
|
|
|
MetaWindow *window,
|
|
|
|
int x, int y)
|
|
|
|
{
|
|
|
|
#ifdef HAVE_COMPOSITE_EXTENSIONS
|
2006-03-30 17:01:45 -05:00
|
|
|
MoveInfo *move_info = find_info (window);
|
|
|
|
|
2006-03-31 12:25:02 -05:00
|
|
|
if (!g_getenv ("USE_WOBBLY"))
|
|
|
|
return;
|
|
|
|
|
2006-03-30 17:01:45 -05:00
|
|
|
model_update_move (move_info->model, x, y);
|
2006-02-25 11:54:39 -05:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
meta_compositor_end_move (MetaCompositor *compositor,
|
|
|
|
MetaWindow *window)
|
|
|
|
{
|
|
|
|
#ifdef HAVE_COMPOSITE_EXTENSIONS
|
2006-03-30 17:01:45 -05:00
|
|
|
MoveInfo *info = find_info (window);
|
|
|
|
|
2006-03-31 12:25:02 -05:00
|
|
|
if (!g_getenv ("USE_WOBBLY"))
|
|
|
|
return;
|
|
|
|
|
2006-03-30 17:01:45 -05:00
|
|
|
info->finished = TRUE;
|
2006-03-14 12:00:56 -05:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
meta_compositor_free_window (MetaCompositor *compositor,
|
|
|
|
MetaWindow *window)
|
|
|
|
{
|
|
|
|
#ifdef HAVE_COMPOSITE_EXTENSIONS
|
2006-03-30 17:01:45 -05:00
|
|
|
MoveInfo *info = find_info (window);
|
|
|
|
|
2006-03-31 12:25:02 -05:00
|
|
|
if (!g_getenv ("USE_WOBBLY"))
|
|
|
|
return;
|
|
|
|
|
2006-03-30 17:01:45 -05:00
|
|
|
if (info)
|
|
|
|
info->window_destroyed = TRUE;
|
2006-03-14 12:00:56 -05:00
|
|
|
#endif
|
2006-02-25 11:54:39 -05:00
|
|
|
}
|