summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Sanabria Carr <carrbs@cs.pdx.edu>2012-03-09 00:13:18 -0800
committerBenjamin Sanabria Carr <carrbs@cs.pdx.edu>2012-03-09 00:13:18 -0800
commit56ed6df50ef33ae5b87d87128e0d098e250e4d5f (patch)
tree099b9103b9224cac491847ce89888a9ae40ea249
parent7fa37b2403f1d3d7524dd8aeaf36b9bf422a8ac0 (diff)
added doxygen comments to my code, cleaned up old commented code, and moved some functions around to their appropriate places
-rw-r--r--src/libcompositewm/context_list.c40
-rw-r--r--src/libcompositewm/window.c89
-rw-r--r--src/libcompositewm/xtoq.c38
-rw-r--r--src/libcompositewm/xtoq.h17
-rw-r--r--src/libcompositewm/xtoq_internal.h46
5 files changed, 115 insertions, 115 deletions
diff --git a/src/libcompositewm/context_list.c b/src/libcompositewm/context_list.c
index a5029a7..9a0c30a 100644
--- a/src/libcompositewm/context_list.c
+++ b/src/libcompositewm/context_list.c
@@ -30,37 +30,17 @@ _xtoq_context_node *_xtoq_window_list_head = NULL;
xtoq_context_t *
_xtoq_add_context_t(struct xtoq_context_t *context)
{
- /* Does the window already exist */
- /*
- if (_xtoq_get_context_node_by_window_id(context->window))
- return NULL;
-
- xtoq_context_t * new_context;
- new_context = malloc(sizeof(xtoq_context_t));
-
- new_context->conn = context->conn;
- new_context->window = context->window;
- new_context->parent = context->parent;
- new_context->damage = context->damage;
- new_context->x = context->x;
- new_context->y = context->y;
- new_context->width = context->width;
- new_context->height = context->height;
- new_context->local_data = context->local_data;
- */
+ /* temp pointers for traversing */
_xtoq_context_node *new_node;
_xtoq_context_node *curr;
_xtoq_context_node *prev;
-
/* Create node to hold the new window */
-
new_node = malloc(sizeof(_xtoq_context_node));
if (!new_node) {
exit(1);
}
new_node->context = context;
- //new_node->context = new_context;
/* Handle the case where this is the first node added */
if (!_xtoq_window_list_head) {
@@ -68,28 +48,13 @@ _xtoq_add_context_t(struct xtoq_context_t *context)
new_node->next = NULL;
_xtoq_window_list_head = new_node;
} else {
- /*
- curr = _xtoq_window_list_head;
- while (curr->next) {
- prev = curr;
- curr = curr->next;
- }
- curr->next = new_node;
- new_node->prev = curr;
- new_node->next = NULL;
- */
-
- // Add the new node to the beginning of the list,
- // rather than the end.
+ /* Add the new node to the beginning of the list */
new_node->next = _xtoq_window_list_head;
_xtoq_window_list_head->prev = new_node;
new_node->prev = NULL;
-
_xtoq_window_list_head = new_node;
}
-
-
return new_node->context;
}
@@ -118,7 +83,6 @@ _xtoq_remove_context_node(xcb_window_t window_id) {
while (curr != NULL) {
if (curr->context->window == window_id) {
// this will be freed in the event_loop
- //free(curr->context);
if(curr->next){
curr->next->prev = curr->prev;
}
diff --git a/src/libcompositewm/window.c b/src/libcompositewm/window.c
index 17ec836..dbe01a4 100644
--- a/src/libcompositewm/window.c
+++ b/src/libcompositewm/window.c
@@ -89,14 +89,14 @@ _xtoq_window_created(xcb_connection_t * conn, xcb_map_request_event_t *event) {
return NULL;
}
- // allocate memory for new xtoq_context_t
+ /* allocate memory for new xtoq_context_t */
xtoq_context_t *context = malloc(sizeof(xtoq_context_t));
xcb_get_geometry_reply_t *geom;
geom = _xtoq_get_window_geometry(conn, event->window);
- // set any available values from xcb_create_notify_event_t object pointer
- // and geom pointer
+ /* set any available values from xcb_create_notify_event_t object pointer
+ and geom pointer */
context->conn = conn;
context->window = event->window;
context->parent = event->parent;
@@ -105,22 +105,22 @@ _xtoq_window_created(xcb_connection_t * conn, xcb_map_request_event_t *event) {
context->width = geom->width;
context->height = geom->height;
- // done with geom
free (geom);
/* Set the ICCCM properties we care about */
set_icccm_properties(context);
- //register for damage
+ /* register for damage */
init_damage_on_window(context);
- // add context to context_list
+ /* add context to context_list */
context = _xtoq_add_context_t(context);
return context;
}
-xtoq_context_t * _xtoq_destroy_window(xcb_destroy_notify_event_t *event) {
+xtoq_context_t *
+_xtoq_destroy_window(xcb_destroy_notify_event_t *event) {
xtoq_context_t *context = _xtoq_get_context_node_by_window_id(event->window);
if (!context) {
@@ -128,15 +128,67 @@ xtoq_context_t * _xtoq_destroy_window(xcb_destroy_notify_event_t *event) {
return NULL;
}
- // Destroy the damage object associated with the window.
+ /* Destroy the damage object associated with the window. */
xcb_damage_destroy(context->conn,context->damage);
- // Call the remove function in context_list.c
+ /* Call the remove function in context_list.c */
_xtoq_remove_context_node(context->window);
- //Returns the pointer for the context that was removed from the list.
+ /* Return the pointer for the context that was removed from the list. */
return context;
}
+void
+xtoq_configure_window(xtoq_context_t *context, int x, int y, int height, int width) {
+
+ /* Set values for xtoq_context_t */
+ context->x = x;
+ context->y = y;
+ context->width = width;
+ context->height = height;
+
+ uint32_t values[] = {(uint32_t)x, (uint32_t)y, (uint32_t)width, (uint32_t)height };
+
+ xcb_configure_window (context->conn, context->window, XCB_CONFIG_WINDOW_X
+ | XCB_CONFIG_WINDOW_Y | XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT, values);
+ xcb_flush(context->conn);
+ return;
+}
+
+void
+xtoq_request_close(xtoq_context_t *context) {
+
+ /* check to see if the context is in the list */
+ context = _xtoq_get_context_node_by_window_id(context->window);
+ if (!context)
+ return;
+
+ /* kill using xcb_kill_client */
+ if (!context->wm_delete_set == 1) {
+ xcb_kill_client(context->conn, context->window);
+ xcb_flush(context->conn);
+ return;
+ }
+ /* kill using WM_DELETE_WINDOW */
+ if (context->wm_delete_set == 1){
+ xcb_client_message_event_t event;
+
+ memset(&event, 0, sizeof(xcb_client_message_event_t));
+
+ event.response_type = XCB_CLIENT_MESSAGE;
+ event.window = context->window;
+ event.type = _wm_atoms->wm_protocols_atom;
+ event.format = 32;
+ event.data.data32[0] = _wm_atoms->wm_delete_window_atom;
+ event.data.data32[1] = XCB_CURRENT_TIME;
+
+ xcb_send_event(context->conn, 0, context->window, XCB_EVENT_MASK_NO_EVENT,
+ (char*)&event);
+ xcb_flush(context->conn);
+ return;
+
+ }
+ return;
+}
/* Resize the window on server side */
void
@@ -268,21 +320,4 @@ init_damage_on_window (xtoq_context_t *context)
context->damage = damage_id;
}
-void
-xtoq_configure_window(xtoq_context_t *context, int x, int y, int height, int width) {
-
- // Set values for xtoq_context_t
- context->x = x;
- context->y = y;
- context->width = width;
- context->height = height;
-
- uint32_t values[] = {(uint32_t)x, (uint32_t)y, (uint32_t)width, (uint32_t)height };
- /* The connection c and the window win are supposed to be defined */
-
- xcb_configure_window (context->conn, context->window, XCB_CONFIG_WINDOW_X
- | XCB_CONFIG_WINDOW_Y | XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT, values);
- xcb_flush(context->conn);
- return;
-}
diff --git a/src/libcompositewm/xtoq.c b/src/libcompositewm/xtoq.c
index 9a4ba08..fc22211 100644
--- a/src/libcompositewm/xtoq.c
+++ b/src/libcompositewm/xtoq.c
@@ -242,44 +242,6 @@ dummy_xtoq_mouse_motion (xtoq_context_t *context, long x, long y, int window, in
}
-/* SOURCE: http://i3-wm.sourcearchive.com/documentation/3.b/client_8c-source.html */
-
-void
-xtoq_request_close(xtoq_context_t *context) {
-
- // is the context in the list?
- context = _xtoq_get_context_node_by_window_id(context->window);
- if (!context)
- return;
-
- // kill using xcb_kill_client
- if (!context->wm_delete_set == 1) {
- xcb_kill_client(context->conn, context->window);
- xcb_flush(context->conn);
- return;
- }
- // kill using WM_DELETE_WINDOW
- if (context->wm_delete_set == 1){
- xcb_client_message_event_t event;
-
- memset(&event, 0, sizeof(xcb_client_message_event_t));
-
- event.response_type = XCB_CLIENT_MESSAGE;
- event.window = context->window;
- event.type = _wm_atoms->wm_protocols_atom;//atoms[WM_PROTOCOLS];
- event.format = 32;
- event.data.data32[0] = _wm_atoms->wm_delete_window_atom;//atoms[WM_DELETE_WINDOW];
- event.data.data32[1] = XCB_CURRENT_TIME;
-
- xcb_send_event(context->conn, 0, context->window, XCB_EVENT_MASK_NO_EVENT,
- (char*)&event);
- xcb_flush(context->conn);
- return;
-
- }
- return;
-}
-
/* Close all windows, the connection, as well as the event loop */
void xtoq_close(void) {
diff --git a/src/libcompositewm/xtoq.h b/src/libcompositewm/xtoq.h
index f44c0f4..36e9d65 100644
--- a/src/libcompositewm/xtoq.h
+++ b/src/libcompositewm/xtoq.h
@@ -137,9 +137,26 @@ dummy_xtoq_button_down (xtoq_context_t *context, long x, long y, int window, int
void
dummy_xtoq_mouse_motion (xtoq_context_t *context, long x, long y, int window, int button);
+/****************
+ * window.c
+ ****************/
+
+/**
+ * kill the window, if possible using WM_DELETE_WINDOW (icccm)
+ * otherwise using xcb_kill_client.
+ * @param context The context of the window to be killed
+ */
void
xtoq_request_close(xtoq_context_t *context);
+/**
+ * move and/or resize the window, update the context
+ * @param context the context of the window to configure
+ * @param x The new x coordinate
+ * @param y The new y coordinate
+ * @param height The new height
+ * @param width The new width
+ */
void
xtoq_configure_window(xtoq_context_t *context, int x, int y, int height, int width);
diff --git a/src/libcompositewm/xtoq_internal.h b/src/libcompositewm/xtoq_internal.h
index fe9c3e5..375199b 100644
--- a/src/libcompositewm/xtoq_internal.h
+++ b/src/libcompositewm/xtoq_internal.h
@@ -169,27 +169,40 @@ _xtoq_stop_event_loop (void);
* context_list.c
****************/
+/**
+ * A structure (doubly linked list) to hold
+ * pointers to the contexts
+ */
typedef struct _xtoq_context_node {
- struct xtoq_context_t *context;
- struct _xtoq_context_node * next;
- struct _xtoq_context_node * prev;
+ struct xtoq_context_t *context; /**< Pointer to a context */
+ struct _xtoq_context_node * next; /**< Pointer to the next context node */
+ struct _xtoq_context_node * prev; /**< Pointer to the previous context node */
} _xtoq_context_node;
-typedef struct _xtoq_context_list {
- struct _xtoq_context_node * head;
- int count;
-} _xtoq_context_list;
-
/* this is the head pointer */
extern _xtoq_context_node *_xtoq_window_list_head;
-
+/**
+ * Add a newly created context to the context_list.
+ * @param context The context to be added to the linked list
+ * @return Pointer to context added to the list.
+ */
xtoq_context_t *
_xtoq_add_context_t(struct xtoq_context_t *context);
+/**
+ * Remove a context to the context_list using the window's id.
+ * @param window_id The window_id of the context which should
+ * be removed from the context_list
+ */
void
_xtoq_remove_context_node(xcb_window_t window_id);
+/**
+ * Find a context in the doubly linked list using its window_id.
+ * @param window_id The window_id of the context which should
+ * @return Pointer to context (if found), NULL if not found.
+ */
xtoq_context_t *
_xtoq_get_context_node_by_window_id (xcb_window_t window_id);
@@ -203,10 +216,19 @@ _xtoq_get_context_node_by_window_id (xcb_window_t window_id);
* @param evt The map event for the window
* @return Pointer to new context. NULL if window already exists.
*/
-xtoq_context_t *_xtoq_window_created(xcb_connection_t * conn,
+xtoq_context_t *
+_xtoq_window_created(xcb_connection_t * conn,
xcb_map_request_event_t *evt);
-
-xtoq_context_t *_xtoq_destroy_window(xcb_destroy_notify_event_t *event);
+/**
+ * Destroy the damage object associated with the window.
+ * Call the remove function in context_list.c
+ * @param conn The connection to xserver
+ * @param event The destroy notify event for the window
+ * @return Pointer to the context that was removed from the list, NULL if
+ * window isn't being managed by context_list
+ */
+xtoq_context_t *
+_xtoq_destroy_window(xcb_destroy_notify_event_t *event);
/**
* Resize the window to given width and height.