summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElijah Newren <newren@gmail.com>2005-11-19 01:04:06 +0000
committerElijah Newren <newren@src.gnome.org>2005-11-19 01:04:06 +0000
commit4455df299c2e11a761c735e6e10daaa4ddc2ffdd (patch)
tree14e4d4df8c276134f68eeb98449010628f9bad48
parente395f9c66efd14f307b283bf0f28d510e3d58d5d (diff)
downloadmetacity-4455df299c2e11a761c735e6e10daaa4ddc2ffdd.tar.gz
Do the cleanups requested by Havoc in his review.
2005-11-18 Elijah Newren <newren@gmail.com> Do the cleanups requested by Havoc in his review. * constraints-ideas.txt: Update for the recent changes * src/boxes.[ch]: (<general>): Fixup copyright information for meta_rectangle_(equal|intersect), remove PRINT_DEBUG #define (meta_rectangle_to_string): (meta_rectangle_region_to_string): (meta_rectangle_edge_to_string): (meta_rectangle_edge_list_to_string): remove hardcoded length of strings and use new (RECT|EDGE)_LENGTH #defines, s/snprintf/g_snprintf/ (merge_spanning_rects_in_region): (meta_rectangle_get_minimal_spanning_set_for_region): remove lots of overly verbose debugging spew that was #ifdef'd out anyway (meta_rectangle_find_linepoint_closest_to_point): fix up argument list and equations to follow coding style * src/constraints.c: (<general>): put #include <config.h> back in here, remove unneeded comment (enum ConstraintPriority): spaces around '=' (ConstraintFunc array all_constraints): (char* array all_constraint_names arrays): (struct Constraint): (Constraint array all_constraints): (do_all_constraints): get rid of the old two-array thing and just have the constraint function and names in one array tracking both fields (place_window_if_needed): make the single-direction maximization be a "hidden feature" only; don't auto-maximize in just a single direction (update_onscreen_requirements): (do_screen_and_xinerama_relative_constraints): add some commas that the compiler strangely never complained about missing before (constrain_to_single_xinerama): Don't apply this constraint for decorationless windows * src/place.c (find_first_fit): put an #ifdef WITH_VERBOSE_MODE around figuring out and logging the rectangle position * src/testboxes.c: (test_merge_regions): (test_regions_okay): (test_find_onscreen_edges): (test_find_nonintersected_xinerama_edges): remove hardcoded length of strings and use new (RECT|EDGE)_LENGTH #defines from boxes.[ch] * src/window.c: (meta_window_new_with_attrs): remove an unneeded comment (meta_window_move_resize_internal): rewrite the freakin' huge comment for clarity (meta_window_begin_wireframe): remove the comment explaining an easy fix and just fix it (update_move_timeout): remove an erroneous (copy & pasted) comment (meta_window_handle_mouse_grab_op_event): remove #ifdef'd out code * src/window.h (struct MetaWindow): simplify comment about window->rect * src/core.c (meta_core_maximize, meta_core_toggle_maximize, meta_core_unmaximize): * src/keybindings.c (handle_maximize_vert, handle_maximize_horiz, handle_toggle_maximize, handle_maximize, handle_unmaximize): * src/place.c (place_window_if_needed): * src/window.[ch] (meta_window_apply_session_info, meta_window_free, meta_window_maximize_internal, meta_window_maximize, meta_window_unmaximize, meta_window_client_message, menu_callback, update_move, enum MetaMaximizeFlags): change meta_window_(un)maximize(_internal) to use flags instead of boolean args
-rw-r--r--ChangeLog99
-rw-r--r--constraints-ideas.txt9
-rw-r--r--src/boxes.c179
-rw-r--r--src/boxes.h14
-rw-r--r--src/constraints.c106
-rw-r--r--src/core.c12
-rw-r--r--src/keybindings.c24
-rw-r--r--src/place.c4
-rw-r--r--src/testboxes.c18
-rw-r--r--src/window.c178
-rw-r--r--src/window.h33
11 files changed, 338 insertions, 338 deletions
diff --git a/ChangeLog b/ChangeLog
index 4c9a9861..b3a6b7f1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,104 @@
2005-11-18 Elijah Newren <newren@gmail.com>
+ Do the cleanups requested by Havoc in his review.
+
+ * constraints-ideas.txt: Update for the recent changes
+
+ * src/boxes.[ch]:
+
+ (<general>):
+ Fixup copyright information for meta_rectangle_(equal|intersect),
+ remove PRINT_DEBUG #define
+
+ (meta_rectangle_to_string):
+ (meta_rectangle_region_to_string):
+ (meta_rectangle_edge_to_string):
+ (meta_rectangle_edge_list_to_string):
+ remove hardcoded length of strings and use new (RECT|EDGE)_LENGTH
+ #defines, s/snprintf/g_snprintf/
+
+ (merge_spanning_rects_in_region):
+ (meta_rectangle_get_minimal_spanning_set_for_region):
+ remove lots of overly verbose debugging spew that was #ifdef'd out
+ anyway
+
+ (meta_rectangle_find_linepoint_closest_to_point):
+ fix up argument list and equations to follow coding style
+
+ * src/constraints.c:
+
+ (<general>):
+ put #include <config.h> back in here, remove unneeded comment
+
+ (enum ConstraintPriority):
+ spaces around '='
+
+ (ConstraintFunc array all_constraints):
+ (char* array all_constraint_names arrays):
+ (struct Constraint):
+ (Constraint array all_constraints):
+ (do_all_constraints):
+ get rid of the old two-array thing and just have the constraint
+ function and names in one array tracking both fields
+
+ (place_window_if_needed):
+ make the single-direction maximization be a "hidden feature" only;
+ don't auto-maximize in just a single direction
+
+ (update_onscreen_requirements):
+ (do_screen_and_xinerama_relative_constraints):
+ add some commas that the compiler strangely never complained about
+ missing before
+
+ (constrain_to_single_xinerama):
+ Don't apply this constraint for decorationless windows
+
+ * src/place.c (find_first_fit): put an #ifdef WITH_VERBOSE_MODE
+ around figuring out and logging the rectangle position
+
+ * src/testboxes.c:
+
+ (test_merge_regions):
+ (test_regions_okay):
+ (test_find_onscreen_edges):
+ (test_find_nonintersected_xinerama_edges):
+ remove hardcoded length of strings and use new (RECT|EDGE)_LENGTH
+ #defines from boxes.[ch]
+
+ * src/window.c:
+
+ (meta_window_new_with_attrs):
+ remove an unneeded comment
+
+ (meta_window_move_resize_internal):
+ rewrite the freakin' huge comment for clarity
+
+ (meta_window_begin_wireframe):
+ remove the comment explaining an easy fix and just fix it
+
+ (update_move_timeout):
+ remove an erroneous (copy & pasted) comment
+
+ (meta_window_handle_mouse_grab_op_event):
+ remove #ifdef'd out code
+
+ * src/window.h (struct MetaWindow): simplify comment about
+ window->rect
+
+ * src/core.c (meta_core_maximize, meta_core_toggle_maximize,
+ meta_core_unmaximize):
+ * src/keybindings.c (handle_maximize_vert, handle_maximize_horiz,
+ handle_toggle_maximize, handle_maximize, handle_unmaximize):
+ * src/place.c (place_window_if_needed):
+ * src/window.[ch] (meta_window_apply_session_info, meta_window_free,
+ meta_window_maximize_internal, meta_window_maximize,
+ meta_window_unmaximize, meta_window_client_message,
+ menu_callback, update_move, enum MetaMaximizeFlags):
+ change meta_window_(un)maximize(_internal) to use flags instead of
+ boolean args
+
+2005-11-18 Elijah Newren <newren@gmail.com>
+
Fix the breakage all these constraints_experiments changes caused
to reduced resources mode. Also fixes #304857 (wireframe can move
off the top of the screen despite the fact that the window won't
diff --git a/constraints-ideas.txt b/constraints-ideas.txt
index ff9d605c..ca27ad45 100644
--- a/constraints-ideas.txt
+++ b/constraints-ideas.txt
@@ -8,7 +8,7 @@ Short-term (I hope...) TODO list/reminders:
- Need to add my copyright info to all the modified files
- - Need to verify XRandR stuff appropriately invalidates the workarea
+ X Need to verify XRandR stuff appropriately invalidates the workarea
X Need to update the documentation; the huge comment is out of date and
misleading now
@@ -27,13 +27,15 @@ Short-term (I hope...) TODO list/reminders:
the window drift northwest. Very weird.
X Get rid of compiling warnings for constraints.c even if they're dumb
- - Should we turn off fully-onscreen & on-single-xinerama constraints
+ X Should we turn off fully-onscreen & on-single-xinerama constraints
for decorationless windows? Otherwise, most users (those that
don't know about alt-drag to move or alt+f7 to keyboard move)
won't be able to move xmms off their current xinerama onscreen
space. This might mean that users lose their window (dragging the
top of the window too far offscreen), but that might be a required
trade-off for having a stupid-app.
+ [Update: I decided to do so only for the on-single-xinerama
+ constraints]
- Brokenness left in aspect-ratio resizing:
X gtk+ seems to be doing nit-picky fighting with us over which way to
@@ -109,7 +111,7 @@ Short-term (I hope...) TODO list/reminders:
- spanning rects
- boxes.[ch] & testboxes.c
- - Questions for UI experts:
+ X Questions for UI experts:
- should I have left edges lining up to left edges of other
windows result in resistance as well, or just left edges lining
up against right edges as I currently do?
@@ -325,6 +327,7 @@ Bugs to fix:
319351 - don't instantly snap on mouse-move-snapping, remove
braindeadedness of having order of releasing shift and
releasing button press matter so much
+ 304857 - wireframe moving off the top of the screen is misleading
Some ideas:
- move_rectangle_into_region & clip_rectangle_into_region in
diff --git a/src/boxes.c b/src/boxes.c
index 975572b3..24c0e739 100644
--- a/src/boxes.c
+++ b/src/boxes.c
@@ -2,12 +2,11 @@
/*
* Copyright (C) 2005 Elijah Newren
- * [According to the ChangeLog, Anders, Havoc, and Rob were responsible
- * for the meta_rectangle_intersect() and meta_rectangle_equal()
- * functions that I copied from display.c]
- * Copyright (C) 2002 Anders Carlsson
+ * [meta_rectangle_intersect() is copyright the GTK+ Team according to Havoc,
+ * see gdkrectangle.c. As far as Havoc knows, he probably wrote
+ * meta_rectangle_equal(), and I'm guessing it's (C) Red Hat. So...]
+ * Copyright (C) 1995-2000 GTK+ Team
* Copyright (C) 2002 Red Hat, Inc.
- * Copyright (C) 2003 Rob Adams
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -30,21 +29,16 @@
#include <X11/Xutil.h> /* Just for the definition of the various gravities */
#include <stdio.h> /* For snprintf */
-/* PRINT_DEBUG may be useful to define when compiling the testboxes program if
- * any issues crop up.
- */
-/* #define PRINT_DEBUG */
-
char*
meta_rectangle_to_string (const MetaRectangle *rect,
char *output)
{
- /* 25 = 2 commas, space, plus, trailing \0 + 5 for each digit.
+ /* 25 chars: 2 commas, space, plus, trailing \0 + 5 for each digit.
* Should be more than enough space. Note that of this space, the
* trailing \0 will be overwritten for all but the last rectangle.
*/
- snprintf (output, 25, "%d,%d +%d,%d",
- rect->x, rect->y, rect->width, rect->height);
+ g_snprintf (output, RECT_LENGTH, "%d,%d +%d,%d",
+ rect->x, rect->y, rect->width, rect->height);
return output;
}
@@ -54,12 +48,12 @@ meta_rectangle_region_to_string (GList *region,
const char *separator_string,
char *output)
{
- /* 27 = 2 commas, 2 square brackets, space, plus, trailing \0 + 5 for
- * each digit. Should be more than enough space. Note that of this
+ /* 27 chars: 2 commas, 2 square brackets, space, plus, trailing \0 + 5
+ * for each digit. Should be more than enough space. Note that of this
* space, the trailing \0 will be overwritten for all but the last
* rectangle.
*/
- char rect_string[27];
+ char rect_string[RECT_LENGTH];
if (region == NULL)
snprintf (output, 10, "(EMPTY)");
@@ -69,8 +63,8 @@ meta_rectangle_region_to_string (GList *region,
while (tmp)
{
MetaRectangle *rect = tmp->data;
- snprintf (rect_string, 27, "[%d,%d +%d,%d]",
- rect->x, rect->y, rect->width, rect->height);
+ g_snprintf (rect_string, RECT_LENGTH, "[%d,%d +%d,%d]",
+ rect->x, rect->y, rect->width, rect->height);
cur = g_stpcpy (cur, rect_string);
tmp = tmp->next;
if (tmp)
@@ -84,16 +78,16 @@ char*
meta_rectangle_edge_to_string (const MetaEdge *edge,
char *output)
{
- /* 25 = 2 commas, space, plus, trailing \0 + 5 for each digit.
+ /* 25 chars: 2 commas, space, plus, trailing \0 + 5 for each digit.
* Should be more than enough space. Note that of this space, the
* trailing \0 will be overwritten for all but the last rectangle.
*
* Plus 2 for parenthesis, 4 for 2 more numbers, 2 more commas, and
* 2 more spaces, for a total of 10 more.
*/
- snprintf (output, 35, "[%d,%d +%d,%d], %2d, %2d",
- edge->rect.x, edge->rect.y, edge->rect.width, edge->rect.height,
- edge->side_type, edge->edge_type);
+ g_snprintf (output, EDGE_LENGTH, "[%d,%d +%d,%d], %2d, %2d",
+ edge->rect.x, edge->rect.y, edge->rect.width, edge->rect.height,
+ edge->side_type, edge->edge_type);
return output;
}
@@ -103,7 +97,7 @@ meta_rectangle_edge_list_to_string (GList *edge_list,
const char *separator_string,
char *output)
{
- /* 27 = 2 commas, 2 square brackets, space, plus, trailing \0 + 5 for
+ /* 27 chars: 2 commas, 2 square brackets, space, plus, trailing \0 + 5 for
* each digit. Should be more than enough space. Note that of this
* space, the trailing \0 will be overwritten for all but the last
* rectangle.
@@ -111,7 +105,7 @@ meta_rectangle_edge_list_to_string (GList *edge_list,
* Plus 2 for parenthesis, 4 for 2 more numbers, 2 more commas, and
* 2 more spaces, for a total of 10 more.
*/
- char rect_string[27 + 10];
+ char rect_string[EDGE_LENGTH];
if (edge_list == NULL)
snprintf (output, 10, "(EMPTY)");
@@ -122,9 +116,9 @@ meta_rectangle_edge_list_to_string (GList *edge_list,
{
MetaEdge *edge = tmp->data;
MetaRectangle *rect = &edge->rect;
- snprintf (rect_string, 37, "([%d,%d +%d,%d], %2d, %2d)",
- rect->x, rect->y, rect->width, rect->height,
- edge->side_type, edge->edge_type);
+ g_snprintf (rect_string, EDGE_LENGTH, "([%d,%d +%d,%d], %2d, %2d)",
+ rect->x, rect->y, rect->width, rect->height,
+ edge->side_type, edge->edge_type);
cur = g_stpcpy (cur, rect_string);
tmp = tmp->next;
if (tmp)
@@ -356,10 +350,6 @@ merge_spanning_rects_in_region (GList *region)
*/
GList* compare;
-#ifdef PRINT_DEBUG
- int num_contains, num_merged, num_part_contains, num_adjacent;
- num_contains = num_merged = num_part_contains = num_adjacent = 0;
-#endif
compare = region;
if (region == NULL)
@@ -369,16 +359,6 @@ merge_spanning_rects_in_region (GList *region)
return NULL;
}
-#ifdef PRINT_DEBUG
- char spanning_region[1 + 28 * g_list_length (region)];
- char rect1_string[25];
- char rect2_string[25];
- printf ("Merging stats:\n");
- printf (" Length of initial list: %d\n", g_list_length (region));
- printf (" Initial rectangles: %s\n",
- meta_rectangle_region_to_string (region, ", ", spanning_region));
-#endif
-
while (compare && compare->next)
{
MetaRectangle *a = compare->data;
@@ -393,29 +373,15 @@ merge_spanning_rects_in_region (GList *region)
g_assert (b->width > 0 && b->height > 0);
-#ifdef PRINT_DEBUG
- printf (" -- Comparing %s to %s --\n",
- meta_rectangle_to_string (a, rect1_string),
- meta_rectangle_to_string (b, rect2_string));
-#endif
-
/* If a contains b, just remove b */
if (meta_rectangle_contains_rect (a, b))
{
delete_me = other;
-#ifdef PRINT_DEBUG
- num_contains++;
- num_merged++;
-#endif
}
/* If b contains a, just remove a */
else if (meta_rectangle_contains_rect (a, b))
{
delete_me = compare;
-#ifdef PRINT_DEBUG
- num_contains++;
- num_merged++;
-#endif
}
/* If a and b might be mergeable horizontally */
else if (a->y == b->y && a->height == b->height)
@@ -427,10 +393,6 @@ merge_spanning_rects_in_region (GList *region)
a->width = MAX (a->x + a->width, b->x + b->width) - new_x;
a->x = new_x;
delete_me = other;
-#ifdef PRINT_DEBUG
- num_part_contains++;
- num_merged++;
-#endif
}
/* If a and b are adjacent */
else if (a->x + a->width == b->x || a->x == b->x + b->width)
@@ -439,10 +401,6 @@ merge_spanning_rects_in_region (GList *region)
a->width = MAX (a->x + a->width, b->x + b->width) - new_x;
a->x = new_x;
delete_me = other;
-#ifdef PRINT_DEBUG
- num_adjacent++;
- num_merged++;
-#endif
}
}
/* If a and b might be mergeable vertically */
@@ -455,10 +413,6 @@ merge_spanning_rects_in_region (GList *region)
a->height = MAX (a->y + a->height, b->y + b->height) - new_y;
a->y = new_y;
delete_me = other;
-#ifdef PRINT_DEBUG
- num_part_contains++;
- num_merged++;
-#endif
}
/* If a and b are adjacent */
else if (a->y + a->height == b->y || a->y == b->y + b->height)
@@ -467,10 +421,6 @@ merge_spanning_rects_in_region (GList *region)
a->height = MAX (a->y + a->height, b->y + b->height) - new_y;
a->y = new_y;
delete_me = other;
-#ifdef PRINT_DEBUG
- num_adjacent++;
- num_merged++;
-#endif
}
}
@@ -479,12 +429,6 @@ merge_spanning_rects_in_region (GList *region)
/* Delete any rectangle in the list that is no longer wanted */
if (delete_me != NULL)
{
-#ifdef PRINT_DEBUG
- MetaRectangle *bla = delete_me->data;
- printf (" Deleting rect %s\n",
- meta_rectangle_to_string (bla, rect1_string));
-#endif
-
/* Deleting the rect we compare others to is a little tricker */
if (compare == delete_me)
{
@@ -498,36 +442,11 @@ merge_spanning_rects_in_region (GList *region)
region = g_list_delete_link (region, delete_me);
}
-#ifdef PRINT_DEBUG
- char new_list[1 + 28 * g_list_length (region)];
- printf (" After comparison, new list is: %s\n",
- meta_rectangle_region_to_string (region, ", ", new_list));
-#endif
}
compare = compare->next;
}
-#ifdef PRINT_DEBUG
- /* Note that I believe it will be the case that num_part_contains and
- * num_adjacent will alwyas be 0 while num_contains will be equal to
- * num_merged. If so, this might be useful information to use to come up
- * with some kind of optimization for this funcation, given that there
- * exists someone who really wants to do that.
- */
- char final_list[1 + 28 * g_list_length (region)];
- printf (" Num rectangles contained in others : %d\n",
- num_contains);
- printf (" Num rectangles partially contained in others: %d\n",
- num_part_contains);
- printf (" Num rectangles adjacent to others : %d\n",
- num_adjacent);
- printf (" Num rectangles merged with others : %d\n",
- num_merged);
- printf (" Final rectangles: %s\n",
- meta_rectangle_region_to_string (region, ", ", final_list));
-#endif
-
return region;
}
@@ -622,39 +541,21 @@ meta_rectangle_get_minimal_spanning_set_for_region (
temp_rect = g_new (MetaRectangle, 1);
*temp_rect = *basic_rect;
ret = g_list_prepend (NULL, temp_rect);
-#ifdef PRINT_DEBUG
- char rect_string[25];
- printf("Initialized spanning set with %s.\n",
- meta_rectangle_to_string (basic_rect, rect_string));
-#endif
strut_iter = all_struts;
while (strut_iter)
{
GList *rect_iter;
MetaRectangle *strut = (MetaRectangle*) strut_iter->data;
-#ifdef PRINT_DEBUG
- printf("Dealing with strut %s.\n",
- meta_rectangle_to_string (strut, rect_string));
-#endif
+
tmp_list = ret;
ret = NULL;
rect_iter = tmp_list;
while (rect_iter)
{
MetaRectangle *rect = (MetaRectangle*) rect_iter->data;
-#ifdef PRINT_DEBUG
- printf(" Looking if we need to chop up %s.\n",
- meta_rectangle_to_string (rect, rect_string));
-#endif
if (!meta_rectangle_overlap (rect, strut))
- {
ret = g_list_prepend (ret, rect);
-#ifdef PRINT_DEBUG
- printf(" No chopping of %s.\n",
- meta_rectangle_to_string (rect, rect_string));
-#endif
- }
else
{
/* If there is area in rect left of strut */
@@ -664,10 +565,6 @@ meta_rectangle_get_minimal_spanning_set_for_region (
*temp_rect = *rect;
temp_rect->width = strut->x - rect->x;
ret = g_list_prepend (ret, temp_rect);
-#ifdef PRINT_DEBUG
- printf(" Added %s.\n",
- meta_rectangle_to_string (temp_rect, rect_string));
-#endif
}
/* If there is area in rect right of strut */
if (rect->x + rect->width > strut->x + strut->width)
@@ -679,10 +576,6 @@ meta_rectangle_get_minimal_spanning_set_for_region (
temp_rect->width = rect->x + rect->width - new_x;
temp_rect->x = new_x;
ret = g_list_prepend (ret, temp_rect);
-#ifdef PRINT_DEBUG
- printf(" Added %s.\n",
- meta_rectangle_to_string (temp_rect, rect_string));
-#endif
}
/* If there is area in rect above strut */
if (rect->y < strut->y)
@@ -691,10 +584,6 @@ meta_rectangle_get_minimal_spanning_set_for_region (
*temp_rect = *rect;
temp_rect->height = strut->y - rect->y;
ret = g_list_prepend (ret, temp_rect);
-#ifdef PRINT_DEBUG
- printf(" Added %s.\n",
- meta_rectangle_to_string (temp_rect, rect_string));
-#endif
}
/* If there is area in rect below strut */
if (rect->y + rect->height > strut->y + strut->height)
@@ -706,10 +595,6 @@ meta_rectangle_get_minimal_spanning_set_for_region (
temp_rect->height = rect->y + rect->height - new_y;
temp_rect->y = new_y;
ret = g_list_prepend (ret, temp_rect);
-#ifdef PRINT_DEBUG
- printf(" Added %s.\n",
- meta_rectangle_to_string (temp_rect, rect_string));
-#endif
}
g_free (rect);
}
@@ -1063,10 +948,14 @@ meta_rectangle_shove_into_region (const GList *spanning_rects,
}
void
-meta_rectangle_find_linepoint_closest_to_point (double x1, double y1,
- double x2, double y2,
- double px, double py,
- double *valx, double *valy)
+meta_rectangle_find_linepoint_closest_to_point (double x1,
+ double y1,
+ double x2,
+ double y2,
+ double px,
+ double py,
+ double *valx,
+ double *valy)
{
/* I'll use the shorthand rx, ry for the return values, valx & valy.
* Now, we need (rx,ry) to be on the line between (x1,y1) and (x2,y2).
@@ -1107,10 +996,12 @@ meta_rectangle_find_linepoint_closest_to_point (double x1, double y1,
double diffx, diffy, den;
diffx = x2 - x1;
diffy = y2 - y1;
- den = diffx*diffx + diffy*diffy;
+ den = diffx * diffx + diffy * diffy;
- *valx = (py*diffx*diffy + px*diffx*diffx + y2*x1*diffy - y1*x2*diffy) / den;
- *valy = (px*diffx*diffy + py*diffy*diffy + x2*y1*diffx - x1*y2*diffx) / den;
+ *valx = (py * diffx * diffy + px * diffx * diffx +
+ y2 * x1 * diffy - y1 * x2 * diffy) / den;
+ *valy = (px * diffx * diffy + py * diffy * diffy +
+ x2 * y1 * diffx - x1 * y2 * diffx) / den;
}
/***************************************************************************/
diff --git a/src/boxes.h b/src/boxes.h
index 8da56d44..3a9ba147 100644
--- a/src/boxes.h
+++ b/src/boxes.h
@@ -62,11 +62,15 @@ struct _MetaEdge
};
/* Output functions -- note that the output buffer had better be big enough:
- * rect_to_string: 1 + 24
- * region_to_string: 1 + (26+strlen(separator_string))*g_list_length (region)
- * edge_to_string: 1 + 24 + 10
- * edge_list_to_...: 1 + (36+strlen(sep..._string))*g_list_length (edge_list)
- */
+ * rect_to_string: RECT_LENGTH
+ * region_to_string: (RECT_LENGTH+strlen(separator_string)) *
+ * g_list_length (region)
+ * edge_to_string: EDGE_LENGTH
+ * edge_list_to_...: (EDGE_LENGTH+strlen(separator_string)) *
+ * g_list_length (edge_list)
+ */
+#define RECT_LENGTH 27
+#define EDGE_LENGTH 37
char* meta_rectangle_to_string (const MetaRectangle *rect,
char *output);
char* meta_rectangle_region_to_string (GList *region,
diff --git a/src/constraints.c b/src/constraints.c
index 816b40b0..a4616b41 100644
--- a/src/constraints.c
+++ b/src/constraints.c
@@ -21,6 +21,7 @@
* 02111-1307, USA.
*/
+#include <config.h>
#include "constraints.h"
#include "workspace.h"
#include "place.h"
@@ -28,10 +29,6 @@
#include <stdlib.h>
#include <math.h>
-/* Stupid disallowing of nested C comments makes a #if 0 and the use of C++
- * looking comments mandatory. Of course, if C weren't so stupid it'd just
- * allow C++ style comments...
- */
#if 0
// This is the short and sweet version of how to hack on this file; see
// doc/how-constraints-works.txt for the gory details. The basics of
@@ -92,16 +89,16 @@
typedef enum
{
- PRIORITY_MINIMUM=0, // Dummy value used for loop start = min(all priorities)
- PRIORITY_ASPECT_RATIO=0,
- PRIORITY_ENTIRELY_VISIBLE_ON_SINGLE_XINERAMA=0,
- PRIORITY_ENTIRELY_VISIBLE_ON_WORKAREA=1,
- PRIORITY_SIZE_HINTS_INCREMENTS=1,
- PRIORITY_MAXIMIZATION=2,
- PRIORITY_FULLSCREEN=2,
- PRIORITY_SIZE_HINTS_LIMITS=3,
- PRIORITY_PARTIALLY_VISIBLE_ON_WORKAREA=4,
- PRIORITY_MAXIMUM=4 // Dummy value used for loop end = max(all priorities)
+ PRIORITY_MINIMUM = 0, // Dummy value used for loop start = min(all priorities)
+ PRIORITY_ASPECT_RATIO = 0,
+ PRIORITY_ENTIRELY_VISIBLE_ON_SINGLE_XINERAMA = 0,
+ PRIORITY_ENTIRELY_VISIBLE_ON_WORKAREA = 1,
+ PRIORITY_SIZE_HINTS_INCREMENTS = 1,
+ PRIORITY_MAXIMIZATION = 2,
+ PRIORITY_FULLSCREEN = 2,
+ PRIORITY_SIZE_HINTS_LIMITS = 3,
+ PRIORITY_PARTIALLY_VISIBLE_ON_WORKAREA = 4,
+ PRIORITY_MAXIMUM = 4 // Dummy value used for loop end = max(all priorities)
} ConstraintPriority;
typedef enum
@@ -199,28 +196,21 @@ typedef gboolean (* ConstraintFunc) (MetaWindow *window,
ConstraintPriority priority,
gboolean check_only);
-static const ConstraintFunc all_constraints[] = {
- constrain_maximization,
- constrain_fullscreen,
- constrain_size_increments,
- constrain_size_limits,
- constrain_aspect_ratio,
- constrain_to_single_xinerama,
- constrain_fully_onscreen,
- constrain_partially_onscreen,
- NULL
-};
-
-static const char* all_constraint_names[] = {
- "constrain_maximization",
- "constrain_fullscreen",
- "constrain_size_increments",
- "constrain_size_limits",
- "constrain_aspect_ratio",
- "constrain_to_single_xinerama",
- "constrain_fully_onscreen",
- "constrain_partially_onscreen",
- NULL
+typedef struct {
+ ConstraintFunc func;
+ const char* name;
+} Constraint;
+
+static const Constraint all_constraints[] = {
+ {constrain_maximization, "constrain_maximization"},
+ {constrain_fullscreen, "constrain_fullscreen"},
+ {constrain_size_increments, "constrain_size_increments"},
+ {constrain_size_limits, "constrain_size_limits"},
+ {constrain_aspect_ratio, "constrain_aspect_ratio"},
+ {constrain_to_single_xinerama, "constrain_to_single_xinerama"},
+ {constrain_fully_onscreen, "constrain_fully_onscreen"},
+ {constrain_partially_onscreen, "constrain_partially_onscreen"},
+ {NULL, NULL}
};
static gboolean
@@ -230,11 +220,11 @@ do_all_constraints (MetaWindow *window,
gboolean check_only)
{
const ConstraintFunc *constraint;
- const char **constraint_name;
+ const char *constraint_name;
gboolean satisfied;
- constraint = &all_constraints[0];
- constraint_name = &all_constraint_names[0];
+ constraint = &all_constraints[0].func;
+ constraint_name = all_constraints[0].name;
satisfied = TRUE;
while (*constraint)
@@ -249,14 +239,14 @@ do_all_constraints (MetaWindow *window,
"info->current is %d,%d +%d,%d after %s\n",
info->current.x, info->current.y,
info->current.width, info->current.height,
- *constraint_name);
+ constraint_name);
}
else if (!satisfied)
{
/* Log which constraint was not satisfied */
meta_topic (META_DEBUG_GEOMETRY,
"constraint %s not satisfied.\n",
- *constraint_name);
+ constraint_name);
return FALSE;
}
++constraint;
@@ -485,15 +475,31 @@ place_window_if_needed(MetaWindow *window,
.083 * info->work_area_xinerama.height;
}
- if (window->maximize_horizontally_after_placement)
- meta_window_maximize_internal (window, TRUE, FALSE, &info->current);
- if (window->maximize_vertically_after_placement);
- meta_window_maximize_internal (window, FALSE, TRUE, &info->current);
-
/* maximization may have changed frame geometry */
if (window->frame && !window->fullscreen)
meta_frame_calc_geometry (window->frame, info->fgeom);
+ if (window->maximize_horizontally_after_placement &&
+ window->maximize_vertically_after_placement)
+ meta_window_maximize_internal (window,
+ META_MAXIMIZE_HORIZONTAL |
+ META_MAXIMIZE_VERTICAL,
+ &info->current);
+ else if (window->maximize_horizontally_after_placement)
+ {
+ info->current.x = info->work_area_xinerama.x
+ + info->fgeom->left_width;
+ info->current.width = info->work_area_xinerama.width
+ - info->fgeom->left_width - info->fgeom->right_width;
+ }
+ else if (window->maximize_vertically_after_placement);
+ {
+ info->current.y = info->work_area_xinerama.y
+ + info->fgeom->top_height;
+ info->current.height = info->work_area_xinerama.height
+ - info->fgeom->top_height - info->fgeom->bottom_height;
+ }
+
window->maximize_horizontally_after_placement = FALSE;
window->maximize_vertically_after_placement = FALSE;
}
@@ -539,7 +545,7 @@ update_onscreen_requirements (MetaWindow *window,
&info->current);
if (old ^ window->require_fully_onscreen)
meta_topic (META_DEBUG_GEOMETRY,
- "require_fully_onscreen for %s toggled to %s\n"
+ "require_fully_onscreen for %s toggled to %s\n",
window->desc,
window->require_fully_onscreen ? "TRUE" : "FALSE");
@@ -909,7 +915,7 @@ do_screen_and_xinerama_relative_constraints (
char spanning_region[1 + 28 * g_list_length (region_spanning_rectangles)];
(void) spanning_region; /* Avoid stupid & incorrect compiler warnings... */
meta_topic (META_DEBUG_GEOMETRY,
- "screen/xinerama constraint; region_spanning_rectangles: %s\n"
+ "screen/xinerama constraint; region_spanning_rectangles: %s\n",
meta_rectangle_region_to_string (region_spanning_rectangles, ", ",
spanning_region));
@@ -976,12 +982,14 @@ constrain_to_single_xinerama (MetaWindow *window,
/* Exit early if we know the constraint won't apply--note that this constraint
* is only meant for normal windows (e.g. we don't want docks to be shoved
- * "onscreen" by their own strut).
+ * "onscreen" by their own strut) and we can't apply it to frameless windows
+ * or else users will be unable to move windows such as XMMS across xineramas.
*/
if (window->type == META_WINDOW_DESKTOP ||
window->type == META_WINDOW_DOCK ||
window->screen->n_xinerama_infos == 1 ||
!window->require_on_single_xinerama ||
+ !window->frame ||
info->is_user_action)
return TRUE;
diff --git a/src/core.c b/src/core.c
index 59708b1d..2bffc6db 100644
--- a/src/core.c
+++ b/src/core.c
@@ -387,7 +387,8 @@ meta_core_maximize (Display *xdisplay,
if (window == NULL || window->frame == NULL)
meta_bug ("No such frame window 0x%lx!\n", frame_xwindow);
- meta_window_maximize (window, TRUE, TRUE);
+ meta_window_maximize (window,
+ META_MAXIMIZE_HORIZONTAL | META_MAXIMIZE_VERTICAL);
}
void
@@ -404,9 +405,11 @@ meta_core_toggle_maximize (Display *xdisplay,
meta_bug ("No such frame window 0x%lx!\n", frame_xwindow);
if (META_WINDOW_MAXIMIZED (window))
- meta_window_unmaximize (window, TRUE, TRUE);
+ meta_window_unmaximize (window,
+ META_MAXIMIZE_HORIZONTAL | META_MAXIMIZE_VERTICAL);
else
- meta_window_maximize (window, TRUE, TRUE);
+ meta_window_maximize (window,
+ META_MAXIMIZE_HORIZONTAL | META_MAXIMIZE_VERTICAL);
}
void
@@ -422,7 +425,8 @@ meta_core_unmaximize (Display *xdisplay,
if (window == NULL || window->frame == NULL)
meta_bug ("No such frame window 0x%lx!\n", frame_xwindow);
- meta_window_unmaximize (window, TRUE, TRUE);
+ meta_window_unmaximize (window,
+ META_MAXIMIZE_HORIZONTAL | META_MAXIMIZE_VERTICAL);
}
void
diff --git a/src/keybindings.c b/src/keybindings.c
index b75017df..472d37b7 100644
--- a/src/keybindings.c
+++ b/src/keybindings.c
@@ -2589,9 +2589,9 @@ handle_maximize_vert (MetaDisplay *display,
if (window && window->has_resize_func)
{
if (window->maximized_vertically)
- meta_window_unmaximize (window, FALSE, TRUE);
+ meta_window_unmaximize (window, META_MAXIMIZE_VERTICAL);
else
- meta_window_maximize (window, FALSE, TRUE);
+ meta_window_maximize (window, META_MAXIMIZE_VERTICAL);
}
}
@@ -2605,9 +2605,9 @@ handle_maximize_horiz (MetaDisplay *display,
if (window && window->has_resize_func)
{
if (window->maximized_horizontally)
- meta_window_unmaximize (window, TRUE, FALSE);
+ meta_window_unmaximize (window, META_MAXIMIZE_HORIZONTAL);
else
- meta_window_maximize (window, TRUE, FALSE);
+ meta_window_maximize (window, META_MAXIMIZE_HORIZONTAL);
}
}
@@ -3034,9 +3034,13 @@ handle_toggle_maximize (MetaDisplay *display,
if (window)
{
if (META_WINDOW_MAXIMIZED (window))
- meta_window_unmaximize (window, TRUE, TRUE);
+ meta_window_unmaximize (window,
+ META_MAXIMIZE_HORIZONTAL |
+ META_MAXIMIZE_VERTICAL);
else if (window->has_maximize_func)
- meta_window_maximize (window, TRUE, TRUE);
+ meta_window_maximize (window,
+ META_MAXIMIZE_HORIZONTAL |
+ META_MAXIMIZE_VERTICAL);
}
}
@@ -3050,7 +3054,9 @@ handle_maximize (MetaDisplay *display,
if (window)
{
if (window->has_maximize_func)
- meta_window_maximize (window, TRUE, TRUE);
+ meta_window_maximize (window,
+ META_MAXIMIZE_HORIZONTAL |
+ META_MAXIMIZE_VERTICAL);
}
}
@@ -3064,7 +3070,9 @@ handle_unmaximize (MetaDisplay *display,
if (window)
{
if (window->maximized_vertically || window->maximized_horizontally)
- meta_window_unmaximize (window, TRUE, TRUE);
+ meta_window_unmaximize (window,
+ META_MAXIMIZE_HORIZONTAL |
+ META_MAXIMIZE_VERTICAL);
}
}
diff --git a/src/place.c b/src/place.c
index f812a433..eeac6c5d 100644
--- a/src/place.c
+++ b/src/place.c
@@ -586,13 +586,15 @@ find_first_fit (MetaWindow *window,
for (i = 0; i < n_xineramas; i++)
{
- char xinerama_location_string[25];
+#ifdef WITH_VERBOSE_MODE
+ char xinerama_location_string[RECT_LENGTH];
meta_rectangle_to_string (&window->screen->xinerama_infos[xineramas_list[i]].rect,
xinerama_location_string);
meta_topic (META_DEBUG_XINERAMA,
"Natural xinerama %d is %s\n",
i,
xinerama_location_string);
+#endif
}
/* try each xinerama in the natural ordering in turn */
diff --git a/src/testboxes.c b/src/testboxes.c
index 127cf261..4ed5881d 100644
--- a/src/testboxes.c
+++ b/src/testboxes.c
@@ -373,8 +373,8 @@ test_merge_regions ()
printf ("Merging stats:\n");
printf (" Length of initial list: %d\n", g_list_length (region));
#ifdef PRINT_DEBUG
- char rect1[25], rect2[25];
- char region_list[1 + 28 * g_list_length (region)];
+ char rect1[RECT_LENGTH], rect2[RECT_LENGTH];
+ char region_list[(RECT_LENGTH + 2) * g_list_length (region)];
meta_rectangle_region_to_string (region, ", ", region_list);
printf (" Initial rectangles: %s\n", region_list);
#endif
@@ -487,7 +487,7 @@ test_merge_regions ()
}
#ifdef PRINT_DEBUG
- char region_list[1 + 28 * g_list_length (region)];
+ char region_list[(RECT_LENGTH + 2) * g_list_length (region)];
meta_rectangle_region_to_string (region, ", ", region_list);
printf (" After comparison, new list is: %s\n", region_list);
#endif
@@ -505,7 +505,7 @@ test_merge_regions ()
printf (" Num rectangles merged with others : %d\n",
num_merged);
#ifdef PRINT_DEBUG
- char region_list2[1 + 28 * g_list_length (region)];
+ char region_list2[(RECT_LENGTH + 2) * g_list_length (region)];
meta_rectangle_region_to_string (region, ", ", region_list2);
printf (" Final rectangles: %s\n", region_list2);
#endif
@@ -622,8 +622,8 @@ test_regions_okay ()
tmp = g_list_prepend (tmp, new_meta_rect ( 0, 20, 1600, 505)); // 808000
#if 0
printf ("Got to here...\n");
- char region_list[1 + 28 * g_list_length (region)];
- char tmp_list[ 1 + 28 * g_list_length (tmp)];
+ char region_list[(RECT_LENGTH+2) * g_list_length (region)];
+ char tmp_list[ (RECT_LENGTH+2) * g_list_length (tmp)];
meta_rectangle_region_to_string (region, ", ", region_list);
meta_rectangle_region_to_string (region, ", ", tmp_list);
printf ("%s vs. %s\n", region_list, tmp_list);
@@ -1078,8 +1078,8 @@ test_find_onscreen_edges ()
tmp = g_list_prepend (tmp, new_onscreen_edge ( 0, 20, 0, 1180, left));
#if 0
- #define FUDGE 50
- char big_buffer1[1 + (16+FUDGE)*38], big_buffer2[1 + 16*38];
+ #define FUDGE 50 /* number of edges */
+ char big_buffer1[(EDGE_LENGTH+2)*FUDGE], big_buffer2[(EDGE_LENGTH+2)*FUDGE];
meta_rectangle_edge_list_to_string (edges, "\n ", big_buffer1);
meta_rectangle_edge_list_to_string (tmp, "\n ", big_buffer2);
printf("Generated edge list:\n %s\nComparison edges list:\n %s\n",
@@ -1168,7 +1168,7 @@ test_find_nonintersected_xinerama_edges ()
tmp = g_list_prepend (tmp, new_xinerama_edge ( 800, 20, 0, 1180, left));
#if 0
#define FUDGE 50
- char big_buffer1[1 + (16+FUDGE)*38], big_buffer2[1 + 16*38];
+ char big_buffer1[(EDGE_LENGTH+2)*FUDGE], big_buffer2[(EDGE_LENGTH+2)*FUDGE];
meta_rectangle_edge_list_to_string (edges, "\n ", big_buffer1);
meta_rectangle_edge_list_to_string (tmp, "\n ", big_buffer2);
printf("Generated edge list:\n %s\nComparison edges list:\n %s\n",
diff --git a/src/window.c b/src/window.c
index 8d377c7c..37cf8281 100644
--- a/src/window.c
+++ b/src/window.c
@@ -401,11 +401,6 @@ meta_window_new_with_attrs (MetaDisplay *display,
window->has_shape = has_shape;
- /* The x & y correspond to the outer window (i.e. including frame), while
- * width and height refer to the inner window (i.e. ignoring the frame).
- * Stupid, stupid, stupid X. See documentation for XWindowAttributes,
- * XGetWindowAttributes, XMoveWindow, and XResizeWindow.
- */
window->rect.x = attrs->x;
window->rect.y = attrs->y;
window->rect.width = attrs->width;
@@ -784,8 +779,10 @@ meta_window_apply_session_info (MetaWindow *window,
info->maximized, window->desc);
if (window->has_maximize_func && info->maximized)
- {
- meta_window_maximize (window, TRUE, TRUE);
+ {
+ meta_window_maximize (window,
+ META_MAXIMIZE_HORIZONTAL |
+ META_MAXIMIZE_VERTICAL);
if (info->saved_rect_set)
{
@@ -979,7 +976,8 @@ meta_window_free (MetaWindow *window)
window->display->focus_window = NULL;
if (window->maximized_horizontally || window->maximized_vertically)
- meta_window_unmaximize (window, TRUE, TRUE);
+ meta_window_unmaximize (window,
+ META_MAXIMIZE_HORIZONTAL | META_MAXIMIZE_VERTICAL);
meta_window_unqueue_calc_showing (window);
meta_window_unqueue_move_resize (window);
@@ -2025,11 +2023,14 @@ meta_window_save_rect (MetaWindow *window)
}
void
-meta_window_maximize_internal (MetaWindow *window,
- gboolean maximize_horizontally,
- gboolean maximize_vertically,
- MetaRectangle *saved_rect)
-{
+meta_window_maximize_internal (MetaWindow *window,
+ MetaMaximizeFlags directions,
+ MetaRectangle *saved_rect)
+{
+ /* At least one of the two directions ought to be set */
+ gboolean maximize_horizontally, maximize_vertically;
+ maximize_horizontally = directions & META_MAXIMIZE_HORIZONTAL;
+ maximize_vertically = directions & META_MAXIMIZE_VERTICAL;
g_assert (maximize_horizontally || maximize_vertically);
meta_topic (META_DEBUG_WINDOW_OPS,
@@ -2054,10 +2055,13 @@ meta_window_maximize_internal (MetaWindow *window,
}
void
-meta_window_maximize (MetaWindow *window,
- gboolean maximize_horizontally,
- gboolean maximize_vertically)
+meta_window_maximize (MetaWindow *window,
+ MetaMaximizeFlags directions)
{
+ /* At least one of the two directions ought to be set */
+ gboolean maximize_horizontally, maximize_vertically;
+ maximize_horizontally = directions & META_MAXIMIZE_HORIZONTAL;
+ maximize_vertically = directions & META_MAXIMIZE_VERTICAL;
g_assert (maximize_horizontally || maximize_vertically);
/* Only do something if the window isn't already maximized in the
@@ -2083,8 +2087,7 @@ meta_window_maximize (MetaWindow *window,
}
meta_window_maximize_internal (window,
- maximize_horizontally,
- maximize_vertically,
+ directions,
NULL);
/* move_resize with new maximization constraints
@@ -2094,10 +2097,15 @@ meta_window_maximize (MetaWindow *window,
}
void
-meta_window_unmaximize (MetaWindow *window,
- gboolean unmaximize_horizontally,
- gboolean unmaximize_vertically)
+meta_window_unmaximize (MetaWindow *window,
+ MetaMaximizeFlags directions)
{
+ /* At least one of the two directions ought to be set */
+ gboolean unmaximize_horizontally, unmaximize_vertically;
+ unmaximize_horizontally = directions & META_MAXIMIZE_HORIZONTAL;
+ unmaximize_vertically = directions & META_MAXIMIZE_VERTICAL;
+ g_assert (unmaximize_horizontally || unmaximize_vertically);
+
/* Only do something if the window isn't already maximized in the
* given direction(s).
*/
@@ -2531,47 +2539,40 @@ meta_window_move_resize_internal (MetaWindow *window,
int w,
int h)
{
- /* meta_window_move_resize_internal absolutely sucks as far as what it
- * accepts for the new position of the window. w & h are always the
- * area of the inner or client window (i.e. excluding the frame).
- * root_x_nw and root_y_nw can be any of:
- *
- * (1) Bogus; should just be ignored.
- * (2) Something kind of strange that needs to be fixed up with
- * adjust_for_gravity(). I'm not sure I quite understand it
- * despite my reading of all relevant functions multiple times plus
- * lots of X manual page reading. Anyway, I think the basic idea
- * is that it somehow specifies the inner position of the window in
- * such a way that the relevant part of the frame for the given
- * gravity will remain fixed. Kinda confusing, but it was stuff
- * written by someone else and it all seems to all work, though, so
- * I'm just not going to touch this code if I can help it.
- * (3) Desired positon of the NW corner of the inner window
- * (4) Some unnatural nasty mixture of the above that is obscene and
- * broken and we don't even attempt to fix up; but it's #ifdef'd
- * out so we don't worry about it. It needs to be fixed (not this
- * function) before it really is used, though.
- *
- * Other than case (1) which occurs whenever the operation is a
- * resize-only operation (in which case window->rect.x and window->rect.y
- * combined with meta_rectangle_resize_with_gravity() provides the real
- * position), here are the cases and what they yield:
+ /* meta_window_move_resize_internal gets called with very different
+ * meanings for root_x_nw and root_y_nw. w & h are always the area of
+ * the inner or client window (i.e. excluding the frame) and the
+ * resize_gravity is always the gravity associated with the resize or
+ * move_resize request (the gravity is ignored for move-only operations).
+ * But the location is different because of how this function gets
+ * called; note that in all cases what we want to find out is the upper
+ * left corner of the position of the inner window:
*
* Case | Called from (flags; resize_gravity)
* -----+-----------------------------------------------
- * 2 | New window (ConfigureRequest; gravity)
- * 2 | Session restore (GravityAdjust; gravity)
- * 3 | meta_window_resize (UserAction || 0; NorthWest)
- * 3 | meta_window_move (UserAction || 0; NorthWest)
- * 3 | meta_window_move_resize (UserAction || 0; NorthWest)
+ * 1 | A resize only ConfigureRequest
+ * 1 | meta_window_resize
+ * 1 | meta_window_resize_with_gravity
+ * 2 | New window
+ * 2 | Session restore
+ * 2 | A not-resize-only ConfigureRequest
+ * 3 | meta_window_move
+ * 3 | meta_window_move_resize
* 4 | various functions via handle_net_moveresize_window() in display.c
- * 2 | ConfigureRequest (ConfigureRequest; gravity)
*
- * Other than the (4) case, this is all cleaned up via use of
- * meta_rectangle_resize_with_gravity() to turn type (1) cases into type
- * (3) and the use of adjust_for_gravity() to turn all (2) cases into
- * (3). This makes it so that all position and size fields correspond to
- * the desired inner (or "client") window position.
+ * For each of the cases, root_x_nw and root_y_nw must be treated as follows:
+ *
+ * (1) They should be entirely ignored; instead the previous position
+ * and size of the window should be resized according to the given
+ * gravity in order to determine the new position of the window.
+ * (2) Needs to be fixed up by adjust_for_gravity() as these
+ * coordinates are relative to some corner or side of the outer
+ * window (except for the case of StaticGravity) and we want to
+ * know the location of the upper left corner of the inner window.
+ * (3) These values are already the desired positon of the NW corner
+ * of the inner window
+ * (4) The place that calls this function this way must be fixed; it is
+ * wrong.
*/
XWindowChanges values;
unsigned int mask;
@@ -3382,15 +3383,9 @@ meta_window_begin_wireframe (MetaWindow *window)
int display_width, display_height;
window->display->grab_wireframe_rect = window->rect;
-
- /* FIXME: Uh, why not use meta_window_get_position() to be like all the
- * other code in Metacity?
- */
- 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_position (window,
+ &window->display->grab_wireframe_rect.x,
+ &window->display->grab_wireframe_rect.y);
meta_window_get_xor_rect (window, &window->display->grab_wireframe_rect,
&new_xor);
@@ -4283,9 +4278,9 @@ meta_window_client_message (MetaWindow *window,
(action == _NET_WM_STATE_TOGGLE &&
!window->maximized_horizontally));
if (max && window->has_maximize_func)
- meta_window_maximize (window, TRUE, FALSE);
+ meta_window_maximize (window, META_MAXIMIZE_HORIZONTAL);
else
- meta_window_unmaximize (window, TRUE, FALSE);
+ meta_window_unmaximize (window, META_MAXIMIZE_HORIZONTAL);
}
if (first == display->atom_net_wm_state_maximized_vert ||
@@ -4297,9 +4292,9 @@ meta_window_client_message (MetaWindow *window,
(action == _NET_WM_STATE_TOGGLE &&
!window->maximized_vertically));
if (max && window->has_maximize_func)
- meta_window_maximize (window, FALSE, TRUE);
+ meta_window_maximize (window, META_MAXIMIZE_VERTICAL);
else
- meta_window_unmaximize (window, FALSE, TRUE);
+ meta_window_unmaximize (window, META_MAXIMIZE_VERTICAL);
}
if (first == display->atom_net_wm_state_modal ||
@@ -6069,11 +6064,15 @@ menu_callback (MetaWindowMenu *menu,
break;
case META_MENU_OP_UNMAXIMIZE:
- meta_window_unmaximize (window, TRUE, TRUE);
+ meta_window_unmaximize (window,
+ META_MAXIMIZE_HORIZONTAL |
+ META_MAXIMIZE_VERTICAL);
break;
case META_MENU_OP_MAXIMIZE:
- meta_window_maximize (window, TRUE, TRUE);
+ meta_window_maximize (window,
+ META_MAXIMIZE_HORIZONTAL |
+ META_MAXIMIZE_VERTICAL);
break;
case META_MENU_OP_UNSHADE:
@@ -6493,7 +6492,6 @@ update_move_timeout (gpointer data)
window->display->grab_latest_motion_x,
window->display->grab_latest_motion_y);
- /* Return value is ignored, but whatever... */
return FALSE;
}
@@ -6566,7 +6564,9 @@ update_move (MetaWindow *window,
window->display->grab_anchor_root_x = x;
window->display->grab_anchor_root_y = y;
- meta_window_unmaximize (window, TRUE, TRUE);
+ meta_window_unmaximize (window,
+ META_MAXIMIZE_HORIZONTAL |
+ META_MAXIMIZE_VERTICAL);
return;
}
@@ -6605,7 +6605,9 @@ update_move (MetaWindow *window,
window->saved_rect.y += window->frame->child_y;
}
- meta_window_unmaximize (window, TRUE, TRUE);
+ meta_window_unmaximize (window,
+ META_MAXIMIZE_HORIZONTAL |
+ META_MAXIMIZE_VERTICAL);
}
window->display->grab_initial_window_pos = work_area;
@@ -6613,7 +6615,9 @@ update_move (MetaWindow *window,
window->display->grab_anchor_root_y = y;
window->shaken_loose = FALSE;
- meta_window_maximize (window, TRUE, TRUE);
+ meta_window_maximize (window,
+ META_MAXIMIZE_HORIZONTAL |
+ META_MAXIMIZE_VERTICAL);
return;
}
@@ -7078,28 +7082,6 @@ meta_window_handle_mouse_grab_op_event (MetaWindow *window,
}
break;
-#if 0
- case EnterNotify:
- case LeaveNotify:
- if (meta_grab_op_is_moving (window->display->grab_op))
- {
- if (event->xcrossing.root == window->screen->xroot)
- update_move (window,
- event->xcrossing.state & ShiftMask,
- event->xcrossing.x_root,
- event->xcrossing.y_root);
- }
- else if (meta_grab_op_is_resizing (window->display->grab_op))
- {
- if (event->xcrossing.root == window->screen->xroot)
- update_resize (window,
- event->xcrossing.state & ShiftMask,
- event->xcrossing.x_root,
- event->xcrossing.y_root,
- FALSE);
- }
- break;
-#endif
default:
break;
}
diff --git a/src/window.h b/src/window.h
index bc28f7a5..8d869e06 100644
--- a/src/window.h
+++ b/src/window.h
@@ -51,6 +51,12 @@ typedef enum
META_WINDOW_SPLASHSCREEN
} MetaWindowType;
+typedef enum
+{
+ META_MAXIMIZE_HORIZONTAL = 1 << 0,
+ META_MAXIMIZE_VERTICAL = 1 << 1
+} MetaMaximizeFlags;
+
struct _MetaStruts
{
/* struts */
@@ -293,13 +299,9 @@ struct _MetaWindow
/* The size we set the window to last (i.e. what we believe
* to be its actual size on the server). The x, y are
* the actual server-side x,y so are relative to the frame
- * or the root window as appropriate.
- *
- * In a format that I (Elijah) understand: The x & y are trying to
- * provide the position of the upper-left corner of the client
- * (i.e. inner) window, but may do so relative to where the upper
- * left of the frame is if there is one. The width and height are
- * always of the client (i.e. inner) window.
+ * (meaning that they just hold the frame width and height)
+ * or the root window (meaning they specify the location
+ * of the top left of the inner window) as appropriate.
*/
MetaRectangle rect;
@@ -366,16 +368,13 @@ void meta_window_calc_showing (MetaWindow *window);
void meta_window_queue_calc_showing (MetaWindow *window);
void meta_window_minimize (MetaWindow *window);
void meta_window_unminimize (MetaWindow *window);
-void meta_window_maximize (MetaWindow *window,
- gboolean maximize_horizontally,
- gboolean maximize_vertically);
-void meta_window_maximize_internal (MetaWindow *window,
- gboolean maximize_horizontally,
- gboolean maximize_vertically,
- MetaRectangle *saved_rect);
-void meta_window_unmaximize (MetaWindow *window,
- gboolean unmaximize_horizontally,
- gboolean unmaximize_vertically);
+void meta_window_maximize (MetaWindow *window,
+ MetaMaximizeFlags directions);
+void meta_window_maximize_internal (MetaWindow *window,
+ MetaMaximizeFlags directions,
+ MetaRectangle *saved_rect);
+void meta_window_unmaximize (MetaWindow *window,
+ MetaMaximizeFlags directions);
void meta_window_make_above (MetaWindow *window);
void meta_window_unmake_above (MetaWindow *window);
void meta_window_shade (MetaWindow *window);