mark parameters const
This commit is contained in:
parent
e73538a56f
commit
ed66a30410
|
@ -13,12 +13,12 @@
|
||||||
#include "tree.h"
|
#include "tree.h"
|
||||||
|
|
||||||
/** Callback for dragging */
|
/** 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 */
|
/** Macro to create a callback function for dragging */
|
||||||
#define DRAGGING_CB(name) \
|
#define DRAGGING_CB(name) \
|
||||||
static void name(Con *con, Rect *old_rect, uint32_t new_x, \
|
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? */
|
/** On which border was the dragging initiated? */
|
||||||
typedef enum { BORDER_LEFT = (1 << 0),
|
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
|
* 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
|
* 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
|
* 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
|
#if 0
|
||||||
/**
|
/**
|
||||||
|
@ -133,8 +133,8 @@ void floating_toggle_hide(xcb_connection_t *conn, Workspace *workspace);
|
||||||
* the event and the new coordinates (x, y).
|
* 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,
|
xcb_window_t confine_to, border_t border, callback_t callback,
|
||||||
void *extra);
|
const void *extra);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -10,6 +10,6 @@
|
||||||
#ifndef _RESIZE_H
|
#ifndef _RESIZE_H
|
||||||
#define _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
|
#endif
|
||||||
|
|
10
src/click.c
10
src/click.c
|
@ -25,7 +25,7 @@ typedef enum { CLICK_BORDER = 0, CLICK_DECORATION = 1, CLICK_INSIDE = 2 } click_
|
||||||
* then calls resize_graphical_handler().
|
* 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);
|
DLOG("border = %d\n", border);
|
||||||
char way = (border == BORDER_TOP || border == BORDER_LEFT ? 'p' : 'n');
|
char way = (border == BORDER_TOP || border == BORDER_LEFT ? 'p' : 'n');
|
||||||
orientation_t orientation = (border == BORDER_TOP || border == BORDER_BOTTOM ? VERT : HORIZ);
|
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).
|
* 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
|
/* 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
|
* right mouse button, by chosing the border which is the most near one to
|
||||||
* the position of the mouse pointer */
|
* 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().
|
* 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) */
|
/* check if this was a click on the window border (and on which one) */
|
||||||
Rect bsr = con_border_style_rect(con);
|
Rect bsr = con_border_style_rect(con);
|
||||||
DLOG("BORDER x = %d, y = %d for con %p, window 0x%08x\n",
|
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.
|
* 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("--> click properties: mod = %d, destination = %d\n", mod_pressed, dest);
|
||||||
DLOG("--> OUTCOME = %p\n", con);
|
DLOG("--> OUTCOME = %p\n", con);
|
||||||
DLOG("type = %d, name = %s\n", con->type, con->name);
|
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;
|
last_timestamp = event->time;
|
||||||
|
|
||||||
const uint32_t mod = config.floating_modifier;
|
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);
|
DLOG("floating_mod = %d, detail = %d\n", mod_pressed, event->detail);
|
||||||
if ((con = con_by_window_id(event->event)))
|
if ((con = con_by_window_id(event->event)))
|
||||||
return route_click(con, event, mod_pressed, CLICK_INSIDE);
|
return route_click(con, event, mod_pressed, CLICK_INSIDE);
|
||||||
|
|
|
@ -296,7 +296,7 @@ bool floating_maybe_reassign_ws(Con *con) {
|
||||||
}
|
}
|
||||||
|
|
||||||
DRAGGING_CB(drag_window_callback) {
|
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 */
|
/* Reposition the client correctly while moving */
|
||||||
con->rect.x = old_rect->x + (new_x - event->root_x);
|
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
|
* 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");
|
DLOG("floating_drag_window\n");
|
||||||
|
|
||||||
/* Push changes before dragging, so that the window gets raised now and not
|
/* 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 {
|
struct resize_window_callback_params {
|
||||||
border_t corner;
|
const border_t corner;
|
||||||
bool proportional;
|
const bool proportional;
|
||||||
xcb_button_press_event_t *event;
|
const xcb_button_press_event_t *event;
|
||||||
};
|
};
|
||||||
|
|
||||||
DRAGGING_CB(resize_window_callback) {
|
DRAGGING_CB(resize_window_callback) {
|
||||||
struct resize_window_callback_params *params = extra;
|
const struct resize_window_callback_params *params = extra;
|
||||||
xcb_button_press_event_t *event = params->event;
|
const xcb_button_press_event_t *event = params->event;
|
||||||
border_t corner = params->corner;
|
border_t corner = params->corner;
|
||||||
|
|
||||||
int32_t dest_x = con->rect.x;
|
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
|
* Calls the drag_pointer function with the resize_window callback
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void floating_resize_window(Con *con, bool proportional,
|
void floating_resize_window(Con *con, const bool proportional,
|
||||||
xcb_button_press_event_t *event) {
|
const xcb_button_press_event_t *event) {
|
||||||
DLOG("floating_resize_window\n");
|
DLOG("floating_resize_window\n");
|
||||||
|
|
||||||
/* corner saves the nearest corner to the original click. It contains
|
/* 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).
|
* the event and the new coordinates (x, y).
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void drag_pointer(Con *con, xcb_button_press_event_t *event, xcb_window_t
|
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)
|
confine_to, border_t border, callback_t callback, const void *extra)
|
||||||
{
|
{
|
||||||
uint32_t new_x, new_y;
|
uint32_t new_x, new_y;
|
||||||
Rect old_rect;
|
Rect old_rect;
|
||||||
|
|
|
@ -26,7 +26,7 @@ struct callback_params {
|
||||||
};
|
};
|
||||||
|
|
||||||
DRAGGING_CB(resize_callback) {
|
DRAGGING_CB(resize_callback) {
|
||||||
struct callback_params *params = extra;
|
const struct callback_params *params = extra;
|
||||||
Con *output = params->output;
|
Con *output = params->output;
|
||||||
DLOG("new x = %d, y = %d\n", new_x, new_y);
|
DLOG("new x = %d, y = %d\n", new_x, new_y);
|
||||||
if (params->orientation == HORIZ) {
|
if (params->orientation == HORIZ) {
|
||||||
|
@ -49,7 +49,7 @@ DRAGGING_CB(resize_callback) {
|
||||||
xcb_flush(conn);
|
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");
|
DLOG("resize handler\n");
|
||||||
|
|
||||||
uint32_t new_position;
|
uint32_t new_position;
|
||||||
|
@ -98,7 +98,7 @@ int resize_graphical_handler(Con *first, Con *second, orientation_t orientation,
|
||||||
|
|
||||||
xcb_flush(conn);
|
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, ¶ms);
|
drag_pointer(NULL, event, grabwin, BORDER_TOP, resize_callback, ¶ms);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue