mirror of
https://github.com/brl/mutter.git
synced 2024-11-21 23:50:41 -05:00
Bounce on window focus.
This commit is contained in:
parent
5af52e9fe1
commit
76dff49a3e
12
ChangeLog
12
ChangeLog
@ -1,3 +1,15 @@
|
|||||||
|
2006-05-25 Adam Jackson <ajax@freedesktop.org>
|
||||||
|
|
||||||
|
* src/c-window.c:
|
||||||
|
* src/c-window.h:
|
||||||
|
* src/compositor.c:
|
||||||
|
* src/compositor.h:
|
||||||
|
* src/effects.c:
|
||||||
|
* src/effects.h:
|
||||||
|
* src/spring-model.c:
|
||||||
|
* src/window.c:
|
||||||
|
Bounce on window focus.
|
||||||
|
|
||||||
Wed May 24 22:15:01 2006 Søren Sandmann <sandmann@redhat.com>
|
Wed May 24 22:15:01 2006 Søren Sandmann <sandmann@redhat.com>
|
||||||
|
|
||||||
* src/compositor.c (do_effect): Make sure windows are kept on top
|
* src/compositor.c (do_effect): Make sure windows are kept on top
|
||||||
|
@ -34,6 +34,7 @@
|
|||||||
#include "c-window.h"
|
#include "c-window.h"
|
||||||
#include "window.h"
|
#include "window.h"
|
||||||
#include "frame.h"
|
#include "frame.h"
|
||||||
|
#include "spring-model.h"
|
||||||
|
|
||||||
struct _MetaCompWindow
|
struct _MetaCompWindow
|
||||||
{
|
{
|
||||||
@ -1093,6 +1094,72 @@ meta_comp_window_run_minimize (MetaCompWindow *window,
|
|||||||
g_idle_add (run_animation_01, info);
|
g_idle_add (run_animation_01, info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* bounce effect */
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
MetaEffect *effect;
|
||||||
|
MetaCompWindow *window;
|
||||||
|
GTimer *timer;
|
||||||
|
Model *model;
|
||||||
|
MetaRectangle rect;
|
||||||
|
gdouble last_time;
|
||||||
|
} BounceInfo;
|
||||||
|
|
||||||
|
/* XXX HATE */
|
||||||
|
extern void get_patch_points (Model *model, CmPoint points[4][4]);
|
||||||
|
extern void compute_window_rect (MetaWindow *window, MetaRectangle *rect);
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
update_bounce (gpointer data)
|
||||||
|
{
|
||||||
|
BounceInfo *info = data;
|
||||||
|
CmDrawableNode *node = (CmDrawableNode *)info->window->node;
|
||||||
|
gdouble elapsed = g_timer_elapsed (info->timer, NULL);
|
||||||
|
int i;
|
||||||
|
int n_steps = floor ((elapsed - info->last_time) * 60);
|
||||||
|
CmPoint points[4][4];
|
||||||
|
|
||||||
|
if (model_is_calm (info->model) || elapsed > 0.7)
|
||||||
|
{
|
||||||
|
cm_drawable_node_unset_patch (node);
|
||||||
|
meta_effect_end (info->effect);
|
||||||
|
g_free(info);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < n_steps; ++i)
|
||||||
|
model_step (info->model);
|
||||||
|
|
||||||
|
if (i > 0)
|
||||||
|
info->last_time = elapsed;
|
||||||
|
|
||||||
|
get_patch_points (info->model, points);
|
||||||
|
|
||||||
|
cm_drawable_node_set_patch (node, points);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
meta_comp_window_bounce (MetaCompWindow *comp_window,
|
||||||
|
MetaEffect *effect)
|
||||||
|
{
|
||||||
|
BounceInfo *info = g_new0 (BounceInfo, 1);
|
||||||
|
MetaWindow *meta_window =
|
||||||
|
meta_display_lookup_x_window (comp_window->display,
|
||||||
|
WS_RESOURCE_XID (comp_window->drawable));
|
||||||
|
|
||||||
|
info->window = comp_window;
|
||||||
|
info->effect = effect;
|
||||||
|
info->timer = g_timer_new ();
|
||||||
|
info->last_time = 0;
|
||||||
|
|
||||||
|
compute_window_rect (meta_window, &info->rect);
|
||||||
|
info->model = model_new (&info->rect, TRUE);
|
||||||
|
|
||||||
|
g_idle_add (update_bounce, info);
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
|
@ -45,6 +45,8 @@ void meta_comp_window_shrink (MetaCompWindow *comp_window,
|
|||||||
MetaEffect *effect);
|
MetaEffect *effect);
|
||||||
void meta_comp_window_unshrink (MetaCompWindow *comp_window,
|
void meta_comp_window_unshrink (MetaCompWindow *comp_window,
|
||||||
MetaEffect *effect);
|
MetaEffect *effect);
|
||||||
|
void meta_comp_window_bounce (MetaCompWindow *comp_window,
|
||||||
|
MetaEffect *effect);
|
||||||
void meta_comp_window_restack (MetaCompWindow *comp_window,
|
void meta_comp_window_restack (MetaCompWindow *comp_window,
|
||||||
MetaCompWindow *above);
|
MetaCompWindow *above);
|
||||||
void meta_comp_window_freeze_stack (MetaCompWindow *comp_window);
|
void meta_comp_window_freeze_stack (MetaCompWindow *comp_window);
|
||||||
|
@ -149,6 +149,15 @@ do_effect (MetaEffect *effect,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
case META_EFFECT_FOCUS:
|
||||||
|
{
|
||||||
|
MetaCompScreen *screen = meta_comp_screen_get_by_xwindow (
|
||||||
|
get_xid (effect->u.focus.window));
|
||||||
|
MetaCompWindow *window = meta_comp_screen_lookup_window (
|
||||||
|
screen, effect->u.focus.window->frame->xwindow);
|
||||||
|
meta_comp_window_bounce (window, effect);
|
||||||
|
break;
|
||||||
|
}
|
||||||
case META_EFFECT_CLOSE:
|
case META_EFFECT_CLOSE:
|
||||||
{
|
{
|
||||||
MetaCompScreen *screen = meta_comp_screen_get_by_xwindow (
|
MetaCompScreen *screen = meta_comp_screen_get_by_xwindow (
|
||||||
@ -780,7 +789,7 @@ struct MoveInfo
|
|||||||
|
|
||||||
#ifdef HAVE_COMPOSITE_EXTENSIONS
|
#ifdef HAVE_COMPOSITE_EXTENSIONS
|
||||||
|
|
||||||
static void
|
void
|
||||||
get_patch_points (Model *model,
|
get_patch_points (Model *model,
|
||||||
CmPoint points[4][4])
|
CmPoint points[4][4])
|
||||||
{
|
{
|
||||||
@ -850,7 +859,7 @@ wobble (gpointer data)
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void
|
void
|
||||||
compute_window_rect (MetaWindow *window,
|
compute_window_rect (MetaWindow *window,
|
||||||
MetaRectangle *rect)
|
MetaRectangle *rect)
|
||||||
{
|
{
|
||||||
|
@ -27,6 +27,9 @@
|
|||||||
|
|
||||||
typedef void (* MetaAnimationFinishedFunc) (gpointer data);
|
typedef void (* MetaAnimationFinishedFunc) (gpointer data);
|
||||||
|
|
||||||
|
/* XXX namespace me */
|
||||||
|
void compute_window_rect (MetaWindow *window, MetaRectangle *rect);
|
||||||
|
|
||||||
MetaCompositor* meta_compositor_new (MetaDisplay *display);
|
MetaCompositor* meta_compositor_new (MetaDisplay *display);
|
||||||
void meta_compositor_unref (MetaCompositor *compositor);
|
void meta_compositor_unref (MetaCompositor *compositor);
|
||||||
void meta_compositor_process_event (MetaCompositor *compositor,
|
void meta_compositor_process_event (MetaCompositor *compositor,
|
||||||
|
@ -125,6 +125,21 @@ meta_effect_end (MetaEffect *effect)
|
|||||||
g_free (effect);
|
g_free (effect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
meta_effect_run_focus (MetaWindow *window,
|
||||||
|
MetaEffectFinished finished,
|
||||||
|
gpointer data)
|
||||||
|
{
|
||||||
|
MetaEffect *effect;
|
||||||
|
|
||||||
|
g_return_if_fail (window != NULL);
|
||||||
|
|
||||||
|
effect = create_effect (META_EFFECT_FOCUS, finished, data);
|
||||||
|
effect->u.focus.window = window;
|
||||||
|
|
||||||
|
run_handler (effect);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
meta_effect_run_minimize (MetaWindow *window,
|
meta_effect_run_minimize (MetaWindow *window,
|
||||||
MetaRectangle *window_rect,
|
MetaRectangle *window_rect,
|
||||||
|
@ -66,12 +66,12 @@ typedef struct
|
|||||||
MetaWindow *window;
|
MetaWindow *window;
|
||||||
MetaRectangle window_rect;
|
MetaRectangle window_rect;
|
||||||
MetaRectangle icon_rect;
|
MetaRectangle icon_rect;
|
||||||
} MetaMinimizeEffect, MetaRestoreEffect; /* same data for both */
|
} MetaMinimizeEffect, MetaRestoreEffect;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
MetaWindow *window;
|
MetaWindow *window;
|
||||||
} MetaCloseEffect;
|
} MetaCloseEffect, MetaFocusEffect;
|
||||||
|
|
||||||
struct MetaEffect
|
struct MetaEffect
|
||||||
{
|
{
|
||||||
@ -83,6 +83,7 @@ struct MetaEffect
|
|||||||
MetaMinimizeEffect minimize;
|
MetaMinimizeEffect minimize;
|
||||||
MetaRestoreEffect restore;
|
MetaRestoreEffect restore;
|
||||||
MetaCloseEffect close;
|
MetaCloseEffect close;
|
||||||
|
MetaFocusEffect focus;
|
||||||
} u;
|
} u;
|
||||||
|
|
||||||
MetaEffectPriv *priv;
|
MetaEffectPriv *priv;
|
||||||
@ -100,6 +101,9 @@ void meta_effect_run_minimize (MetaWindow *window,
|
|||||||
void meta_effect_run_close (MetaWindow *window,
|
void meta_effect_run_close (MetaWindow *window,
|
||||||
MetaEffectFinished finished,
|
MetaEffectFinished finished,
|
||||||
gpointer data);
|
gpointer data);
|
||||||
|
void meta_effect_run_focus (MetaWindow *window,
|
||||||
|
MetaEffectFinished finished,
|
||||||
|
gpointer data);
|
||||||
void meta_effect_end (MetaEffect *effect);
|
void meta_effect_end (MetaEffect *effect);
|
||||||
|
|
||||||
|
|
||||||
|
@ -205,15 +205,32 @@ model_init_grid (Model *model, MetaRectangle *rect, gboolean expand)
|
|||||||
hpad = rect->width / 6;
|
hpad = rect->width / 6;
|
||||||
vpad = rect->height / 6;
|
vpad = rect->height / 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define EXPAND_DELTA 4
|
||||||
|
|
||||||
for (y = 0; y < GRID_HEIGHT; y++)
|
for (y = 0; y < GRID_HEIGHT; y++)
|
||||||
for (x = 0; x < GRID_WIDTH; x++)
|
for (x = 0; x < GRID_WIDTH; x++)
|
||||||
{
|
{
|
||||||
#if 0
|
if (expand)
|
||||||
v_x = 40 * g_random_double() - 20;
|
{
|
||||||
v_y = 40 * g_random_double() - 20;
|
if (y == 0)
|
||||||
#endif
|
v_y = - EXPAND_DELTA * g_random_double();
|
||||||
v_x = v_y = 0;
|
else if (y == GRID_HEIGHT - 1)
|
||||||
|
v_y = EXPAND_DELTA * g_random_double();
|
||||||
|
else
|
||||||
|
v_y = 2 * EXPAND_DELTA * g_random_double() - EXPAND_DELTA;
|
||||||
|
|
||||||
|
if (x == 0)
|
||||||
|
v_x = - EXPAND_DELTA * g_random_double();
|
||||||
|
else if (x == GRID_WIDTH - 1)
|
||||||
|
v_x = EXPAND_DELTA * g_random_double();
|
||||||
|
else
|
||||||
|
v_x = 2 * EXPAND_DELTA * g_random_double() - EXPAND_DELTA;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
v_x = v_y = 0;
|
||||||
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
if (expand)
|
if (expand)
|
||||||
@ -355,7 +372,7 @@ on_end_move (Model *model)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#define EPSILON 0.01
|
#define EPSILON 0.02
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
model_is_calm (Model *model)
|
model_is_calm (Model *model)
|
||||||
|
@ -42,6 +42,7 @@
|
|||||||
#include "window-props.h"
|
#include "window-props.h"
|
||||||
#include "constraints.h"
|
#include "constraints.h"
|
||||||
#include "compositor.h"
|
#include "compositor.h"
|
||||||
|
#include "effects.h"
|
||||||
|
|
||||||
#include <X11/Xatom.h>
|
#include <X11/Xatom.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@ -3760,6 +3761,8 @@ meta_window_focus (MetaWindow *window,
|
|||||||
|
|
||||||
if (window->wm_state_demands_attention)
|
if (window->wm_state_demands_attention)
|
||||||
meta_window_unset_demands_attention(window);
|
meta_window_unset_demands_attention(window);
|
||||||
|
|
||||||
|
meta_effect_run_focus(window, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Loading…
Reference in New Issue
Block a user