[swindow] Add border manipulation function

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2008-05-03 15:17:46 +02:00
parent 7f284ba15a
commit f42f75468c
2 changed files with 62 additions and 25 deletions

View File

@ -24,15 +24,16 @@
#include "common/swindow.h" #include "common/swindow.h"
/** Create a simple window /** Create a simple window.
* \param conn Connection ref * \param conn Connection ref.
* \param phys_screen physical screen id * \param phys_screen Physical screen number.
* \param x x coordinate * \param x x coordinate.
* \param y y coordinate * \param y y coordinate.
* \param w width * \param w Width.
* \param h height * \param h Height.
* \param border_width window's border width * \param border_width Window border width.
* \return pointer to a simple_window_t * \return A pointer to a newly allocated simple window, which must be deleted
* with simplewindow_delete().
*/ */
simple_window_t * simple_window_t *
simplewindow_new(xcb_connection_t *conn, int phys_screen, int x, int y, simplewindow_new(xcb_connection_t *conn, int phys_screen, int x, int y,
@ -76,13 +77,13 @@ simplewindow_new(xcb_connection_t *conn, int phys_screen, int x, int y,
sw->gc = xcb_generate_id(sw->connection); sw->gc = xcb_generate_id(sw->connection);
xcb_create_gc(sw->connection, sw->gc, gc_draw, gc_mask, gc_values); xcb_create_gc(sw->connection, sw->gc, gc_draw, gc_mask, gc_values);
sw->border = border_width; sw->border_width = border_width;
return sw; return sw;
} }
/** Destroy a simple window and all its resources /** Destroy a simple window and all its resources.
* \param sw the simple_window_t to delete * \param sw The simple_window_t to delete.
*/ */
void void
simplewindow_delete(simple_window_t **sw) simplewindow_delete(simple_window_t **sw)
@ -93,10 +94,10 @@ simplewindow_delete(simple_window_t **sw)
p_delete(sw); p_delete(sw);
} }
/** Move a simple window /** Move a simple window.
* \param sw the simple_window_t to move * \param sw The simple window to move.
* \param x x coordinate * \param x New x coordinate.
* \param y y coordinate * \param y New y coordinate.
*/ */
void void
simplewindow_move(simple_window_t *sw, int x, int y) simplewindow_move(simple_window_t *sw, int x, int y)
@ -110,10 +111,10 @@ simplewindow_move(simple_window_t *sw, int x, int y)
move_win_vals); move_win_vals);
} }
/** Resize a simple window /** Resize a simple window.
* \param sw the simple_window_t to resize * \param sw The simple_window_t to resize.
* \param w new width * \param w New width.
* \param h new height * \param h New height.
*/ */
void void
simplewindow_resize(simple_window_t *sw, unsigned int w, unsigned int h) simplewindow_resize(simple_window_t *sw, unsigned int w, unsigned int h)

View File

@ -24,16 +24,23 @@
#include "common/draw.h" #include "common/draw.h"
/** A simple window */ /** A simple window. */
typedef struct simple_window_t typedef struct simple_window_t
{ {
/** The display connection. */
xcb_connection_t *connection; xcb_connection_t *connection;
/** The physical screen number the window is on. */
int phys_screen; int phys_screen;
/** The window object. */
xcb_window_t window; xcb_window_t window;
/** The drawable copied to the window object. */
xcb_drawable_t drawable; xcb_drawable_t drawable;
/** The graphic context. */
xcb_gcontext_t gc; xcb_gcontext_t gc;
/** The window geometry. */
area_t geometry; area_t geometry;
int border; /** The window border width */
int border_width;
} simple_window_t; } simple_window_t;
simple_window_t * simplewindow_new(xcb_connection_t *, int, int, int, unsigned int, unsigned int, unsigned int); simple_window_t * simplewindow_new(xcb_connection_t *, int, int, int, unsigned int, unsigned int, unsigned int);
@ -41,6 +48,13 @@ void simplewindow_delete(simple_window_t **);
void simplewindow_move(simple_window_t *, int, int); void simplewindow_move(simple_window_t *, int, int);
void simplewindow_resize(simple_window_t *, unsigned int, unsigned int); void simplewindow_resize(simple_window_t *, unsigned int, unsigned int);
/** Move and resize a window in one call.
* \param sw The simple window to move and resize.
* \param x The new x coordinate.
* \param y The new y coordinate.
* \param w The new width.
* \param h The new height.
*/
static inline void static inline void
simplewindow_move_resize(simple_window_t *sw, int x, int y, simplewindow_move_resize(simple_window_t *sw, int x, int y,
unsigned int w, unsigned int h) unsigned int w, unsigned int h)
@ -49,9 +63,8 @@ simplewindow_move_resize(simple_window_t *sw, int x, int y,
simplewindow_resize(sw, w, h); simplewindow_resize(sw, w, h);
} }
/** Refresh the window content /** Refresh the window content by copying its drawable data to its window.
* \param sw the simple_window_t to refresh * \param sw The simple window to refresh.
* \param phys_screen physical screen id
*/ */
static inline void static inline void
simplewindow_refresh_drawable(simple_window_t *sw) simplewindow_refresh_drawable(simple_window_t *sw)
@ -62,5 +75,28 @@ simplewindow_refresh_drawable(simple_window_t *sw)
sw->geometry.height); sw->geometry.height);
} }
/** Set a simple window border width.
* \param sw The simple window to change border width.
* \param border_width The border width in pixel.
*/
static inline void
simplewindow_border_width_set(simple_window_t *sw, uint32_t border_width)
{
xcb_configure_window(sw->connection, sw->window, XCB_CONFIG_WINDOW_BORDER_WIDTH,
&border_width);
sw->border_width = border_width;
}
/** Set a simple window border color.
* \param sw The simple window to change border width.
* \param border_color The border color.
*/
static inline void
simplewindow_border_color_set(simple_window_t *sw, xcolor_t *color)
{
xcb_change_window_attributes(sw->connection, sw->window,
XCB_CW_BORDER_PIXEL, &color->pixel);
}
#endif #endif
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80