mark parameters const

next
Michael Stapelberg 2011-11-10 19:17:36 +00:00
parent e73538a56f
commit ed66a30410
5 changed files with 26 additions and 26 deletions

View File

@ -13,12 +13,12 @@
#include "tree.h"
/** Callback for dragging */
typedef void(*callback_t)(Con*, Rect*, uint32_t, uint32_t, void*);
typedef void(*callback_t)(Con*, Rect*, uint32_t, uint32_t, const void*);
/** Macro to create a callback function for dragging */
#define DRAGGING_CB(name) \
static void name(Con *con, Rect *old_rect, uint32_t new_x, \
uint32_t new_y, void *extra)
uint32_t new_y, const void *extra)
/** On which border was the dragging initiated? */
typedef enum { BORDER_LEFT = (1 << 0),
@ -89,7 +89,7 @@ int floating_border_click(xcb_connection_t *conn, Client *client,
* Calls the drag_pointer function with the drag_window callback
*
*/
void floating_drag_window(Con *con, xcb_button_press_event_t *event);
void floating_drag_window(Con *con, const xcb_button_press_event_t *event);
/**
* Called when the user clicked on a floating window while holding the
@ -97,7 +97,7 @@ void floating_drag_window(Con *con, xcb_button_press_event_t *event);
* Calls the drag_pointer function with the resize_window callback
*
*/
void floating_resize_window(Con *con, bool proportional, xcb_button_press_event_t *event);
void floating_resize_window(Con *con, const bool proportional, const xcb_button_press_event_t *event);
#if 0
/**
@ -133,8 +133,8 @@ void floating_toggle_hide(xcb_connection_t *conn, Workspace *workspace);
* the event and the new coordinates (x, y).
*
*/
void drag_pointer(Con *con, xcb_button_press_event_t *event,
void drag_pointer(Con *con, const xcb_button_press_event_t *event,
xcb_window_t confine_to, border_t border, callback_t callback,
void *extra);
const void *extra);
#endif

View File

@ -10,6 +10,6 @@
#ifndef _RESIZE_H
#define _RESIZE_H
int resize_graphical_handler(Con *first, Con *second, orientation_t orientation, xcb_button_press_event_t *event);
int resize_graphical_handler(Con *first, Con *second, orientation_t orientation, const xcb_button_press_event_t *event);
#endif

View File

@ -25,7 +25,7 @@ typedef enum { CLICK_BORDER = 0, CLICK_DECORATION = 1, CLICK_INSIDE = 2 } click_
* then calls resize_graphical_handler().
*
*/
static bool tiling_resize_for_border(Con *con, border_t border, xcb_button_press_event_t *event) {
static bool tiling_resize_for_border(Con *con, border_t border, const xcb_button_press_event_t *event) {
DLOG("border = %d\n", border);
char way = (border == BORDER_TOP || border == BORDER_LEFT ? 'p' : 'n');
orientation_t orientation = (border == BORDER_TOP || border == BORDER_BOTTOM ? VERT : HORIZ);
@ -76,7 +76,7 @@ static bool tiling_resize_for_border(Con *con, border_t border, xcb_button_press
* to the client).
*
*/
static bool floating_mod_on_tiled_client(Con *con, xcb_button_press_event_t *event) {
static bool floating_mod_on_tiled_client(Con *con, const xcb_button_press_event_t *event) {
/* The client is in tiling layout. We can still initiate a resize with the
* right mouse button, by chosing the border which is the most near one to
* the position of the mouse pointer */
@ -115,7 +115,7 @@ static bool floating_mod_on_tiled_client(Con *con, xcb_button_press_event_t *eve
* Finds out which border was clicked on and calls tiling_resize_for_border().
*
*/
static bool tiling_resize(Con *con, xcb_button_press_event_t *event, click_destination_t dest) {
static bool tiling_resize(Con *con, const xcb_button_press_event_t *event, const click_destination_t dest) {
/* check if this was a click on the window border (and on which one) */
Rect bsr = con_border_style_rect(con);
DLOG("BORDER x = %d, y = %d for con %p, window 0x%08x\n",
@ -165,7 +165,7 @@ static bool tiling_resize(Con *con, xcb_button_press_event_t *event, click_desti
* functions for resizing/dragging.
*
*/
static int route_click(Con *con, xcb_button_press_event_t *event, bool mod_pressed, click_destination_t dest) {
static int route_click(Con *con, const xcb_button_press_event_t *event, const bool mod_pressed, const click_destination_t dest) {
DLOG("--> click properties: mod = %d, destination = %d\n", mod_pressed, dest);
DLOG("--> OUTCOME = %p\n", con);
DLOG("type = %d, name = %s\n", con->type, con->name);
@ -279,7 +279,7 @@ int handle_button_press(xcb_button_press_event_t *event) {
last_timestamp = event->time;
const uint32_t mod = config.floating_modifier;
bool mod_pressed = (mod != 0 && (event->state & mod) == mod);
const bool mod_pressed = (mod != 0 && (event->state & mod) == mod);
DLOG("floating_mod = %d, detail = %d\n", mod_pressed, event->detail);
if ((con = con_by_window_id(event->event)))
return route_click(con, event, mod_pressed, CLICK_INSIDE);

View File

@ -296,7 +296,7 @@ bool floating_maybe_reassign_ws(Con *con) {
}
DRAGGING_CB(drag_window_callback) {
struct xcb_button_press_event_t *event = extra;
const struct xcb_button_press_event_t *event = extra;
/* Reposition the client correctly while moving */
con->rect.x = old_rect->x + (new_x - event->root_x);
@ -317,7 +317,7 @@ DRAGGING_CB(drag_window_callback) {
* Calls the drag_pointer function with the drag_window callback
*
*/
void floating_drag_window(Con *con, xcb_button_press_event_t *event) {
void floating_drag_window(Con *con, const xcb_button_press_event_t *event) {
DLOG("floating_drag_window\n");
/* Push changes before dragging, so that the window gets raised now and not
@ -337,14 +337,14 @@ void floating_drag_window(Con *con, xcb_button_press_event_t *event) {
*
*/
struct resize_window_callback_params {
border_t corner;
bool proportional;
xcb_button_press_event_t *event;
const border_t corner;
const bool proportional;
const xcb_button_press_event_t *event;
};
DRAGGING_CB(resize_window_callback) {
struct resize_window_callback_params *params = extra;
xcb_button_press_event_t *event = params->event;
const struct resize_window_callback_params *params = extra;
const xcb_button_press_event_t *event = params->event;
border_t corner = params->corner;
int32_t dest_x = con->rect.x;
@ -397,8 +397,8 @@ DRAGGING_CB(resize_window_callback) {
* Calls the drag_pointer function with the resize_window callback
*
*/
void floating_resize_window(Con *con, bool proportional,
xcb_button_press_event_t *event) {
void floating_resize_window(Con *con, const bool proportional,
const xcb_button_press_event_t *event) {
DLOG("floating_resize_window\n");
/* corner saves the nearest corner to the original click. It contains
@ -426,8 +426,8 @@ void floating_resize_window(Con *con, bool proportional,
* the event and the new coordinates (x, y).
*
*/
void drag_pointer(Con *con, xcb_button_press_event_t *event, xcb_window_t
confine_to, border_t border, callback_t callback, void *extra)
void drag_pointer(Con *con, const xcb_button_press_event_t *event, xcb_window_t
confine_to, border_t border, callback_t callback, const void *extra)
{
uint32_t new_x, new_y;
Rect old_rect;

View File

@ -26,7 +26,7 @@ struct callback_params {
};
DRAGGING_CB(resize_callback) {
struct callback_params *params = extra;
const struct callback_params *params = extra;
Con *output = params->output;
DLOG("new x = %d, y = %d\n", new_x, new_y);
if (params->orientation == HORIZ) {
@ -49,7 +49,7 @@ DRAGGING_CB(resize_callback) {
xcb_flush(conn);
}
int resize_graphical_handler(Con *first, Con *second, orientation_t orientation, xcb_button_press_event_t *event) {
int resize_graphical_handler(Con *first, Con *second, orientation_t orientation, const xcb_button_press_event_t *event) {
DLOG("resize handler\n");
uint32_t new_position;
@ -98,7 +98,7 @@ int resize_graphical_handler(Con *first, Con *second, orientation_t orientation,
xcb_flush(conn);
struct callback_params params = { orientation, output, helpwin, &new_position };
const struct callback_params params = { orientation, output, helpwin, &new_position };
drag_pointer(NULL, event, grabwin, BORDER_TOP, resize_callback, &params);