i3
handlers.c File Reference
#include "all.h"
#include <sys/time.h>
#include <time.h>
#include <xcb/randr.h>
#include <libsn/sn-monitor.h>
Include dependency graph for handlers.c:

Go to the source code of this file.

Data Structures

struct  property_handler_t
 

Macros

#define SN_API_NOT_YET_FROZEN   1
 
#define COPY_MASK_MEMBER(mask_member, event_member)
 
#define _NET_WM_MOVERESIZE_SIZE_TOPLEFT   0
 
#define _NET_WM_MOVERESIZE_SIZE_TOP   1
 
#define _NET_WM_MOVERESIZE_SIZE_TOPRIGHT   2
 
#define _NET_WM_MOVERESIZE_SIZE_RIGHT   3
 
#define _NET_WM_MOVERESIZE_SIZE_BOTTOMRIGHT   4
 
#define _NET_WM_MOVERESIZE_SIZE_BOTTOM   5
 
#define _NET_WM_MOVERESIZE_SIZE_BOTTOMLEFT   6
 
#define _NET_WM_MOVERESIZE_SIZE_LEFT   7
 
#define _NET_WM_MOVERESIZE_MOVE   8 /* movement only */
 
#define _NET_WM_MOVERESIZE_SIZE_KEYBOARD   9 /* size via keyboard */
 
#define _NET_WM_MOVERESIZE_MOVE_KEYBOARD   10 /* move via keyboard */
 
#define _NET_WM_MOVERESIZE_CANCEL   11 /* cancel operation */
 
#define _NET_MOVERESIZE_WINDOW_X   (1 << 8)
 
#define _NET_MOVERESIZE_WINDOW_Y   (1 << 9)
 
#define _NET_MOVERESIZE_WINDOW_WIDTH   (1 << 10)
 
#define _NET_MOVERESIZE_WINDOW_HEIGHT   (1 << 11)
 
#define NUM_HANDLERS   (sizeof(property_handlers) / sizeof(struct property_handler_t))
 

Typedefs

typedef bool(* cb_property_handler_t) (Con *con, xcb_get_property_reply_t *property)
 

Functions

static SLIST_HEAD (ignore_head, Ignore_Event)
 
bool event_is_ignored (const int sequence, const int response_type)
 Checks if the given sequence is ignored and returns true if so.
 
static void check_crossing_screen_boundary (uint32_t x, uint32_t y)
 
static void handle_enter_notify (xcb_enter_notify_event_t *event)
 
static void handle_motion_notify (xcb_motion_notify_event_t *event)
 
static void handle_mapping_notify (xcb_mapping_notify_event_t *event)
 
static void handle_map_request (xcb_map_request_event_t *event)
 
static void handle_configure_request (xcb_configure_request_event_t *event)
 
static void handle_screen_change (xcb_generic_event_t *e)
 
static void handle_unmap_notify_event (xcb_unmap_notify_event_t *event)
 
static void handle_destroy_notify_event (xcb_destroy_notify_event_t *event)
 
static bool window_name_changed (i3Window *window, char *old_name)
 
static bool handle_windowname_change (Con *con, xcb_get_property_reply_t *prop)
 
static bool handle_windowname_change_legacy (Con *con, xcb_get_property_reply_t *prop)
 
static bool handle_windowrole_change (Con *con, xcb_get_property_reply_t *prop)
 
static void handle_expose_event (xcb_expose_event_t *event)
 
static void handle_net_wm_state_change (Con *con, uint32_t change, uint32_t atom)
 
static void handle_client_message (xcb_client_message_event_t *event)
 
static bool handle_window_type (Con *con, xcb_get_property_reply_t *reply)
 
static bool handle_normal_hints (Con *con, xcb_get_property_reply_t *reply)
 
static bool handle_hints (Con *con, xcb_get_property_reply_t *reply)
 
static bool handle_transient_for (Con *con, xcb_get_property_reply_t *prop)
 
static bool handle_clientleader_change (Con *con, xcb_get_property_reply_t *prop)
 
static void handle_focus_in (xcb_focus_in_event_t *event)
 
static void handle_focus_out (xcb_focus_in_event_t *event)
 
static void handle_configure_notify (xcb_configure_notify_event_t *event)
 
static void handle_selection_clear (xcb_selection_clear_event_t *event)
 
static bool handle_class_change (Con *con, xcb_get_property_reply_t *prop)
 
static bool handle_machine_change (Con *con, xcb_get_property_reply_t *prop)
 
static bool handle_motif_hints_change (Con *con, xcb_get_property_reply_t *prop)
 
static bool handle_strut_partial_change (Con *con, xcb_get_property_reply_t *prop)
 
static bool handle_i3_floating (Con *con, xcb_get_property_reply_t *prop)
 
static bool handle_windowicon_change (Con *con, xcb_get_property_reply_t *prop)
 
void property_handlers_init (void)
 Sets the appropriate atoms for the property handlers after the atoms were received from X11.
 
static void property_notify (uint8_t state, xcb_window_t window, xcb_atom_t atom)
 
void handle_event (int type, xcb_generic_event_t *event)
 Takes an xcb_generic_event_t and calls the appropriate handler, based on the event type.
 

Variables

int randr_base = -1
 
int xkb_base = -1
 
int xkb_current_group
 
int shape_base = -1
 
static struct property_handler_t property_handlers []
 

Macro Definition Documentation

◆ _NET_MOVERESIZE_WINDOW_HEIGHT

#define _NET_MOVERESIZE_WINDOW_HEIGHT   (1 << 11)

Definition at line 674 of file handlers.c.

Referenced by handle_client_message().

◆ _NET_MOVERESIZE_WINDOW_WIDTH

#define _NET_MOVERESIZE_WINDOW_WIDTH   (1 << 10)

Definition at line 673 of file handlers.c.

Referenced by handle_client_message().

◆ _NET_MOVERESIZE_WINDOW_X

#define _NET_MOVERESIZE_WINDOW_X   (1 << 8)

Definition at line 671 of file handlers.c.

Referenced by handle_client_message().

◆ _NET_MOVERESIZE_WINDOW_Y

#define _NET_MOVERESIZE_WINDOW_Y   (1 << 9)

Definition at line 672 of file handlers.c.

Referenced by handle_client_message().

◆ _NET_WM_MOVERESIZE_CANCEL

#define _NET_WM_MOVERESIZE_CANCEL   11 /* cancel operation */

Definition at line 669 of file handlers.c.

◆ _NET_WM_MOVERESIZE_MOVE

#define _NET_WM_MOVERESIZE_MOVE   8 /* movement only */

Definition at line 666 of file handlers.c.

Referenced by handle_client_message().

◆ _NET_WM_MOVERESIZE_MOVE_KEYBOARD

#define _NET_WM_MOVERESIZE_MOVE_KEYBOARD   10 /* move via keyboard */

Definition at line 668 of file handlers.c.

◆ _NET_WM_MOVERESIZE_SIZE_BOTTOM

#define _NET_WM_MOVERESIZE_SIZE_BOTTOM   5

Definition at line 663 of file handlers.c.

◆ _NET_WM_MOVERESIZE_SIZE_BOTTOMLEFT

#define _NET_WM_MOVERESIZE_SIZE_BOTTOMLEFT   6

Definition at line 664 of file handlers.c.

◆ _NET_WM_MOVERESIZE_SIZE_BOTTOMRIGHT

#define _NET_WM_MOVERESIZE_SIZE_BOTTOMRIGHT   4

Definition at line 662 of file handlers.c.

◆ _NET_WM_MOVERESIZE_SIZE_KEYBOARD

#define _NET_WM_MOVERESIZE_SIZE_KEYBOARD   9 /* size via keyboard */

Definition at line 667 of file handlers.c.

◆ _NET_WM_MOVERESIZE_SIZE_LEFT

#define _NET_WM_MOVERESIZE_SIZE_LEFT   7

Definition at line 665 of file handlers.c.

Referenced by handle_client_message().

◆ _NET_WM_MOVERESIZE_SIZE_RIGHT

#define _NET_WM_MOVERESIZE_SIZE_RIGHT   3

Definition at line 661 of file handlers.c.

◆ _NET_WM_MOVERESIZE_SIZE_TOP

#define _NET_WM_MOVERESIZE_SIZE_TOP   1

Definition at line 659 of file handlers.c.

◆ _NET_WM_MOVERESIZE_SIZE_TOPLEFT

#define _NET_WM_MOVERESIZE_SIZE_TOPLEFT   0

Definition at line 658 of file handlers.c.

Referenced by handle_client_message().

◆ _NET_WM_MOVERESIZE_SIZE_TOPRIGHT

#define _NET_WM_MOVERESIZE_SIZE_TOPRIGHT   2

Definition at line 660 of file handlers.c.

◆ COPY_MASK_MEMBER

#define COPY_MASK_MEMBER ( mask_member,
event_member )
Value:
do { \
if (event->value_mask & mask_member) { \
mask |= mask_member; \
values[c++] = event->event_member; \
} \
} while (0)

Referenced by handle_configure_request().

◆ NUM_HANDLERS

#define NUM_HANDLERS   (sizeof(property_handlers) / sizeof(struct property_handler_t))

Definition at line 1359 of file handlers.c.

Referenced by property_notify().

◆ SN_API_NOT_YET_FROZEN

#define SN_API_NOT_YET_FROZEN   1

Definition at line 17 of file handlers.c.

Typedef Documentation

◆ cb_property_handler_t

typedef bool(* cb_property_handler_t) (Con *con, xcb_get_property_reply_t *property)

Definition at line 1336 of file handlers.c.

Function Documentation

◆ check_crossing_screen_boundary()

static void check_crossing_screen_boundary ( uint32_t x,
uint32_t y )
static

◆ event_is_ignored()

bool event_is_ignored ( const int sequence,
const int response_type )

Checks if the given sequence is ignored and returns true if so.

Definition at line 52 of file handlers.c.

References Ignore_Event::added, Ignore_Event::response_type, Ignore_Event::sequence, SLIST_END, SLIST_FIRST, SLIST_FOREACH, SLIST_NEXT, and SLIST_REMOVE.

Referenced by handle_enter_notify(), handle_event(), and xcb_prepare_cb().

◆ handle_class_change()

static bool handle_class_change ( Con * con,
xcb_get_property_reply_t * prop )
static

Definition at line 1221 of file handlers.c.

References remanage_window(), Con::window, and window_update_class().

Here is the call graph for this function:

◆ handle_client_message()

◆ handle_clientleader_change()

static bool handle_clientleader_change ( Con * con,
xcb_get_property_reply_t * prop )
static

Definition at line 1052 of file handlers.c.

References Con::window, and window_update_leader().

Here is the call graph for this function:

◆ handle_configure_notify()

static void handle_configure_notify ( xcb_configure_notify_event_t * event)
static

Definition at line 1187 of file handlers.c.

References DLOG, force_xinerama, ipc_send_event(), randr_query_outputs(), and root.

Referenced by handle_event().

Here is the call graph for this function:

◆ handle_configure_request()

◆ handle_destroy_notify_event()

static void handle_destroy_notify_event ( xcb_destroy_notify_event_t * event)
static

Definition at line 556 of file handlers.c.

References DLOG, and handle_unmap_notify_event().

Referenced by handle_event().

Here is the call graph for this function:

◆ handle_enter_notify()

◆ handle_event()

◆ handle_expose_event()

static void handle_expose_event ( xcb_expose_event_t * event)
static

Definition at line 641 of file handlers.c.

References con_by_frame_id(), conn, DLOG, draw_util_copy_surface(), Con::frame, Con::frame_buffer, Rect::height, LOG, Con::rect, and Rect::width.

Referenced by handle_event().

Here is the call graph for this function:

◆ handle_focus_in()

static void handle_focus_in ( xcb_focus_in_event_t * event)
static

Definition at line 1063 of file handlers.c.

References con_activate_unblock(), con_by_window_id(), con_focus(), con_inside_floating(), croot, DLOG, focused, focused_id, Con::name, Con::parent, root, tree_render(), Con::type, Con::window, and x_push_changes().

Referenced by handle_event().

Here is the call graph for this function:

◆ handle_focus_out()

static void handle_focus_out ( xcb_focus_in_event_t * event)
static

Definition at line 1116 of file handlers.c.

References con_by_window_id(), DLOG, Con::name, and root.

Referenced by handle_event().

Here is the call graph for this function:

◆ handle_hints()

static bool handle_hints ( Con * con,
xcb_get_property_reply_t * reply )
static

Definition at line 1026 of file handlers.c.

References con_set_urgency(), remanage_window(), tree_render(), Con::window, and window_update_hints().

Here is the call graph for this function:

◆ handle_i3_floating()

static bool handle_i3_floating ( Con * con,
xcb_get_property_reply_t * prop )
static

Definition at line 1318 of file handlers.c.

References DLOG, and remanage_window().

Here is the call graph for this function:

◆ handle_machine_change()

static bool handle_machine_change ( Con * con,
xcb_get_property_reply_t * prop )
static

Definition at line 1231 of file handlers.c.

References remanage_window(), Con::window, and window_update_machine().

Here is the call graph for this function:

◆ handle_map_request()

static void handle_map_request ( xcb_map_request_event_t * event)
static

Definition at line 283 of file handlers.c.

References add_ignore_event(), conn, DLOG, and manage_window().

Referenced by handle_event().

Here is the call graph for this function:

◆ handle_mapping_notify()

static void handle_mapping_notify ( xcb_mapping_notify_event_t * event)
static

Definition at line 263 of file handlers.c.

References aio_get_mod_mask_for(), conn, DLOG, grab_all_keys(), keysyms, translate_keysyms(), ungrab_all_keys(), XCB_NUM_LOCK, and xcb_numlock_mask.

Referenced by handle_event().

Here is the call graph for this function:

◆ handle_motif_hints_change()

static bool handle_motif_hints_change ( Con * con,
xcb_get_property_reply_t * prop )
static

Definition at line 1241 of file handlers.c.

References Con::border_style, con_set_border_style(), croot, Con::current_border_width, DLOG, Con::window, window_update_motif_hints(), and x_push_changes().

Here is the call graph for this function:

◆ handle_motion_notify()

static void handle_motion_notify ( xcb_motion_notify_event_t * event)
static

◆ handle_net_wm_state_change()

static void handle_net_wm_state_change ( Con * con,
uint32_t change,
uint32_t atom )
static

◆ handle_normal_hints()

static bool handle_normal_hints ( Con * con,
xcb_get_property_reply_t * reply )
static

Definition at line 1007 of file handlers.c.

References con_inside_floating(), floating_check_size(), FREE, tree_render(), Con::window, and window_update_normal_hints().

Here is the call graph for this function:

◆ handle_screen_change()

static void handle_screen_change ( xcb_generic_event_t * e)
static

Definition at line 456 of file handlers.c.

References conn, croot, DLOG, ELOG, Rect::height, ipc_send_event(), randr_query_outputs(), Con::rect, root, scratchpad_fix_resolution(), and Rect::width.

Referenced by handle_event().

Here is the call graph for this function:

◆ handle_selection_clear()

static void handle_selection_clear ( xcb_selection_clear_event_t * event)
static

Definition at line 1206 of file handlers.c.

References DLOG, LOG, and wm_sn.

Referenced by handle_event().

◆ handle_strut_partial_change()

static bool handle_strut_partial_change ( Con * con,
xcb_get_property_reply_t * prop )
static

◆ handle_transient_for()

static bool handle_transient_for ( Con * con,
xcb_get_property_reply_t * prop )
static

Definition at line 1042 of file handlers.c.

References Con::window, and window_update_transient_for().

Here is the call graph for this function:

◆ handle_unmap_notify_event()

static void handle_unmap_notify_event ( xcb_unmap_notify_event_t * event)
static

Definition at line 484 of file handlers.c.

References add_ignore_event(), con_by_frame_id(), con_by_window_id(), conn, DLOG, DONT_KILL_WINDOW, Con::ignore_unmap, LOG, tree_close_internal(), and tree_render().

Referenced by handle_destroy_notify_event(), and handle_event().

Here is the call graph for this function:

◆ handle_window_type()

static bool handle_window_type ( Con * con,
xcb_get_property_reply_t * reply )
static

Definition at line 995 of file handlers.c.

References Con::window, and window_update_type().

Here is the call graph for this function:

◆ handle_windowicon_change()

static bool handle_windowicon_change ( Con * con,
xcb_get_property_reply_t * prop )
static

Definition at line 1326 of file handlers.c.

References croot, Con::window, window_update_icon(), and x_push_changes().

Here is the call graph for this function:

◆ handle_windowname_change()

static bool handle_windowname_change ( Con * con,
xcb_get_property_reply_t * prop )
static

◆ handle_windowname_change_legacy()

static bool handle_windowname_change_legacy ( Con * con,
xcb_get_property_reply_t * prop )
static

◆ handle_windowrole_change()

static bool handle_windowrole_change ( Con * con,
xcb_get_property_reply_t * prop )
static

Definition at line 629 of file handlers.c.

References remanage_window(), Con::window, and window_update_role().

Here is the call graph for this function:

◆ property_handlers_init()

void property_handlers_init ( void )

Sets the appropriate atoms for the property handlers after the atoms were received from X11.

Definition at line 1366 of file handlers.c.

References property_handler_t::atom, conn_screen, property_handlers, sndisplay, and startup_monitor_event().

Referenced by main().

Here is the call graph for this function:

◆ property_notify()

static void property_notify ( uint8_t state,
xcb_window_t window,
xcb_atom_t atom )
static

Definition at line 1385 of file handlers.c.

References property_handler_t::atom, property_handler_t::cb, con_by_window_id(), conn, DLOG, FREE, property_handler_t::long_len, NUM_HANDLERS, property_handlers, state, and Con::window.

Referenced by handle_event().

Here is the call graph for this function:

◆ SLIST_HEAD()

static SLIST_HEAD ( ignore_head ,
Ignore_Event  )
static

Definition at line 28 of file handlers.c.

References Ignore_Event::response_type, Ignore_Event::sequence, SLIST_INSERT_HEAD, and smalloc().

Here is the call graph for this function:

◆ window_name_changed()

static bool window_name_changed ( i3Window * window,
char * old_name )
static

Definition at line 567 of file handlers.c.

References i3string_as_utf8(), and Window::name.

Referenced by handle_windowname_change(), and handle_windowname_change_legacy().

Here is the call graph for this function:

Variable Documentation

◆ property_handlers

struct property_handler_t property_handlers[]
static
Initial value:
= {
{0, UINT_MAX, handle_hints},
{0, UINT_MAX, handle_normal_hints},
{0, UINT_MAX, handle_transient_for},
{0, UINT_MAX, handle_window_type},
{0, UINT_MAX, handle_i3_floating},
{0, 5 * sizeof(uint64_t), handle_motif_hints_change},
{0, UINT_MAX, handle_windowicon_change}}
static bool handle_windowname_change(Con *con, xcb_get_property_reply_t *prop)
Definition handlers.c:584
static bool handle_hints(Con *con, xcb_get_property_reply_t *reply)
Definition handlers.c:1026
static bool handle_motif_hints_change(Con *con, xcb_get_property_reply_t *prop)
Definition handlers.c:1241
static bool handle_class_change(Con *con, xcb_get_property_reply_t *prop)
Definition handlers.c:1221
static bool handle_clientleader_change(Con *con, xcb_get_property_reply_t *prop)
Definition handlers.c:1052
static bool handle_windowicon_change(Con *con, xcb_get_property_reply_t *prop)
Definition handlers.c:1326
static bool handle_strut_partial_change(Con *con, xcb_get_property_reply_t *prop)
Definition handlers.c:1259
static bool handle_windowname_change_legacy(Con *con, xcb_get_property_reply_t *prop)
Definition handlers.c:607
static bool handle_normal_hints(Con *con, xcb_get_property_reply_t *reply)
Definition handlers.c:1007
static bool handle_i3_floating(Con *con, xcb_get_property_reply_t *prop)
Definition handlers.c:1318
static bool handle_window_type(Con *con, xcb_get_property_reply_t *reply)
Definition handlers.c:995
static bool handle_machine_change(Con *con, xcb_get_property_reply_t *prop)
Definition handlers.c:1231
static bool handle_transient_for(Con *con, xcb_get_property_reply_t *prop)
Definition handlers.c:1042
static bool handle_windowrole_change(Con *con, xcb_get_property_reply_t *prop)
Definition handlers.c:629

Definition at line 1344 of file handlers.c.

Referenced by property_handlers_init(), and property_notify().

◆ randr_base

int randr_base = -1

Definition at line 20 of file handlers.c.

Referenced by handle_event(), and main().

◆ shape_base

int shape_base = -1

Definition at line 23 of file handlers.c.

Referenced by handle_event(), and main().

◆ xkb_base

int xkb_base = -1

Definition at line 21 of file handlers.c.

Referenced by handle_event(), and main().

◆ xkb_current_group

int xkb_current_group

Definition at line 22 of file handlers.c.

Referenced by binding_in_current_group(), and handle_event().