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> 2002-08-06 He Qiangqiang <carton@linux.net.cn>
* configure.in: Added "zh_CN" to ALL_LINGUAS. * configure.in: Added "zh_CN" to ALL_LINGUAS.

View File

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

File diff suppressed because it is too large Load Diff

View File

@ -24,13 +24,28 @@
#include "util.h" #include "util.h"
#include "window.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, void meta_window_constrain (MetaWindow *window,
MetaFrameGeometry *fgeom, MetaFrameGeometry *fgeom,
int resize_gravity,
const MetaRectangle *orig, 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); MetaRectangle *new);
MetaResizeDirection meta_x_direction_from_gravity (int gravity);
MetaResizeDirection meta_y_direction_from_gravity (int gravity);
#endif /* META_CONSTRAINTS_H */ #endif /* META_CONSTRAINTS_H */

View File

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

View File

@ -19,10 +19,23 @@
* 02111-1307, USA. * 02111-1307, USA.
*/ */
#include <config.h>
#include "effects.h" #include "effects.h"
#include "display.h" #include "display.h"
#include "ui.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 typedef struct
{ {
MetaScreen *screen; MetaScreen *screen;
@ -41,11 +54,14 @@ typedef struct
/* used instead of the global flag, since /* used instead of the global flag, since
* we don't want to change midstream. * we don't want to change midstream.
*/ */
gboolean use_opaque; MetaAnimationStyle style;
/* For wireframe */ /* For wireframe drawn on root window */
GC gc; GC gc;
/* For wireframe window */
Window wireframe_xwindow;
/* For opaque */ /* For opaque */
MetaImageWindow *image_window; MetaImageWindow *image_window;
GdkPixbuf *orig_pixbuf; GdkPixbuf *orig_pixbuf;
@ -54,6 +70,61 @@ typedef struct
} BoxAnimationContext; } 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 static gboolean
effects_draw_box_animation_timeout (BoxAnimationContext *context) effects_draw_box_animation_timeout (BoxAnimationContext *context)
{ {
@ -64,7 +135,7 @@ effects_draw_box_animation_timeout (BoxAnimationContext *context)
if (!context->first_time) if (!context->first_time)
{ {
if (!context->use_opaque) if (context->style == META_ANIMATION_DRAW_ROOT)
{ {
/* Restore the previously drawn background */ /* Restore the previously drawn background */
XDrawRectangle (context->screen->display->xdisplay, XDrawRectangle (context->screen->display->xdisplay,
@ -94,18 +165,23 @@ effects_draw_box_animation_timeout (BoxAnimationContext *context)
if (elapsed > context->millisecs_duration) if (elapsed > context->millisecs_duration)
{ {
/* All done */ /* All done */
if (context->use_opaque) if (context->style == META_ANIMATION_WINDOW_OPAQUE)
{ {
g_object_unref (G_OBJECT (context->orig_pixbuf)); g_object_unref (G_OBJECT (context->orig_pixbuf));
meta_image_window_free (context->image_window); meta_image_window_free (context->image_window);
} }
else else if (context->style == META_ANIMATION_DRAW_ROOT)
{ {
meta_display_ungrab (context->screen->display); meta_display_ungrab (context->screen->display);
meta_ui_pop_delay_exposes (context->screen->ui); meta_ui_pop_delay_exposes (context->screen->ui);
XFreeGC (context->screen->display->xdisplay, XFreeGC (context->screen->display->xdisplay,
context->gc); context->gc);
} }
else if (context->style == META_ANIMATION_WINDOW_WIREFRAME)
{
XDestroyWindow (context->screen->display->xdisplay,
context->wireframe_xwindow);
}
g_free (context); g_free (context);
return FALSE; return FALSE;
@ -130,7 +206,7 @@ effects_draw_box_animation_timeout (BoxAnimationContext *context)
context->last_rect = draw_rect; context->last_rect = draw_rect;
if (context->use_opaque) if (context->style == META_ANIMATION_WINDOW_OPAQUE)
{ {
GdkPixbuf *scaled; GdkPixbuf *scaled;
@ -174,7 +250,7 @@ effects_draw_box_animation_timeout (BoxAnimationContext *context)
g_object_unref (G_OBJECT (scaled)); g_object_unref (G_OBJECT (scaled));
} }
} }
else else if (context->style == META_ANIMATION_DRAW_ROOT)
{ {
/* Draw the rectangle */ /* Draw the rectangle */
XDrawRectangle (context->screen->display->xdisplay, XDrawRectangle (context->screen->display->xdisplay,
@ -183,6 +259,12 @@ effects_draw_box_animation_timeout (BoxAnimationContext *context)
draw_rect.x, draw_rect.y, draw_rect.x, draw_rect.y,
draw_rect.width, draw_rect.height); 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 */ /* kick changes onto the server */
XFlush (context->screen->display->xdisplay); XFlush (context->screen->display->xdisplay);
@ -198,7 +280,7 @@ effects_draw_box_animation_timeout (BoxAnimationContext *context)
* and unmapping of windows that's going on. * and unmapping of windows that's going on.
*/ */
static gboolean use_opaque_animations = FALSE; static MetaAnimationStyle animation_style = META_ANIMATION_WINDOW_WIREFRAME;
void void
meta_effects_draw_box_animation (MetaScreen *screen, meta_effects_draw_box_animation (MetaScreen *screen,
@ -225,9 +307,14 @@ meta_effects_draw_box_animation (MetaScreen *screen,
context->end_rect = *destination_rect; context->end_rect = *destination_rect;
context->anim_type = anim_type; 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; GdkPixbuf *pix;
@ -242,7 +329,7 @@ meta_effects_draw_box_animation (MetaScreen *screen,
if (pix == NULL) if (pix == NULL)
{ {
/* Fall back to wireframe */ /* Fall back to wireframe */
context->use_opaque = FALSE; context->style = META_ANIMATION_WINDOW_WIREFRAME;
} }
else else
{ {
@ -258,7 +345,36 @@ meta_effects_draw_box_animation (MetaScreen *screen,
} }
/* Not an else, so that fallback works */ /* 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; XGCValues gc_values;

View File

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

View File

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

View File

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