summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon TURNEY <jon.turney@dronecode.org.uk>2012-11-10 17:54:59 +0000
committerJon TURNEY <jon.turney@dronecode.org.uk>2012-11-21 14:03:19 +0000
commitddf894f4f90599554a87b75fde129c1a000fb042 (patch)
tree5751c609c50eb56929e3faf55d15878b0115f5fd
parent96f0a37984cab1a9a4daecfb056bfe4cd161f6fe (diff)
Make xcwm_rect_t bounds and dmg_bounds members, rather than an allocation in xcwm_window_t
-rw-r--r--include/xcwm/window.h4
-rw-r--r--src/libxcwm/context.c12
-rw-r--r--src/libxcwm/event_loop.c16
-rw-r--r--src/libxcwm/image.c18
-rw-r--r--src/libxcwm/window.c60
-rw-r--r--src/libxcwm/xcwm_internal.h4
6 files changed, 51 insertions, 63 deletions
diff --git a/include/xcwm/window.h b/include/xcwm/window.h
index 3cea314..b476cb8 100644
--- a/include/xcwm/window.h
+++ b/include/xcwm/window.h
@@ -189,7 +189,7 @@ xcwm_window_set_local_data(xcwm_window_t *window, void *data_ptr);
* @param window Window to get rectangle from.
* @return The rectangle.
*/
-xcwm_rect_t *
+const xcwm_rect_t *
xcwm_window_get_full_rect(xcwm_window_t const *window);
/**
@@ -197,7 +197,7 @@ xcwm_window_get_full_rect(xcwm_window_t const *window);
* @param window The window to get damage from.
* @return Rectangle describing damaged area.
*/
-xcwm_rect_t *
+const xcwm_rect_t *
xcwm_window_get_damaged_rect(xcwm_window_t const *window);
/**
diff --git a/src/libxcwm/context.c b/src/libxcwm/context.c
index a66747a..88d2c32 100644
--- a/src/libxcwm/context.c
+++ b/src/libxcwm/context.c
@@ -81,10 +81,6 @@ xcwm_context_open(char *display)
assert(root_context);
root_context->root_window = malloc(sizeof(xcwm_window_t));
assert(root_context->root_window);
- root_context->root_window->bounds = malloc(sizeof(xcwm_rect_t));
- root_context->root_window->dmg_bounds = malloc(sizeof(xcwm_rect_t));
- assert(root_context->root_window->bounds);
- assert(root_context->root_window->dmg_bounds);
root_context->conn = conn;
root_context->conn_screen = conn_screen;
@@ -94,10 +90,10 @@ xcwm_context_open(char *display)
root_context->root_window->context = root_context;
/* Set width, height, x, & y from root_screen into the xcwm_context_t */
- root_context->root_window->bounds->width = root_screen->width_in_pixels;
- root_context->root_window->bounds->height = root_screen->height_in_pixels;
- root_context->root_window->bounds->x = 0;
- root_context->root_window->bounds->y = 0;
+ root_context->root_window->bounds.width = root_screen->width_in_pixels;
+ root_context->root_window->bounds.height = root_screen->height_in_pixels;
+ root_context->root_window->bounds.x = 0;
+ root_context->root_window->bounds.y = 0;
_xcwm_init_composite(root_context);
diff --git a/src/libxcwm/event_loop.c b/src/libxcwm/event_loop.c
index a856487..71d8010 100644
--- a/src/libxcwm/event_loop.c
+++ b/src/libxcwm/event_loop.c
@@ -227,8 +227,8 @@ run_event_loop(void *thread_arg_struct)
* where the damage area is larger than the bounds of the
* window. */
if (return_evt->window->initial_damage == 1
- || (dmgevnt->area.width > return_evt->window->bounds->width)
- || (dmgevnt->area.height > return_evt->window->bounds->height) ) {
+ || (dmgevnt->area.width > return_evt->window->bounds.width)
+ || (dmgevnt->area.height > return_evt->window->bounds.height) ) {
xcb_xfixes_region_t region =
xcb_generate_id(return_evt->window->context->conn);
xcb_rectangle_t rect;
@@ -248,8 +248,8 @@ run_event_loop(void *thread_arg_struct)
/* Add new damage area for entire window */
rect.x = 0;
rect.y = 0;
- rect.width = return_evt->window->bounds->width;
- rect.height = return_evt->window->bounds->height;
+ rect.width = return_evt->window->bounds.width;
+ rect.height = return_evt->window->bounds.height;
xcb_xfixes_set_region(return_evt->window->context->conn,
region,
1,
@@ -266,10 +266,10 @@ run_event_loop(void *thread_arg_struct)
continue;
}
- return_evt->window->dmg_bounds->x = dmgevnt->area.x;
- return_evt->window->dmg_bounds->y = dmgevnt->area.y;
- return_evt->window->dmg_bounds->width = dmgevnt->area.width;
- return_evt->window->dmg_bounds->height = dmgevnt->area.height;
+ return_evt->window->dmg_bounds.x = dmgevnt->area.x;
+ return_evt->window->dmg_bounds.y = dmgevnt->area.y;
+ return_evt->window->dmg_bounds.width = dmgevnt->area.width;
+ return_evt->window->dmg_bounds.height = dmgevnt->area.height;
xcwm_event_release_thread_lock();
diff --git a/src/libxcwm/image.c b/src/libxcwm/image.c
index eed868e..e762716 100644
--- a/src/libxcwm/image.c
+++ b/src/libxcwm/image.c
@@ -83,17 +83,17 @@ xcwm_image_copy_damaged(xcwm_window_t *window)
xcb_flush(window->context->conn);
/* Return null if image is 0 by 0 */
- if (window->dmg_bounds->width == 0 || window->dmg_bounds->height == 0) {
+ if (window->dmg_bounds.width == 0 || window->dmg_bounds.height == 0) {
return NULL;
}
/* Get the image of the damaged area of the window */
image = xcb_image_get(window->context->conn,
window->composite_pixmap_id,
- window->dmg_bounds->x,
- window->dmg_bounds->y,
- window->dmg_bounds->width,
- window->dmg_bounds->height,
+ window->dmg_bounds.x,
+ window->dmg_bounds.y,
+ window->dmg_bounds.width,
+ window->dmg_bounds.height,
(unsigned int)~0L,
XCB_IMAGE_FORMAT_Z_PIXMAP);
@@ -105,10 +105,10 @@ xcwm_image_copy_damaged(xcwm_window_t *window)
xcwm_image_t * xcwm_image = malloc(sizeof(xcwm_image_t));
xcwm_image->image = image;
- xcwm_image->x = window->dmg_bounds->x;
- xcwm_image->y = window->dmg_bounds->y;
- xcwm_image->width = window->dmg_bounds->width;
- xcwm_image->height = window->dmg_bounds->height;
+ xcwm_image->x = window->dmg_bounds.x;
+ xcwm_image->y = window->dmg_bounds.y;
+ xcwm_image->width = window->dmg_bounds.width;
+ xcwm_image->height = window->dmg_bounds.height;
return xcwm_image;
}
diff --git a/src/libxcwm/window.c b/src/libxcwm/window.c
index 998d997..58e3ca4 100644
--- a/src/libxcwm/window.c
+++ b/src/libxcwm/window.c
@@ -104,19 +104,15 @@ _xcwm_window_create(xcwm_context_t *context, xcb_window_t new_window,
/* allocate memory for new xcwm_window_t and rectangles */
xcwm_window_t *window = malloc(sizeof(xcwm_window_t));
assert(window);
- window->bounds = malloc(sizeof(xcwm_rect_t));
- assert(window->bounds);
- window->dmg_bounds = malloc(sizeof(xcwm_rect_t));
- assert(window->dmg_bounds);
/* set any available values from xcb_create_notify_event_t object pointer
and geom pointer */
window->context = context;
window->window_id = new_window;
- window->bounds->x = geom->x;
- window->bounds->y = geom->y;
- window->bounds->width = geom->width;
- window->bounds->height = geom->height;
+ window->bounds.x = geom->x;
+ window->bounds.y = geom->y;
+ window->bounds.width = geom->width;
+ window->bounds.height = geom->height;
window->opacity = ~0;
window->composite_pixmap_id = 0;
window->local_data = 0;
@@ -182,16 +178,16 @@ xcwm_window_configure(xcwm_window_t *window, int x, int y,
{
/* Set values for xcwm_window_t */
- window->bounds->x = x;
- window->bounds->y = y;
- window->bounds->width = width;
- window->bounds->height = height;
+ window->bounds.x = x;
+ window->bounds.y = y;
+ window->bounds.width = width;
+ window->bounds.height = height;
_xcwm_resize_window(window->context->conn, window->window_id,
x, y, width, height);
/* Set the damage area to the new window size so its redrawn properly */
- window->dmg_bounds->width = width;
- window->dmg_bounds->height = height;
+ window->dmg_bounds.width = width;
+ window->dmg_bounds.height = height;
}
void
@@ -205,10 +201,10 @@ xcwm_window_remove_damage(xcwm_window_t *window)
return;
}
- rect.x = window->dmg_bounds->x;
- rect.y = window->dmg_bounds->y;
- rect.width = window->dmg_bounds->width;
- rect.height = window->dmg_bounds->height;
+ rect.x = window->dmg_bounds.x;
+ rect.y = window->dmg_bounds.y;
+ rect.width = window->dmg_bounds.width;
+ rect.height = window->dmg_bounds.height;
xcb_xfixes_create_region(window->context->conn,
region,
@@ -222,10 +218,10 @@ xcwm_window_remove_damage(xcwm_window_t *window)
if (!(_xcwm_request_check(window->context->conn, cookie,
"Failed to subtract damage"))) {
- window->dmg_bounds->x = 0;
- window->dmg_bounds->y = 0;
- window->dmg_bounds->width = 0;
- window->dmg_bounds->height = 0;
+ window->dmg_bounds.x = 0;
+ window->dmg_bounds.y = 0;
+ window->dmg_bounds.width = 0;
+ window->dmg_bounds.height = 0;
}
return;
}
@@ -273,10 +269,6 @@ _xcwm_window_release(xcwm_window_t *window)
return;
}
- free(window->bounds);
- if (window->dmg_bounds) {
- free(window->dmg_bounds);
- }
if (window->name) {
free(window->name);
}
@@ -341,18 +333,18 @@ xcwm_window_set_local_data(xcwm_window_t *window, void *data_ptr)
window->local_data = data_ptr;
}
-xcwm_rect_t *
+const xcwm_rect_t *
xcwm_window_get_full_rect(xcwm_window_t const *window)
{
- return window->bounds;
+ return &(window->bounds);
}
-xcwm_rect_t *
+const xcwm_rect_t *
xcwm_window_get_damaged_rect(xcwm_window_t const *window)
{
- return window->dmg_bounds;
+ return &(window->dmg_bounds);
}
char *
@@ -579,8 +571,8 @@ init_damage_on_window(xcb_connection_t *conn, xcwm_window_t *window)
window->damage = damage_id;
/* Initialize the damaged area in the window to zero */
- window->dmg_bounds->x = 0;
- window->dmg_bounds->y = 0;
- window->dmg_bounds->width = 0;
- window->dmg_bounds->height = 0;
+ window->dmg_bounds.x = 0;
+ window->dmg_bounds.y = 0;
+ window->dmg_bounds.width = 0;
+ window->dmg_bounds.height = 0;
}
diff --git a/src/libxcwm/xcwm_internal.h b/src/libxcwm/xcwm_internal.h
index d2b0b44..cc183f8 100644
--- a/src/libxcwm/xcwm_internal.h
+++ b/src/libxcwm/xcwm_internal.h
@@ -80,8 +80,8 @@ struct xcwm_window_t {
struct xcwm_window_t *parent;
struct xcwm_window_t *transient_for; /* Window this one is transient for */
xcb_damage_damage_t damage;
- xcwm_rect_t *bounds;
- xcwm_rect_t *dmg_bounds;
+ xcwm_rect_t bounds;
+ xcwm_rect_t dmg_bounds;
xcb_size_hints_t size_hints; /* WM_NORMAL_HINTS */
char *name; /* The name of the window */
int wm_delete_set; /* Flag for WM_DELETE_WINDOW, 1 if set */