src/handlers.c File Reference

#include <stdio.h>
#include <assert.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include <xcb/xcb.h>
#include <xcb/xcb_atom.h>
#include <xcb/xcb_icccm.h>
#include <xcb/randr.h>
#include <X11/XKBlib.h>
#include "i3.h"
#include "debug.h"
#include "table.h"
#include "layout.h"
#include "commands.h"
#include "data.h"
#include "xcb.h"
#include "util.h"
#include "randr.h"
#include "config.h"
#include "queue.h"
#include "resize.h"
#include "client.h"
#include "manage.h"
#include "floating.h"
#include "workspace.h"
#include "log.h"
#include "container.h"
#include "ipc.h"
Include dependency graph for handlers.c:

Go to the source code of this file.

Defines

#define COPY_MASK_MEMBER(mask_member, event_member)

Functions

static SLIST_HEAD (ignore_head, Ignore_Event)
static bool event_is_ignored (const int sequence)
int handle_key_press (void *ignored, xcb_connection_t *conn, xcb_key_press_event_t *event)
 There was a key press.
static void check_crossing_screen_boundary (uint32_t x, uint32_t y)
int handle_enter_notify (void *ignored, xcb_connection_t *conn, xcb_enter_notify_event_t *event)
 When the user moves the mouse pointer onto a window, this callback gets called.
int handle_motion_notify (void *ignored, xcb_connection_t *conn, xcb_motion_notify_event_t *event)
 When the user moves the mouse but does not change the active window (e.g.
int handle_mapping_notify (void *ignored, xcb_connection_t *conn, xcb_mapping_notify_event_t *event)
 Called when the keyboard mapping changes (for example by using Xmodmap), we need to update our key bindings then (re-translate symbols).
int handle_map_request (void *prophs, xcb_connection_t *conn, xcb_map_request_event_t *event)
 A new window appeared on the screen (=was mapped), so let’s manage it.
int handle_configure_request (void *prophs, xcb_connection_t *conn, xcb_configure_request_event_t *event)
 Configure requests are received when the application wants to resize windows on their own.
int handle_configure_event (void *prophs, xcb_connection_t *conn, xcb_configure_notify_event_t *event)
 Configuration notifies are only handled because we need to set up ignore for the following enter notify events.
int handle_screen_change (void *prophs, xcb_connection_t *conn, xcb_generic_event_t *e)
 Gets triggered upon a RandR screen change event, that is when the user changes the screen configuration in any way (mode, position, …).
int handle_unmap_notify_event (void *data, xcb_connection_t *conn, xcb_unmap_notify_event_t *event)
 Our window decorations were unmapped.
int handle_destroy_notify_event (void *data, xcb_connection_t *conn, xcb_destroy_notify_event_t *event)
 A destroy notify event is sent when the window is not unmapped, but immediately destroyed (for example when starting a window and immediately killing the program which started it).
int handle_windowname_change (void *data, xcb_connection_t *conn, uint8_t state, xcb_window_t window, xcb_atom_t atom, xcb_get_property_reply_t *prop)
 Called when a window changes its title.
int handle_windowname_change_legacy (void *data, xcb_connection_t *conn, uint8_t state, xcb_window_t window, xcb_atom_t atom, xcb_get_property_reply_t *prop)
 We handle legacy window names (titles) which are in COMPOUND_TEXT encoding.
int handle_windowclass_change (void *data, xcb_connection_t *conn, uint8_t state, xcb_window_t window, xcb_atom_t atom, xcb_get_property_reply_t *prop)
 Store the window classes for jumping to them later.
int handle_expose_event (void *data, xcb_connection_t *conn, xcb_expose_event_t *event)
 Expose event means we should redraw our windows (= title bar).
int handle_client_message (void *data, xcb_connection_t *conn, xcb_client_message_event_t *event)
 Handle client messages (EWMH).
int handle_window_type (void *data, xcb_connection_t *conn, uint8_t state, xcb_window_t window, xcb_atom_t atom, xcb_get_property_reply_t *property)
 Handles _NET_WM_WINDOW_TYPE changes.
int handle_normal_hints (void *data, xcb_connection_t *conn, uint8_t state, xcb_window_t window, xcb_atom_t name, xcb_get_property_reply_t *reply)
 Handles the size hints set by a window, but currently only the part necessary for displaying clients proportionally inside their frames (mplayer for example).
int handle_hints (void *data, xcb_connection_t *conn, uint8_t state, xcb_window_t window, xcb_atom_t name, xcb_get_property_reply_t *reply)
 Handles the WM_HINTS property for extracting the urgency state of the window.
int handle_transient_for (void *data, xcb_connection_t *conn, uint8_t state, xcb_window_t window, xcb_atom_t name, xcb_get_property_reply_t *reply)
 Handles the transient for hints set by a window, signalizing that this window is a popup window for some other window.
int handle_clientleader_change (void *data, xcb_connection_t *conn, uint8_t state, xcb_window_t window, xcb_atom_t name, xcb_get_property_reply_t *prop)
 Handles changes of the WM_CLIENT_LEADER atom which specifies if this is a toolwindow (or similar) and to which window it belongs (logical parent).

Define Documentation

#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().


Function Documentation

static void check_crossing_screen_boundary ( uint32_t  x,
uint32_t  y 
) [static]
static bool event_is_ignored ( const int  sequence  )  [static]
int handle_client_message ( void *  data,
xcb_connection_t *  conn,
xcb_client_message_event_t *  event 
)

Handle client messages (EWMH).

Definition at line 832 of file handlers.c.

References _NET_WM_STATE, _NET_WM_STATE_ADD, _NET_WM_STATE_FULLSCREEN, _NET_WM_STATE_REMOVE, _NET_WM_STATE_TOGGLE, atoms, by_child, client_toggle_fullscreen(), ELOG, Client::fullscreen, and table_get().

Referenced by main().

Here is the call graph for this function:

int handle_clientleader_change ( void *  data,
xcb_connection_t *  conn,
uint8_t  state,
xcb_window_t  window,
xcb_atom_t  name,
xcb_get_property_reply_t *  prop 
)

Handles changes of the WM_CLIENT_LEADER atom which specifies if this is a toolwindow (or similar) and to which window it belongs (logical parent).

Definition at line 1068 of file handlers.c.

References by_child, DLOG, Client::leader, table_get(), and WM_CLIENT_LEADER.

Referenced by main(), and reparent_window().

Here is the call graph for this function:

int handle_configure_event ( void *  prophs,
xcb_connection_t *  conn,
xcb_configure_notify_event_t *  event 
)

Configuration notifies are only handled because we need to set up ignore for the following enter notify events.

Definition at line 431 of file handlers.c.

Referenced by main().

int handle_configure_request ( void *  prophs,
xcb_connection_t *  conn,
xcb_configure_request_event_t *  event 
)

Configure requests are received when the application wants to resize windows on their own.

We generate a synthethic configure notify event to signalize the client its "new" position.

Definition at line 292 of file handlers.c.

References Client::borderless, by_child, c_ws, Client::child, client_is_floating(), config, Client::container, COPY_MASK_MEMBER, Client::desired_height, DLOG, Client::dock, fake_absolute_configure_notify(), fake_configure_notify(), Config::font, Client::fullscreen, Rect::height, Font::height, load_font(), Container::mode, Workspace::output, Client::rect, Workspace::rect, render_workspace(), reposition_client(), resize_client(), table_get(), Client::titlebar_position, Rect::width, Container::workspace, Client::workspace, Rect::x, Rect::y, and y.

Referenced by main().

Here is the call graph for this function:

int handle_destroy_notify_event ( void *  data,
xcb_connection_t *  conn,
xcb_destroy_notify_event_t *  event 
)

A destroy notify event is sent when the window is not unmapped, but immediately destroyed (for example when starting a window and immediately killing the program which started it).

We just pass on the event to the unmap notify handler (by copying the important fields in the event data structure).

Definition at line 588 of file handlers.c.

References DLOG, and handle_unmap_notify_event().

Referenced by main().

Here is the call graph for this function:

int handle_enter_notify ( void *  ignored,
xcb_connection_t *  conn,
xcb_enter_notify_event_t *  event 
)

When the user moves the mouse pointer onto a window, this callback gets called.

Definition at line 173 of file handlers.c.

References by_child, by_parent, c_ws, check_crossing_screen_boundary(), config, Client::container, Stack_Window::container, Container::currently_focused, Config::disable_focus_follows_mouse, DLOG, event_is_ignored(), Container::mode, Workspace::output, set_focus(), SLIST_FOREACH, stack_wins, table_get(), Stack_Window::window, and Client::workspace.

Referenced by main().

Here is the call graph for this function:

int handle_expose_event ( void *  data,
xcb_connection_t *  conn,
xcb_expose_event_t *  event 
)
int handle_hints ( void *  data,
xcb_connection_t *  conn,
uint8_t  state,
xcb_window_t  window,
xcb_atom_t  name,
xcb_get_property_reply_t *  reply 
)

Handles the WM_HINTS property for extracting the urgency state of the window.

Definition at line 986 of file handlers.c.

References by_child, c_ws, Client::child, CLIENT_LOG, xoutput::current_workspace, DLOG, LOG, Workspace::output, redecorate_window(), render_workspace(), SLIST_FIRST, table_get(), Client::urgent, Client::workspace, workspace_is_visible(), and workspace_update_urgent_flag().

Referenced by main().

Here is the call graph for this function:

int handle_key_press ( void *  ignored,
xcb_connection_t *  conn,
xcb_key_press_event_t *  event 
)

There was a key press.

We compare this key code with our bindings table and pass the bound action to parse_command().

Definition at line 90 of file handlers.c.

References BIND_MODE_SWITCH, Binding::command, DLOG, ELOG, get_binding(), parse_command(), xcb_numlock_mask, and xkb_current_group.

Referenced by main().

Here is the call graph for this function:

int handle_map_request ( void *  prophs,
xcb_connection_t *  conn,
xcb_map_request_event_t *  event 
)

A new window appeared on the screen (=was mapped), so let’s manage it.

Definition at line 274 of file handlers.c.

References DLOG, and manage_window().

Referenced by main().

Here is the call graph for this function:

int handle_mapping_notify ( void *  ignored,
xcb_connection_t *  conn,
xcb_mapping_notify_event_t *  event 
)

Called when the keyboard mapping changes (for example by using Xmodmap), we need to update our key bindings then (re-translate symbols).

Definition at line 253 of file handlers.c.

References DLOG, grab_all_keys(), keysyms, translate_keysyms(), ungrab_all_keys(), and xcb_get_numlock_mask().

Referenced by main().

Here is the call graph for this function:

int handle_motion_notify ( void *  ignored,
xcb_connection_t *  conn,
xcb_motion_notify_event_t *  event 
)

When the user moves the mouse but does not change the active window (e.g.

when having no windows opened but moving mouse on the root screen and crossing virtual screen boundaries), this callback gets called.

Definition at line 237 of file handlers.c.

References check_crossing_screen_boundary().

Referenced by main().

Here is the call graph for this function:

int handle_normal_hints ( void *  data,
xcb_connection_t *  conn,
uint8_t  state,
xcb_window_t  window,
xcb_atom_t  name,
xcb_get_property_reply_t *  reply 
)

Handles the size hints set by a window, but currently only the part necessary for displaying clients proportionally inside their frames (mplayer for example).

See ICCCM 4.1.2.3 for more details

Definition at line 872 of file handlers.c.

References Client::base_height, Client::base_width, by_child, Client::child, CLIENT_LOG, Client::container, DLOG, Client::force_reconfigure, Client::fullscreen, Rect::height, Client::height_increment, Client::proportional_height, Client::proportional_width, Client::rect, render_container(), resize_client(), table_get(), Rect::width, Client::width_increment, Client::workspace, and workspace_is_visible().

Referenced by main().

Here is the call graph for this function:

int handle_screen_change ( void *  prophs,
xcb_connection_t *  conn,
xcb_generic_event_t *  e 
)

Gets triggered upon a RandR screen change event, that is when the user changes the screen configuration in any way (mode, position, …).

Definition at line 444 of file handlers.c.

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

Referenced by main().

Here is the call graph for this function:

int handle_transient_for ( void *  data,
xcb_connection_t *  conn,
uint8_t  state,
xcb_window_t  window,
xcb_atom_t  name,
xcb_get_property_reply_t *  reply 
)

Handles the transient for hints set by a window, signalizing that this window is a popup window for some other window.

See ICCCM 4.1.2.6 for more details

Definition at line 1036 of file handlers.c.

References by_child, DLOG, Client::floating, table_get(), and toggle_floating_mode().

Referenced by main().

Here is the call graph for this function:

int handle_unmap_notify_event ( void *  data,
xcb_connection_t *  conn,
xcb_unmap_notify_event_t *  event 
)
int handle_window_type ( void *  data,
xcb_connection_t *  conn,
uint8_t  state,
xcb_window_t  window,
xcb_atom_t  atom,
xcb_get_property_reply_t *  property 
)

Handles _NET_WM_WINDOW_TYPE changes.

Definition at line 857 of file handlers.c.

References ELOG.

Referenced by main().

int handle_windowclass_change ( void *  data,
xcb_connection_t *  conn,
uint8_t  state,
xcb_window_t  window,
xcb_atom_t  atom,
xcb_get_property_reply_t *  prop 
)

Store the window classes for jumping to them later.

Definition at line 730 of file handlers.c.

References by_child, DLOG, FREE, LOG, table_get(), Client::window_class_class, and Client::window_class_instance.

Referenced by main(), and reparent_window().

Here is the call graph for this function:

int handle_windowname_change ( void *  data,
xcb_connection_t *  conn,
uint8_t  state,
xcb_window_t  window,
xcb_atom_t  atom,
xcb_get_property_reply_t *  prop 
)
int handle_windowname_change_legacy ( void *  data,
xcb_connection_t *  conn,
uint8_t  state,
xcb_window_t  window,
xcb_atom_t  atom,
xcb_get_property_reply_t *  prop 
)

We handle legacy window names (titles) which are in COMPOUND_TEXT encoding.

However, we just pass them along, so when containing non-ASCII characters, those will be rendering incorrectly. In order to correctly render unicode window titles in i3, an application has to set _NET_WM_NAME, which is in UTF-8 encoding.

On every update, a message is put out to the user, so he may improve the situation and update applications which display filenames in their title to correctly use _NET_WM_NAME and therefore support unicode.

Definition at line 667 of file handlers.c.

References by_child, Client::container, decorate_window(), DLOG, Client::dock, Client::frame, LOG, Container::mode, Client::name, Client::name_len, render_container(), table_get(), Client::titlegc, Client::uses_net_wm_name, Client::workspace, and workspace_is_visible().

Referenced by main(), and reparent_window().

Here is the call graph for this function:

static SLIST_HEAD ( ignore_head  ,
Ignore_Event   
) [static]

Definition at line 47 of file handlers.c.

References SLIST_INSERT_HEAD, and smalloc().

Here is the call graph for this function:

Generated by  doxygen 1.6.2-20100208