00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef META_BOXES_H
00025 #define META_BOXES_H
00026
00027 #include <glib.h>
00028 #include "common.h"
00029
00030 typedef struct _MetaRectangle MetaRectangle;
00031 struct _MetaRectangle
00032 {
00033 int x;
00034 int y;
00035 int width;
00036 int height;
00037 };
00038
00039 typedef struct _MetaStrut MetaStrut;
00040 struct _MetaStrut
00041 {
00042 MetaRectangle rect;
00043 MetaDirection side;
00044 };
00045
00046 #define BOX_LEFT(box) ((box).x)
00047 #define BOX_RIGHT(box) ((box).x + (box).width)
00048 #define BOX_TOP(box) ((box).y)
00049 #define BOX_BOTTOM(box) ((box).y + (box).height)
00050
00051 typedef enum
00052 {
00053 FIXED_DIRECTION_NONE = 0,
00054 FIXED_DIRECTION_X = 1 << 0,
00055 FIXED_DIRECTION_Y = 1 << 1,
00056 } FixedDirections;
00057
00058 typedef enum
00059 {
00060 META_EDGE_WINDOW,
00061 META_EDGE_XINERAMA,
00062 META_EDGE_SCREEN
00063 } MetaEdgeType;
00064
00065 typedef struct _MetaEdge MetaEdge;
00066 struct _MetaEdge
00067 {
00068 MetaRectangle rect;
00069 MetaDirection side_type;
00070 MetaEdgeType edge_type;
00071 };
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081 #define RECT_LENGTH 27
00082 #define EDGE_LENGTH 37
00083 char* meta_rectangle_to_string (const MetaRectangle *rect,
00084 char *output);
00085 char* meta_rectangle_region_to_string (GList *region,
00086 const char *separator_string,
00087 char *output);
00088 char* meta_rectangle_edge_to_string (const MetaEdge *edge,
00089 char *output);
00090 char* meta_rectangle_edge_list_to_string (
00091 GList *edge_list,
00092 const char *separator_string,
00093 char *output);
00094
00095
00096 MetaRectangle meta_rect (int x, int y, int width, int height);
00097
00098
00099 int meta_rectangle_area (const MetaRectangle *rect);
00100 gboolean meta_rectangle_intersect (const MetaRectangle *src1,
00101 const MetaRectangle *src2,
00102 MetaRectangle *dest);
00103 gboolean meta_rectangle_equal (const MetaRectangle *src1,
00104 const MetaRectangle *src2);
00105
00106
00107
00108
00109 gboolean meta_rectangle_overlap (const MetaRectangle *rect1,
00110 const MetaRectangle *rect2);
00111
00112
00113
00114
00115
00116
00117 gboolean meta_rectangle_vert_overlap (const MetaRectangle *rect1,
00118 const MetaRectangle *rect2);
00119 gboolean meta_rectangle_horiz_overlap (const MetaRectangle *rect1,
00120 const MetaRectangle *rect2);
00121
00122
00123
00124
00125 gboolean meta_rectangle_could_fit_rect (const MetaRectangle *outer_rect,
00126 const MetaRectangle *inner_rect);
00127 gboolean meta_rectangle_contains_rect (const MetaRectangle *outer_rect,
00128 const MetaRectangle *inner_rect);
00129
00130
00131
00132
00133
00134
00135
00136
00137 void meta_rectangle_resize_with_gravity (const MetaRectangle *old_rect,
00138 MetaRectangle *rect,
00139 int gravity,
00140 int new_width,
00141 int new_height);
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154 GList* meta_rectangle_get_minimal_spanning_set_for_region (
00155 const MetaRectangle *basic_rect,
00156 const GSList *all_struts);
00157
00158
00159 GList* meta_rectangle_expand_region (GList *region,
00160 const int left_expand,
00161 const int right_expand,
00162 const int top_expand,
00163 const int bottom_expand);
00164
00165
00166
00167 GList* meta_rectangle_expand_region_conditionally (
00168 GList *region,
00169 const int left_expand,
00170 const int right_expand,
00171 const int top_expand,
00172 const int bottom_expand,
00173 const int min_x,
00174 const int min_y);
00175
00176
00177
00178
00179
00180 void meta_rectangle_expand_to_avoiding_struts (
00181 MetaRectangle *rect,
00182 const MetaRectangle *expand_to,
00183 const MetaDirection direction,
00184 const GSList *all_struts);
00185
00186
00187
00188
00189
00190
00191
00192
00193 void meta_rectangle_free_list_and_elements (GList *filled_list);
00194
00195
00196
00197
00198
00199 gboolean meta_rectangle_could_fit_in_region (
00200 const GList *spanning_rects,
00201 const MetaRectangle *rect);
00202 gboolean meta_rectangle_contained_in_region (
00203 const GList *spanning_rects,
00204 const MetaRectangle *rect);
00205 gboolean meta_rectangle_overlaps_with_region (
00206 const GList *spanning_rects,
00207 const MetaRectangle *rect);
00208
00209
00210
00211
00212 void meta_rectangle_clamp_to_fit_into_region (
00213 const GList *spanning_rects,
00214 FixedDirections fixed_directions,
00215 MetaRectangle *rect,
00216 const MetaRectangle *min_size);
00217
00218
00219
00220
00221 void meta_rectangle_clip_to_region (const GList *spanning_rects,
00222 FixedDirections fixed_directions,
00223 MetaRectangle *rect);
00224
00225
00226
00227
00228 void meta_rectangle_shove_into_region(
00229 const GList *spanning_rects,
00230 FixedDirections fixed_directions,
00231 MetaRectangle *rect);
00232
00233
00234
00235
00236
00237 void meta_rectangle_find_linepoint_closest_to_point (double x1, double y1,
00238 double x2, double y2,
00239 double px, double py,
00240 double *valx, double *valy);
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251 gboolean meta_rectangle_edge_aligns (const MetaRectangle *rect,
00252 const MetaEdge *edge);
00253
00254
00255
00256
00257 gint meta_rectangle_edge_cmp (gconstpointer a, gconstpointer b);
00258
00259
00260
00261
00262
00263 gint meta_rectangle_edge_cmp_ignore_type (gconstpointer a, gconstpointer b);
00264
00265
00266
00267
00268 GList* meta_rectangle_remove_intersections_with_boxes_from_edges (
00269 GList *edges,
00270 const GSList *rectangles);
00271
00272
00273
00274
00275 GList* meta_rectangle_find_onscreen_edges (const MetaRectangle *basic_rect,
00276 const GSList *all_struts);
00277
00278
00279
00280
00281 GList* meta_rectangle_find_nonintersected_xinerama_edges (
00282 const GList *xinerama_rects,
00283 const GSList *all_struts);
00284
00285 #endif