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:
22
src/common.h
22
src/common.h
@@ -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.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user