disable animation when shading windows, just doesn't really convey the

2002-07-28  Havoc Pennington  <hp@pobox.com>

	* src/window.c (meta_window_shade): disable animation when shading
	windows, just doesn't really convey the idea anyway.

	* src/effects.c: Move to using a shaped window instead of
	IncludeInferiors to do the animations, looks a lot better
	because we don't have to grab the server.

	* src/window.c (meta_window_change_workspace): remove bogus
	assertion that was causing a crash
	(meta_window_new): auto-fullscreen huge undecorated windows.

	* src/keybindings.c (switch_to_workspace): use
	meta_window_change_workspace() to avoid same bug in cut-and-paste
	code from there
This commit is contained in:
Havoc Pennington 2002-08-06 04:11:23 +00:00 committed by Havoc Pennington
parent f15e959634
commit 00dcef82e3
9 changed files with 1162 additions and 118 deletions

View File

@ -1,3 +1,20 @@
2002-07-28 Havoc Pennington <hp@pobox.com>
* src/window.c (meta_window_shade): disable animation when shading
windows, just doesn't really convey the idea anyway.
* src/effects.c: Move to using a shaped window instead of
IncludeInferiors to do the animations, looks a lot better
because we don't have to grab the server.
* src/window.c (meta_window_change_workspace): remove bogus
assertion that was causing a crash
(meta_window_new): auto-fullscreen huge undecorated windows.
* src/keybindings.c (switch_to_workspace): use
meta_window_change_workspace() to avoid same bug in cut-and-paste
code from there
2002-08-06 He Qiangqiang <carton@linux.net.cn>
* configure.in: Added "zh_CN" to ALL_LINGUAS.

View File

@ -112,14 +112,18 @@ do
echo "Running libtoolize..."
libtoolize --force --copy
fi
echo "Running $ACLOCAL $aclocalinclude ..."
$ACLOCAL $aclocalinclude
if grep "^AM_CONFIG_HEADER" configure.in >/dev/null; then
echo "Running autoheader..."
autoheader
fi
echo "Running $AUTOMAKE --gnu $am_opt ..."
$AUTOMAKE --add-missing --gnu $am_opt
echo "Running autoconf ..."
autoconf
)

File diff suppressed because it is too large Load Diff

View File

@ -24,13 +24,28 @@
#include "util.h"
#include "window.h"
#include "frame.h"
typedef enum
{
META_RESIZE_LEFT_OR_TOP,
META_RESIZE_CENTER,
META_RESIZE_RIGHT_OR_BOTTOM
} MetaResizeDirection;
void meta_window_constrain (MetaWindow *window,
MetaFrameGeometry *fgeom,
int resize_gravity,
const MetaRectangle *orig,
int x_move_delta,
int y_move_delta,
MetaResizeDirection x_direction,
int x_delta,
MetaResizeDirection y_direction,
int y_delta,
MetaRectangle *new);
MetaResizeDirection meta_x_direction_from_gravity (int gravity);
MetaResizeDirection meta_y_direction_from_gravity (int gravity);
#endif /* META_CONSTRAINTS_H */

View File

@ -633,6 +633,8 @@ meta_display_close (MetaDisplay *display)
if (display->leader_window != None)
XDestroyWindow (display->xdisplay, display->leader_window);
XFlush (display->xdisplay);
#ifndef USE_GDK_DISPLAY
meta_event_queue_free (display->events);
XCloseDisplay (display->xdisplay);

View File

@ -19,10 +19,23 @@
* 02111-1307, USA.
*/
#include <config.h>
#include "effects.h"
#include "display.h"
#include "ui.h"
#ifdef HAVE_SHAPE
#include <X11/extensions/shape.h>
#endif
typedef enum
{
META_ANIMATION_DRAW_ROOT,
META_ANIMATION_WINDOW_WIREFRAME,
META_ANIMATION_WINDOW_OPAQUE
} MetaAnimationStyle;
typedef struct
{
MetaScreen *screen;
@ -41,11 +54,14 @@ typedef struct
/* used instead of the global flag, since
* we don't want to change midstream.
*/
gboolean use_opaque;
MetaAnimationStyle style;
/* For wireframe */
/* For wireframe drawn on root window */
GC gc;
/* For wireframe window */
Window wireframe_xwindow;
/* For opaque */
MetaImageWindow *image_window;
GdkPixbuf *orig_pixbuf;
@ -54,6 +70,61 @@ typedef struct
} BoxAnimationContext;
static void
update_wireframe_window (MetaDisplay *display,
Window xwindow,
const MetaRectangle *rect)
{
XMoveResizeWindow (display->xdisplay,
xwindow,
rect->x, rect->y,
rect->width, rect->height);
#ifdef HAVE_SHAPE
#define OUTLINE_WIDTH 3
if (rect->width > OUTLINE_WIDTH * 2 &&
rect->height > OUTLINE_WIDTH * 2)
{
XRectangle xrect;
Region inner_xregion;
Region outer_xregion;
inner_xregion = XCreateRegion ();
outer_xregion = XCreateRegion ();
xrect.x = 0;
xrect.y = 0;
xrect.width = rect->width;
xrect.height = rect->height;
XUnionRectWithRegion (&xrect, outer_xregion, outer_xregion);
xrect.x += OUTLINE_WIDTH;
xrect.y += OUTLINE_WIDTH;
xrect.width -= OUTLINE_WIDTH * 2;
xrect.height -= OUTLINE_WIDTH * 2;
XUnionRectWithRegion (&xrect, inner_xregion, inner_xregion);
XSubtractRegion (outer_xregion, inner_xregion, outer_xregion);
XShapeCombineRegion (display->xdisplay, xwindow,
ShapeBounding, 0, 0, outer_xregion, ShapeSet);
XDestroyRegion (outer_xregion);
XDestroyRegion (inner_xregion);
}
else
{
/* Unset the shape */
XShapeCombineMask (display->xdisplay, xwindow,
ShapeBounding, 0, 0, None, ShapeSet);
}
#endif
}
static gboolean
effects_draw_box_animation_timeout (BoxAnimationContext *context)
{
@ -64,7 +135,7 @@ effects_draw_box_animation_timeout (BoxAnimationContext *context)
if (!context->first_time)
{
if (!context->use_opaque)
if (context->style == META_ANIMATION_DRAW_ROOT)
{
/* Restore the previously drawn background */
XDrawRectangle (context->screen->display->xdisplay,
@ -94,18 +165,23 @@ effects_draw_box_animation_timeout (BoxAnimationContext *context)
if (elapsed > context->millisecs_duration)
{
/* All done */
if (context->use_opaque)
if (context->style == META_ANIMATION_WINDOW_OPAQUE)
{
g_object_unref (G_OBJECT (context->orig_pixbuf));
meta_image_window_free (context->image_window);
}
else
else if (context->style == META_ANIMATION_DRAW_ROOT)
{
meta_display_ungrab (context->screen->display);
meta_ui_pop_delay_exposes (context->screen->ui);
XFreeGC (context->screen->display->xdisplay,
context->gc);
}
else if (context->style == META_ANIMATION_WINDOW_WIREFRAME)
{
XDestroyWindow (context->screen->display->xdisplay,
context->wireframe_xwindow);
}
g_free (context);
return FALSE;
@ -130,7 +206,7 @@ effects_draw_box_animation_timeout (BoxAnimationContext *context)
context->last_rect = draw_rect;
if (context->use_opaque)
if (context->style == META_ANIMATION_WINDOW_OPAQUE)
{
GdkPixbuf *scaled;
@ -174,7 +250,7 @@ effects_draw_box_animation_timeout (BoxAnimationContext *context)
g_object_unref (G_OBJECT (scaled));
}
}
else
else if (context->style == META_ANIMATION_DRAW_ROOT)
{
/* Draw the rectangle */
XDrawRectangle (context->screen->display->xdisplay,
@ -183,6 +259,12 @@ effects_draw_box_animation_timeout (BoxAnimationContext *context)
draw_rect.x, draw_rect.y,
draw_rect.width, draw_rect.height);
}
else if (context->style == META_ANIMATION_WINDOW_WIREFRAME)
{
update_wireframe_window (context->screen->display,
context->wireframe_xwindow,
&draw_rect);
}
/* kick changes onto the server */
XFlush (context->screen->display->xdisplay);
@ -198,7 +280,7 @@ effects_draw_box_animation_timeout (BoxAnimationContext *context)
* and unmapping of windows that's going on.
*/
static gboolean use_opaque_animations = FALSE;
static MetaAnimationStyle animation_style = META_ANIMATION_WINDOW_WIREFRAME;
void
meta_effects_draw_box_animation (MetaScreen *screen,
@ -225,9 +307,14 @@ meta_effects_draw_box_animation (MetaScreen *screen,
context->end_rect = *destination_rect;
context->anim_type = anim_type;
context->use_opaque = use_opaque_animations;
context->style = animation_style;
if (context->use_opaque)
#ifndef HAVE_SHAPE
if (context->style == META_ANIMATION_WINDOW_WIREFRAME)
context->style = META_ANIMATION_DRAW_ROOT;
#endif
if (context->style == META_ANIMATION_WINDOW_OPAQUE)
{
GdkPixbuf *pix;
@ -242,7 +329,7 @@ meta_effects_draw_box_animation (MetaScreen *screen,
if (pix == NULL)
{
/* Fall back to wireframe */
context->use_opaque = FALSE;
context->style = META_ANIMATION_WINDOW_WIREFRAME;
}
else
{
@ -258,7 +345,36 @@ meta_effects_draw_box_animation (MetaScreen *screen,
}
/* Not an else, so that fallback works */
if (!context->use_opaque)
if (context->style == META_ANIMATION_WINDOW_WIREFRAME)
{
XSetWindowAttributes attrs;
attrs.override_redirect = True;
attrs.background_pixel = BlackPixel (screen->display->xdisplay,
screen->number);
context->wireframe_xwindow = XCreateWindow (screen->display->xdisplay,
screen->xroot,
initial_rect->x,
initial_rect->y,
initial_rect->width,
initial_rect->height,
0,
CopyFromParent,
CopyFromParent,
CopyFromParent,
CWOverrideRedirect | CWBackPixel,
&attrs);
update_wireframe_window (screen->display,
context->wireframe_xwindow,
initial_rect);
XMapWindow (screen->display->xdisplay,
context->wireframe_xwindow);
}
if (context->style == META_ANIMATION_DRAW_ROOT)
{
XGCValues gc_values;

View File

@ -729,6 +729,8 @@ meta_display_init_keys (MetaDisplay *display)
void
meta_display_shutdown_keys (MetaDisplay *display)
{
/* Note that display->xdisplay is invalid in this function */
meta_prefs_remove_listener (bindings_changed_callback, display);
if (display->keymap)
@ -1995,12 +1997,8 @@ switch_to_workspace (MetaDisplay *display,
if (move_window)
{
/* Lamely rely on prepend */
g_assert (move_window->workspaces->data == workspace);
while (move_window->workspaces->next) /* while list size > 1 */
meta_workspace_remove_window (move_window->workspaces->next->data,
move_window);
/* Removes window from other spaces */
meta_window_change_workspace (move_window, workspace);
}
}

View File

@ -535,6 +535,7 @@ meta_screen_free (MetaScreen *screen)
g_free (screen->screen_name);
g_free (screen);
XFlush (display->xdisplay);
meta_display_ungrab (display);
}

View File

@ -627,6 +627,24 @@ meta_window_new (MetaDisplay *display, Window xwindow,
outer.height >= workarea.height)
meta_window_maximize (window);
}
/* Assume screen-size undecorated windows are intended to be
* fullscreen
*/
else if (window->has_fullscreen_func && !window->decorated &&
!window->maximized)
{
const MetaXineramaScreenInfo *xinerama;
MetaRectangle outer;
xinerama = meta_screen_get_xinerama_for_window (window->screen,
window);
meta_window_get_outer_rect (window, &outer);
if (outer.width >= xinerama->width &&
outer.height >= xinerama->height)
meta_window_make_fullscreen (window);
}
/* Sync stack changes */
meta_stack_thaw (window->screen->stack);
@ -1661,6 +1679,7 @@ meta_window_shade (MetaWindow *window)
"Shading %s\n", window->desc);
if (!window->shaded)
{
#if 0
if (window->mapped)
{
/* Animation */
@ -1682,6 +1701,7 @@ meta_window_shade (MetaWindow *window)
META_SHADE_ANIMATION_LENGTH,
META_BOX_ANIM_SLIDE_UP);
}
#endif
window->shaded = TRUE;
@ -2786,24 +2806,34 @@ void
meta_window_change_workspace (MetaWindow *window,
MetaWorkspace *workspace)
{
GList *next;
meta_verbose ("Changing window %s to workspace %d\n",
window->desc, meta_workspace_index (workspace));
/* See if we're already on this space. If not, make sure we are */
if (g_list_find (window->workspaces, workspace) == NULL)
{
meta_workspace_add_window (workspace, window);
}
/* unstick if stuck */
if (window->on_all_workspaces)
meta_window_unstick (window);
/* Lamely rely on prepend */
g_assert (window->workspaces->data == workspace);
/* Remove from all other spaces */
while (window->workspaces->next) /* while list size > 1 */
meta_workspace_remove_window (window->workspaces->next->data, window);
next = window->workspaces;
while (next != NULL)
{
MetaWorkspace *remove;
remove = next->data;
next = next->next;
if (remove != workspace)
meta_workspace_remove_window (remove, window);
}
/* list size == 1 */
g_assert (window->workspaces != NULL);
g_assert (window->workspaces->next == NULL);
}
void