Misc: Add margin_t & Store frame extents with it & Misc

- Add margin_t, a structure that represents margins around a rectangle.

 - Store frame extents of a window with margin_t, replacing the 4
   fields ({left,right,top,bottom}_width) in struct _win.

 - Add two helper macros, cmemzero() and cmemzero_one(), that zero out a
   block of memory.
This commit is contained in:
Richard Grenville
2015-09-06 20:53:07 +08:00
parent 86266e00e2
commit 7d4d87d683
4 changed files with 54 additions and 28 deletions

View File

@@ -279,6 +279,17 @@ typedef struct {
int y;
} geometry_t;
/// A structure representing margins around a rectangle.
typedef struct {
int top;
int left;
int bottom;
int right;
} margin_t;
// Or use cmemzero().
#define MARGIN_INIT { 0, 0, 0, 0 }
/// Enumeration type of window painting mode.
typedef enum {
WMODE_TRANS,
@@ -1174,8 +1185,8 @@ typedef struct _win {
// Frame-opacity-related members
/// Current window frame opacity. Affected by window opacity.
double frame_opacity;
/// Frame widths. Determined by client window attributes.
unsigned int left_width, right_width, top_width, bottom_width;
/// Frame extents. Acquired from _NET_FRAME_EXTENTS.
margin_t frame_extents;
// Shadow-related members
/// Whether a window has shadow. Calculated.
@@ -1343,6 +1354,13 @@ allocchk_(const char *func_name, void *ptr) {
/// @brief Wrapper of ealloc().
#define crealloc(ptr, nmemb, type) ((type *) allocchk(realloc((ptr), (nmemb) * sizeof(type))))
/// @brief Zero out the given memory block.
#define cmemzero(ptr, size) memset((ptr), 0, (size))
/// @brief Wrapper of cmemzero() that handles a pointer to a single item, for
/// convenience.
#define cmemzero_one(ptr) cmemzero((ptr), sizeof(*(ptr)))
/**
* Return whether a struct timeval value is empty.
*/