projects
/
dana
/
openbox.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
f866c03
)
Fix nits for overlap placement center option
author
Dana Jansens
<danakj@orodu.net>
Sun, 1 Sep 2013 15:49:06 +0000
(11:49 -0400)
committer
Dana Jansens
<danakj@orodu.net>
Sun, 1 Sep 2013 19:09:03 +0000
(15:09 -0400)
openbox/place_overlap.c
patch
|
blob
|
history
diff --git
a/openbox/place_overlap.c
b/openbox/place_overlap.c
index
9eccb97
..
ac7255b
100644
(file)
--- a/
openbox/place_overlap.c
+++ b/
openbox/place_overlap.c
@@
-205,11
+205,11
@@
static void expand_height(Rect* r, int by)
r->height += by;
}
r->height += by;
}
-typedef void ((*
expand_m
ethod)(Rect*, int));
+typedef void ((*
ExpandByM
ethod)(Rect*, int));
/* This structure packs most of the parametars for expand_field() in
order to save pushing the same parameters twice. */
/* This structure packs most of the parametars for expand_field() in
order to save pushing the same parameters twice. */
-typedef struct _
expand_i
nfo {
+typedef struct _
ExpandI
nfo {
const Point* top_left;
int orig_width;
int orig_height;
const Point* top_left;
int orig_width;
int orig_height;
@@
-217,12
+217,12
@@
typedef struct _expand_info {
const Rect* client_rects;
int n_client_rects;
int max_edges;
const Rect* client_rects;
int n_client_rects;
int max_edges;
-}
expand_i
nfo;
+}
ExpandI
nfo;
static int expand_field(int orig_edge_index,
const int* edges,
static int expand_field(int orig_edge_index,
const int* edges,
-
expand_method exp
,
- const
expand_i
nfo* i)
+
ExpandByMethod expand_by
,
+ const
ExpandI
nfo* i)
{
Rect field;
RECT_SET(field,
{
Rect field;
RECT_SET(field,
@@
-233,7
+233,7
@@
static int expand_field(int orig_edge_index,
int edge_index = orig_edge_index;
while (edge_index < i->max_edges - 1) {
int next_edge_index = edge_index + 1;
int edge_index = orig_edge_index;
while (edge_index < i->max_edges - 1) {
int next_edge_index = edge_index + 1;
- (*exp)(&field, edges[next_edge_index] - edges[edge_index]);
+ (*exp
and_by
)(&field, edges[next_edge_index] - edges[edge_index]);
int overlap = total_overlap(i->client_rects, i->n_client_rects, &field);
if (overlap != 0 || !RECT_CONTAINS_RECT(*(i->monitor), field))
break;
int overlap = total_overlap(i->client_rects, i->n_client_rects, &field);
if (overlap != 0 || !RECT_CONTAINS_RECT(*(i->monitor), field))
break;
@@
-261,12
+261,12
@@
static void center_in_field(Point* top_left,
const int* y_edges,
int max_edges)
{
const int* y_edges,
int max_edges)
{
- /*
find minimal rectangle
*/
+ /*
Find minimal rectangle.
*/
int orig_right_edge_index =
grid_position(top_left->x + req_size->width, x_edges, max_edges);
int orig_bottom_edge_index =
grid_position(top_left->y + req_size->height, y_edges, max_edges);
int orig_right_edge_index =
grid_position(top_left->x + req_size->width, x_edges, max_edges);
int orig_bottom_edge_index =
grid_position(top_left->y + req_size->height, y_edges, max_edges);
-
expand_i
nfo i = {
+
ExpandI
nfo i = {
.top_left = top_left,
.orig_width = x_edges[orig_right_edge_index] - top_left->x,
.orig_height = y_edges[orig_bottom_edge_index] - top_left->y,
.top_left = top_left,
.orig_width = x_edges[orig_right_edge_index] - top_left->x,
.orig_height = y_edges[orig_bottom_edge_index] - top_left->y,
@@
-274,20
+274,22
@@
static void center_in_field(Point* top_left,
.client_rects = client_rects,
.n_client_rects = n_client_rects,
.max_edges = max_edges};
.client_rects = client_rects,
.n_client_rects = n_client_rects,
.max_edges = max_edges};
- /*
try extending width
*/
+ /*
Try extending width.
*/
int right_edge_index =
expand_field(orig_right_edge_index, x_edges, expand_width, &i);
int right_edge_index =
expand_field(orig_right_edge_index, x_edges, expand_width, &i);
- /*
try extending height
*/
+ /*
Try extending height.
*/
int bottom_edge_index =
expand_field(orig_bottom_edge_index, y_edges, expand_height, &i);
int bottom_edge_index =
expand_field(orig_bottom_edge_index, y_edges, expand_height, &i);
+
int final_width = x_edges[orig_right_edge_index] - top_left->x;
int final_height = y_edges[orig_bottom_edge_index] - top_left->y;
int final_width = x_edges[orig_right_edge_index] - top_left->x;
int final_height = y_edges[orig_bottom_edge_index] - top_left->y;
- if (right_edge_index == orig_right_edge_index
-
&&
bottom_edge_index != orig_bottom_edge_index)
+ if (right_edge_index == orig_right_edge_index
&&
+ bottom_edge_index != orig_bottom_edge_index)
final_height = y_edges[bottom_edge_index] - top_left->y;
final_height = y_edges[bottom_edge_index] - top_left->y;
- else if (right_edge_index != orig_right_edge_index
-
&&
bottom_edge_index == orig_bottom_edge_index)
+ else if (right_edge_index != orig_right_edge_index
&&
+ bottom_edge_index == orig_bottom_edge_index)
final_width = x_edges[right_edge_index] - top_left->x;
final_width = x_edges[right_edge_index] - top_left->x;
+
/* Now center the given rectangle within the field */
top_left->x += (final_width - req_size->width) / 2;
top_left->y += (final_height - req_size->height) / 2;
/* Now center the given rectangle within the field */
top_left->x += (final_width - req_size->width) / 2;
top_left->y += (final_height - req_size->height) / 2;