Actually commit the stuff mentioned in the last ChangeLog entry.

2005-05-26  Ray Strode  <rstrode@redhat.com>

	Actually commit the stuff mentioned in the last
	ChangeLog entry.
This commit is contained in:
Ray Strode 2005-05-26 19:58:17 +00:00 committed by Ray Strode
parent 2e0d27d0f1
commit 7b416a0a2d
9 changed files with 240 additions and 99 deletions

View File

@ -1,3 +1,8 @@
2005-05-26 Ray Strode <rstrode@redhat.com>
Actually commit the stuff mentioned in the last
ChangeLog entry.
2005-05-26 Ray Strode <rstrode@redhat.com> 2005-05-26 Ray Strode <rstrode@redhat.com>
Add a resize popup when resizing constrained Add a resize popup when resizing constrained

View File

@ -3265,23 +3265,8 @@ meta_display_begin_grab_op (MetaDisplay *display,
if (display->grab_wireframe_active) if (display->grab_wireframe_active)
{ {
MetaRectangle xor_rect;
display->grab_wireframe_rect = window->rect;
if (window->frame)
{
display->grab_wireframe_rect.x += window->frame->rect.x;
display->grab_wireframe_rect.y += window->frame->rect.y;
}
meta_window_calc_showing (display->grab_window); meta_window_calc_showing (display->grab_window);
meta_window_begin_wireframe (window);
meta_window_get_xor_rect (window, &display->grab_wireframe_rect,
&xor_rect);
meta_effects_begin_wireframe (display->grab_window->screen,
&xor_rect);
display->grab_wireframe_last_xor_rect = xor_rect;
} }
#ifdef HAVE_XSYNC #ifdef HAVE_XSYNC
@ -3432,8 +3417,8 @@ meta_display_end_grab_op (MetaDisplay *display,
if (display->grab_wireframe_active) if (display->grab_wireframe_active)
{ {
display->grab_wireframe_active = FALSE; display->grab_wireframe_active = FALSE;
meta_effects_end_wireframe (display->grab_window->screen, meta_window_end_wireframe (display->grab_window);
&display->grab_wireframe_last_xor_rect);
if (!display->grab_was_cancelled) if (!display->grab_was_cancelled)
meta_window_move_resize (display->grab_window, meta_window_move_resize (display->grab_window,
TRUE, TRUE,

View File

@ -274,6 +274,8 @@ struct _MetaDisplay
MetaResizePopup *grab_resize_popup; MetaResizePopup *grab_resize_popup;
GTimeVal grab_last_moveresize_time; GTimeVal grab_last_moveresize_time;
Time grab_motion_notify_time; Time grab_motion_notify_time;
int grab_wireframe_last_display_width;
int grab_wireframe_last_display_height;
GList* grab_old_window_stacking; GList* grab_old_window_stacking;
/* we use property updates as sentinels for certain window focus events /* we use property updates as sentinels for certain window focus events

View File

@ -28,6 +28,8 @@
#include <X11/extensions/shape.h> #include <X11/extensions/shape.h>
#endif #endif
#include <string.h>
typedef enum typedef enum
{ {
META_ANIMATION_DRAW_ROOT, META_ANIMATION_DRAW_ROOT,
@ -429,18 +431,24 @@ meta_effects_draw_box_animation (MetaScreen *screen,
void void
meta_effects_begin_wireframe (MetaScreen *screen, meta_effects_begin_wireframe (MetaScreen *screen,
const MetaRectangle *rect) const MetaRectangle *rect,
int width,
int height)
{ {
/* Grab the X server to avoid screen dirt */ /* Grab the X server to avoid screen dirt */
meta_display_grab (screen->display); meta_display_grab (screen->display);
meta_ui_push_delay_exposes (screen->ui); meta_ui_push_delay_exposes (screen->ui);
meta_effects_update_wireframe (screen, NULL, rect); meta_effects_update_wireframe (screen,
NULL, -1, -1,
rect, width, height);
} }
static void static void
draw_xor_rect (MetaScreen *screen, draw_xor_rect (MetaScreen *screen,
const MetaRectangle *rect) const MetaRectangle *rect,
int width,
int height)
{ {
/* The lines in the center can't overlap the rectangle or each /* The lines in the center can't overlap the rectangle or each
* other, or the XOR gets reversed. So we have to draw things * other, or the XOR gets reversed. So we have to draw things
@ -462,6 +470,68 @@ draw_xor_rect (MetaScreen *screen,
rect->height < (LINE_WIDTH * 4)) rect->height < (LINE_WIDTH * 4))
return; return;
if ((width >= 0) && (height >= 0))
{
int box_width, box_height;
XGCValues gc_values = { 0 };
if (XGetGCValues (screen->display->xdisplay,
screen->root_xor_gc,
GCFont, &gc_values))
{
char *text;
int text_length;
XFontStruct *font_struct;
int text_width, text_height;
int box_x, box_y;
font_struct = XQueryFont (screen->display->xdisplay,
gc_values.font);
if (font_struct != NULL)
{
text = g_strdup_printf ("%d x %d", width, height);
text_length = strlen (text);
text_width = text_length * font_struct->max_bounds.width;
text_height = font_struct->max_bounds.descent +
font_struct->max_bounds.ascent;
box_width = text_width + 2 * LINE_WIDTH;
box_height = text_height + 2 * LINE_WIDTH;
box_x = rect->x + (rect->width - box_width) / 2;
box_y = rect->y + (rect->height - box_height) / 2;
if ((box_width < rect->width) &&
(box_height < rect->height))
{
XFillRectangle (screen->display->xdisplay,
screen->xroot,
screen->root_xor_gc,
box_x, box_y,
box_width, box_height);
XDrawString (screen->display->xdisplay,
screen->xroot,
screen->root_xor_gc,
box_x + LINE_WIDTH,
box_y + LINE_WIDTH + font_struct->max_bounds.ascent,
text, text_length);
}
g_free (text);
}
}
if ((box_width + LINE_WIDTH) >= (rect->width / 3))
return;
if ((box_height + LINE_WIDTH) >= (rect->height / 3))
return;
}
/* Two vertical lines at 1/3 and 2/3 */ /* Two vertical lines at 1/3 and 2/3 */
segments[0].x1 = rect->x + rect->width / 3; segments[0].x1 = rect->x + rect->width / 3;
segments[0].y1 = rect->y + LINE_WIDTH / 2 + LINE_WIDTH % 2; segments[0].y1 = rect->y + LINE_WIDTH / 2 + LINE_WIDTH % 2;
@ -511,22 +581,30 @@ draw_xor_rect (MetaScreen *screen,
void void
meta_effects_update_wireframe (MetaScreen *screen, meta_effects_update_wireframe (MetaScreen *screen,
const MetaRectangle *old_rect, const MetaRectangle *old_rect,
const MetaRectangle *new_rect) int old_width,
int old_height,
const MetaRectangle *new_rect,
int new_width,
int new_height)
{ {
if (old_rect) if (old_rect)
draw_xor_rect (screen, old_rect); draw_xor_rect (screen, old_rect, old_width, old_height);
if (new_rect) if (new_rect)
draw_xor_rect (screen, new_rect); draw_xor_rect (screen, new_rect, new_width, new_height);
XFlush (screen->display->xdisplay); XFlush (screen->display->xdisplay);
} }
void void
meta_effects_end_wireframe (MetaScreen *screen, meta_effects_end_wireframe (MetaScreen *screen,
const MetaRectangle *old_rect) const MetaRectangle *old_rect,
int old_width,
int old_height)
{ {
meta_effects_update_wireframe (screen, old_rect, NULL); meta_effects_update_wireframe (screen,
old_rect, old_width, old_height,
NULL, -1, -1);
meta_display_ungrab (screen->display); meta_display_ungrab (screen->display);
meta_ui_pop_delay_exposes (screen->ui); meta_ui_pop_delay_exposes (screen->ui);

View File

@ -42,11 +42,19 @@ void meta_effects_draw_box_animation (MetaScreen *screen,
MetaBoxAnimType anim_type); MetaBoxAnimType anim_type);
void meta_effects_begin_wireframe (MetaScreen *screen, void meta_effects_begin_wireframe (MetaScreen *screen,
const MetaRectangle *rect); const MetaRectangle *rect,
int width,
int height);
void meta_effects_update_wireframe (MetaScreen *screen, void meta_effects_update_wireframe (MetaScreen *screen,
const MetaRectangle *old_rect, const MetaRectangle *old_rect,
const MetaRectangle *new_rect); int old_width,
int old_height,
const MetaRectangle *new_rect,
int new_width,
int new_height);
void meta_effects_end_wireframe (MetaScreen *screen, void meta_effects_end_wireframe (MetaScreen *screen,
const MetaRectangle *old_rect); const MetaRectangle *old_rect,
int width,
int height);
#endif /* META_EFFECTS_H */ #endif /* META_EFFECTS_H */

View File

@ -1825,18 +1825,9 @@ process_keyboard_move_grab (MetaDisplay *display,
x, y); x, y);
if (display->grab_wireframe_active) if (display->grab_wireframe_active)
{ {
MetaRectangle new_xor; meta_window_update_wireframe (window, x, y,
display->grab_wireframe_rect.width,
display->grab_wireframe_rect.x = x; display->grab_wireframe_rect.height);
display->grab_wireframe_rect.y = y;
meta_window_get_xor_rect (window, &display->grab_wireframe_rect,
&new_xor);
meta_effects_update_wireframe (window->screen,
&display->grab_wireframe_last_xor_rect,
&new_xor);
display->grab_wireframe_last_xor_rect = new_xor;
} }
else else
{ {
@ -2286,24 +2277,7 @@ process_keyboard_resize_grab (MetaDisplay *display,
if (display->grab_wireframe_active) if (display->grab_wireframe_active)
{ {
MetaRectangle new_xor; meta_window_update_wireframe (window, x, y, width, height);
window->display->grab_wireframe_rect.x = x;
window->display->grab_wireframe_rect.y = y;
window->display->grab_wireframe_rect.width = width;
window->display->grab_wireframe_rect.height = height;
meta_window_get_xor_rect (window,
&window->display->grab_wireframe_rect,
&new_xor);
meta_effects_update_wireframe (window->screen,
&window->display->grab_wireframe_last_xor_rect,
&new_xor);
window->display->grab_wireframe_last_xor_rect = new_xor;
/* do this after drawing the wires, so we don't draw over it */
meta_window_refresh_resize_popup (window);
} }
else else
{ {

View File

@ -551,10 +551,12 @@ meta_screen_new (MetaDisplay *display,
gc_values.subwindow_mode = IncludeInferiors; gc_values.subwindow_mode = IncludeInferiors;
gc_values.function = GXinvert; gc_values.function = GXinvert;
gc_values.line_width = META_WIREFRAME_XOR_LINE_WIDTH; gc_values.line_width = META_WIREFRAME_XOR_LINE_WIDTH;
gc_values.font = XLoadFont (screen->display->xdisplay,
"-misc-fixed-*-*-*-*-16-*-*-*-*-*-*-*");
screen->root_xor_gc = XCreateGC (screen->display->xdisplay, screen->root_xor_gc = XCreateGC (screen->display->xdisplay,
screen->xroot, screen->xroot,
GCSubwindowMode | GCFunction | GCLineWidth, GCSubwindowMode | GCFunction | GCLineWidth | GCFont,
&gc_values); &gc_values);
} }

View File

@ -2892,6 +2892,9 @@ meta_window_move_resize_internal (MetaWindow *window,
meta_topic (META_DEBUG_GEOMETRY, "Size/position not modified\n"); meta_topic (META_DEBUG_GEOMETRY, "Size/position not modified\n");
} }
if (window->display->grab_wireframe_active)
meta_window_update_wireframe (window, root_x_nw, root_y_nw, w, h);
else
meta_window_refresh_resize_popup (window); meta_window_refresh_resize_popup (window);
/* Invariants leaving this function are: /* Invariants leaving this function are:
@ -3343,6 +3346,105 @@ meta_window_get_xor_rect (MetaWindow *window,
*xor_rect = *grab_wireframe_rect; *xor_rect = *grab_wireframe_rect;
} }
/* Figure out the numbers that show up in the
* resize popup when in reduced resources mode.
*/
static void
meta_window_get_wireframe_geometry (MetaWindow *window,
int *width,
int *height)
{
if (!window->display->grab_wireframe_active)
return;
if ((width == NULL) || (height == NULL))
return;
if ((window->display->grab_window->size_hints.width_inc <= 1) ||
(window->display->grab_window->size_hints.height_inc <= 1))
{
*width = -1;
*height = -1;
return;
}
*width = window->display->grab_wireframe_rect.width -
window->display->grab_window->size_hints.base_width;
*width /= window->display->grab_window->size_hints.width_inc;
*height = window->display->grab_wireframe_rect.height -
window->display->grab_window->size_hints.base_height;
*height /= window->display->grab_window->size_hints.height_inc;
}
void
meta_window_begin_wireframe (MetaWindow *window)
{
MetaRectangle new_xor;
int display_width, display_height;
window->display->grab_wireframe_rect = window->rect;
if (window->frame)
{
window->display->grab_wireframe_rect.x += window->frame->rect.x;
window->display->grab_wireframe_rect.y += window->frame->rect.y;
}
meta_window_get_xor_rect (window, &window->display->grab_wireframe_rect,
&new_xor);
meta_window_get_wireframe_geometry (window, &display_width, &display_height);
meta_effects_begin_wireframe (window->screen,
&new_xor, display_width, display_height);
window->display->grab_wireframe_last_xor_rect = new_xor;
window->display->grab_wireframe_last_display_width = display_width;
window->display->grab_wireframe_last_display_height = display_height;
}
void
meta_window_update_wireframe (MetaWindow *window,
int x,
int y,
int width,
int height)
{
MetaRectangle new_xor;
int display_width, display_height;
window->display->grab_wireframe_rect.x = x;
window->display->grab_wireframe_rect.y = y;
window->display->grab_wireframe_rect.width = width;
window->display->grab_wireframe_rect.height = height;
meta_window_get_xor_rect (window, &window->display->grab_wireframe_rect,
&new_xor);
meta_window_get_wireframe_geometry (window, &display_width, &display_height);
meta_effects_update_wireframe (window->screen,
&window->display->grab_wireframe_last_xor_rect,
window->display->grab_wireframe_last_display_width,
window->display->grab_wireframe_last_display_height,
&new_xor, display_width, display_height);
window->display->grab_wireframe_last_xor_rect = new_xor;
window->display->grab_wireframe_last_display_width = display_width;
window->display->grab_wireframe_last_display_height = display_height;
}
void
meta_window_end_wireframe (MetaWindow *window)
{
meta_effects_end_wireframe (window->display->grab_window->screen,
&window->display->grab_wireframe_last_xor_rect,
window->display->grab_wireframe_last_display_width,
window->display->grab_wireframe_last_display_height);
}
const char* const char*
meta_window_get_startup_id (MetaWindow *window) meta_window_get_startup_id (MetaWindow *window)
{ {
@ -6386,19 +6488,9 @@ update_move (MetaWindow *window,
/* FIXME Horribly broken, does not honor position /* FIXME Horribly broken, does not honor position
* constraints * constraints
*/ */
MetaRectangle new_xor; meta_window_update_wireframe (window, new_x, new_y,
window->display->grab_wireframe_rect.width,
window->display->grab_wireframe_rect.x = new_x; window->display->grab_wireframe_rect.height);
window->display->grab_wireframe_rect.y = new_y;
meta_window_get_xor_rect (window,
&window->display->grab_wireframe_rect,
&new_xor);
meta_effects_update_wireframe (window->screen,
&window->display->grab_wireframe_last_xor_rect,
&new_xor);
window->display->grab_wireframe_last_xor_rect = new_xor;
} }
else else
{ {
@ -6536,6 +6628,9 @@ update_resize (MetaWindow *window,
if (window->display->grab_wireframe_active) if (window->display->grab_wireframe_active)
{ {
if ((new_x + new_w <= new_x) || (new_y + new_h <= new_y))
return;
/* FIXME This is crap. For example, the wireframe isn't /* FIXME This is crap. For example, the wireframe isn't
* constrained in the way that a real resize would be. An * constrained in the way that a real resize would be. An
* obvious elegant solution is to unmap the window during * obvious elegant solution is to unmap the window during
@ -6543,26 +6638,7 @@ update_resize (MetaWindow *window,
* confuses broken clients that have problems with opaque * confuses broken clients that have problems with opaque
* resize, they probably don't track their visibility. * resize, they probably don't track their visibility.
*/ */
MetaRectangle new_xor; meta_window_update_wireframe (window, new_x, new_y, new_w, new_h);
if ((new_x + new_w <= new_x) || (new_y + new_h <= new_y))
return;
window->display->grab_wireframe_rect.x = new_x;
window->display->grab_wireframe_rect.y = new_y;
window->display->grab_wireframe_rect.width = new_w;
window->display->grab_wireframe_rect.height = new_h;
meta_window_get_xor_rect (window, &window->display->grab_wireframe_rect,
&new_xor);
meta_effects_update_wireframe (window->screen,
&window->display->grab_wireframe_last_xor_rect,
&new_xor);
window->display->grab_wireframe_last_xor_rect = new_xor;
/* do this after drawing the wires, so we don't draw over it */
meta_window_refresh_resize_popup (window);
} }
else else
{ {
@ -6955,12 +7031,15 @@ meta_window_refresh_resize_popup (MetaWindow *window)
if (window->display->grab_window != window) if (window->display->grab_window != window)
return; return;
/* FIXME for now we bail out when doing wireframe, because our /* We shouldn't ever get called when the wireframe is active
* server grab keeps us from being able to redraw the stuff * because that's handled by a different code path in effects.c
* underneath the resize popup.
*/ */
if (window->display->grab_wireframe_active) if (window->display->grab_wireframe_active)
{
meta_topic (META_DEBUG_WINDOW_OPS,
"refresh_resize_popup called when wireframe active\n");
return; return;
}
switch (window->display->grab_op) switch (window->display->grab_op)
{ {

View File

@ -432,6 +432,14 @@ void meta_window_get_outer_rect (MetaWindow *window,
void meta_window_get_xor_rect (MetaWindow *window, void meta_window_get_xor_rect (MetaWindow *window,
const MetaRectangle *grab_wireframe_rect, const MetaRectangle *grab_wireframe_rect,
MetaRectangle *xor_rect); MetaRectangle *xor_rect);
void meta_window_begin_wireframe (MetaWindow *window);
void meta_window_update_wireframe (MetaWindow *window,
int x,
int y,
int width,
int height);
void meta_window_end_wireframe (MetaWindow *window);
void meta_window_delete (MetaWindow *window, void meta_window_delete (MetaWindow *window,
Time timestamp); Time timestamp);
void meta_window_kill (MetaWindow *window); void meta_window_kill (MetaWindow *window);