Merge branch 'next'

This commit is contained in:
Michael Stapelberg
2010-03-30 13:06:41 +02:00
88 changed files with 7702 additions and 2593 deletions

View File

@ -3,7 +3,7 @@
*
* i3 - an improved dynamic tiling window manager
*
* (c) 2009 Michael Stapelberg and contributors
* © 2009 Michael Stapelberg and contributors
*
* See file LICENSE for license information.
*
@ -51,7 +51,13 @@ bool client_matches_class_name(Client *client, char *to_class, char *to_title,
* and when moving a fullscreen client to another screen.
*
*/
void client_enter_fullscreen(xcb_connection_t *conn, Client *client);
void client_enter_fullscreen(xcb_connection_t *conn, Client *client, bool global);
/**
* Leaves fullscreen mode for the given client. This is called by toggle_fullscreen.
*
*/
void client_leave_fullscreen(xcb_connection_t *conn, Client *client);
/**
* Leaves fullscreen mode for the current client. This is called by toggle_fullscreen.
@ -68,6 +74,12 @@ void client_leave_fullscreen(xcb_connection_t *conn, Client *client);
*/
void client_toggle_fullscreen(xcb_connection_t *conn, Client *client);
/**
* Like client_toggle_fullscreen(), but putting it in global fullscreen-mode.
*
*/
void client_toggle_fullscreen_global(xcb_connection_t *conn, Client *client);
/**
* Sets the position of the given client in the X stack to the highest (tiling
* layer is always on the same position, so this doesnt matter) below the
@ -118,12 +130,26 @@ void client_map(xcb_connection_t *conn, Client *client);
*/
void client_mark(xcb_connection_t *conn, Client *client, const char *mark);
/**
* Returns the minimum height of a specific window. The height is calculated
* by using 2 pixels (for the client window itself), possibly padding this to
* comply with the clients base_height and then adding the decoration height.
*
*/
uint32_t client_min_height(Client *client);
/**
* See client_min_height.
*
*/
uint32_t client_min_width(Client *client);
/**
* Pretty-prints the clients information into the logfile.
*
*/
#define CLIENT_LOG(client) do { \
LOG("Window: frame 0x%08x, child 0x%08x\n", client->frame, client->child); \
DLOG("Window: frame 0x%08x, child 0x%08x\n", client->frame, client->child); \
} while (0)
#endif

View File

@ -3,12 +3,14 @@
*
* i3 - an improved dynamic tiling window manager
*
* © 2009 Michael Stapelberg and contributors
* © 2009-2010 Michael Stapelberg and contributors
*
* See file LICENSE for license information.
*
* include/config.h: Contains all structs/variables for
* the configurable part of i3
* include/config.h: Contains all structs/variables for the configurable
* part of i3 as well as functions handling the configuration file (calling
* the parser (src/cfgparse.y) with the correct path, switching key bindings
* mode).
*
*/
@ -21,9 +23,23 @@
typedef struct Config Config;
extern Config config;
extern bool config_use_lexer;
extern SLIST_HEAD(modes_head, Mode) modes;
/**
* Used during the config file lexing/parsing to keep the state of the lexer
* in order to provide useful error messages in yyerror().
*
*/
struct context {
int line_number;
char *line_copy;
const char *filename;
/* These are the same as in YYLTYPE */
int first_column;
int last_column;
};
/**
* Part of the struct Config. It makes sense to group colors for background,
* border and text as every element in i3 has them (window decorations, bar).
@ -76,6 +92,18 @@ struct Config {
int container_stack_limit;
int container_stack_limit_value;
/** By default, focus follows mouse. If the user explicitly wants to
* turn this off (and instead rely only on the keyboard for changing
* focus), we allow him to do this with this relatively special option.
* It is not planned to add any different focus models. */
bool disable_focus_follows_mouse;
/** By default, a workspace bar is drawn at the bottom of the screen.
* If you want to have a more fancy bar, it is recommended to replace
* the whole bar by dzen2, for example using the i3-wsbar script which
* comes with i3. Thus, you can turn it off entirely. */
bool disable_workspace_bar;
const char *default_border;
/** The modifier which needs to be pressed in combination with your mouse
@ -96,6 +124,18 @@ struct Config {
} bar;
};
/**
* This function resolves ~ in pathnames.
*
*/
char *glob_path(const char *path);
/**
* Checks if the given path exists by calling stat().
*
*/
bool path_exists(const char *path);
/**
* Reads the configuration from ~/.i3/config or /etc/i3/config if not found.
*
@ -105,6 +145,12 @@ struct Config {
*/
void load_configuration(xcb_connection_t *conn, const char *override_configfile, bool reload);
/**
* Translates keysymbols to keycodes for all bindings which use keysyms.
*
*/
void translate_keysyms();
/**
* Ungrabs all keys, to be called before re-grabbing the keys because of a
* mapping_notify event or a configuration file reload
@ -116,7 +162,7 @@ void ungrab_all_keys(xcb_connection_t *conn);
* Grab the bound keys (tell X to send us keypress events for those keycodes)
*
*/
void grab_all_keys(xcb_connection_t *conn);
void grab_all_keys(xcb_connection_t *conn, bool bind_mode_switch);
/**
* Switches the key bindings to the given mode, if the mode exists
@ -124,4 +170,14 @@ void grab_all_keys(xcb_connection_t *conn);
*/
void switch_mode(xcb_connection_t *conn, const char *new_mode);
/**
* Returns a pointer to the Binding with the specified modifiers and keycode
* or NULL if no such binding exists.
*
*/
Binding *get_binding(uint16_t modifiers, xcb_keycode_t keycode);
/* prototype for src/cfgparse.y */
void parse_file(const char *f);
#endif

26
include/container.h Normal file
View File

@ -0,0 +1,26 @@
/*
* vim:ts=8:expandtab
*
* i3 - an improved dynamic tiling window manager
*
* © 2009 Michael Stapelberg and contributors
*
* See file LICENSE for license information.
*
*/
#include "data.h"
#ifndef _CONTAINER_H
#define _CONTAINER_H
/**
* Returns the mode of the given container (or MODE_DEFAULT if a NULL pointer
* was passed in order to save a few explicit checks in other places). If
* for_frame was set to true, the special case of having exactly one client
* in a container is handled so that MODE_DEFAULT is returned. For some parts
* of the rendering, this is interesting, other parts need the real mode.
*
*/
int container_mode(Container *con, bool for_frame);
#endif

View File

@ -3,7 +3,7 @@
*
* i3 - an improved dynamic tiling window manager
*
* © 2009 Michael Stapelberg and contributors
* © 2009-2010 Michael Stapelberg and contributors
*
* See file LICENSE for license information.
*
@ -11,6 +11,7 @@
*
*/
#include <xcb/xcb.h>
#include <xcb/randr.h>
#include <xcb/xcb_atom.h>
#include <stdbool.h>
@ -25,11 +26,12 @@
*
* Lets start from the biggest to the smallest:
*
* - An i3Screen is a virtual screen (Xinerama). This can be a single one,
* though two monitors might be connected, if youre running clone
* mode. There can also be multiple of them.
* - An Output is a physical output on your graphics driver. Outputs which
* are currently in use have (output->active == true). Each output has a
* position and a mode. An output usually corresponds to one connected
* screen (except if you are running multiple screens in clone mode).
*
* - Each i3Screen contains Workspaces. The concept is known from various
* - Each Output contains Workspaces. The concept is known from various
* other window managers. Basically, a workspace is a specific set of
* windows, usually grouped thematically (irc, www, work, …). You can switch
* between these.
@ -54,7 +56,7 @@ typedef struct Client Client;
typedef struct Binding Binding;
typedef struct Workspace Workspace;
typedef struct Rect Rect;
typedef struct Screen i3Screen;
typedef struct xoutput Output;
/******************************************************************************
* Helper types
@ -75,6 +77,14 @@ enum {
/**
* Stores a rectangle, for example the size of a window, the child window etc.
* It needs to be packed so that the compiler will not add any padding bytes.
* (it is used in src/ewmh.c for example)
*
* Note that x and y can contain signed values in some cases (for example when
* used for the coordinates of a window, which can be set outside of the
* visible area, but not when specifying the position of a workspace for the
* _NET_WM_WORKAREA hint). Not declaring x/y as int32_t saves us a lot of
* typecasts.
*
* Note that x and y can contain signed values in some cases (for example when
* used for the coordinates of a window, which can be set outside of the
@ -84,9 +94,11 @@ enum {
*
*/
struct Rect {
uint32_t x, y;
uint32_t width, height;
};
uint32_t x;
uint32_t y;
uint32_t width;
uint32_t height;
} __attribute__((packed));
/**
* Defines a position in the table
@ -171,6 +183,9 @@ struct Workspace {
/** Number of this workspace, starting from 0 */
int num;
/** Name of the workspace (in UTF-8) */
char *utf8_name;
/** Name of the workspace (in UCS-2) */
char *name;
@ -200,12 +215,8 @@ struct Workspace {
/** Are the floating clients on this workspace currently hidden? */
bool floating_hidden;
/** A <screen> specifier on which this workspace would like to be (if
* the screen is available). screen := <number> | <position> */
char *preferred_screen;
/** Temporary flag needed for re-querying xinerama screens */
bool reassigned;
/** The name of the RandR output this screen should be on */
char *preferred_output;
/** True if any client on this workspace has its urgent flag set */
bool urgent;
@ -224,8 +235,8 @@ struct Workspace {
* appended) */
TAILQ_HEAD(floating_clients_head, Client) floating_clients;
/** Backpointer to the screen this workspace is on */
i3Screen *screen;
/** Backpointer to the output this workspace is on */
Output *output;
/** This is a two-dimensional dynamic array of
* Container-pointers. Ive always wanted to be a three-star
@ -492,14 +503,26 @@ struct Container {
};
/**
* This is a virtual screen (Xinerama). This can be a single one, though two
* monitors might be connected, if youre running clone mode. There can also
* be multiple of them.
* An Output is a physical output on your graphics driver. Outputs which
* are currently in use have (output->active == true). Each output has a
* position and a mode. An output usually corresponds to one connected
* screen (except if you are running multiple screens in clone mode).
*
*/
struct Screen {
/** Virtual screen number */
int num;
struct xoutput {
/** Output id, so that we can requery the output directly later */
xcb_randr_output_t id;
/** Name of the output */
char *name;
/** Whether the output is currently active (has a CRTC attached with a
* valid mode) */
bool active;
/** Internal flags, necessary for querying RandR screens (happens in
* two stages) */
bool changed;
bool to_be_disabled;
/** Current workspace selected on this virtual screen */
Workspace *current_workspace;
@ -515,7 +538,7 @@ struct Screen {
* _NET_WM_WINDOW_TYPE_DOCK */
SLIST_HEAD(dock_clients_head, Client) dock_clients;
TAILQ_ENTRY(Screen) screens;
TAILQ_ENTRY(xoutput) outputs;
};
#endif

42
include/ewmh.h Normal file
View File

@ -0,0 +1,42 @@
/*
* vim:ts=8:expandtab
*
* i3 - an improved dynamic tiling window manager
*
* © 2009 Michael Stapelberg and contributors
*
* See file LICENSE for license information.
*
*/
#ifndef _EWMH_C
#define _EWMH_C
/**
* Updates _NET_CURRENT_DESKTOP with the current desktop number.
*
* EWMH: The index of the current desktop. This is always an integer between 0
* and _NET_NUMBER_OF_DESKTOPS - 1.
*
*/
void ewmh_update_current_desktop();
/**
* Updates _NET_ACTIVE_WINDOW with the currently focused window.
*
* EWMH: The window ID of the currently active window or None if no window has
* the focus.
*
*/
void ewmh_update_active_window(xcb_window_t window);
/**
* Updates the workarea for each desktop.
*
* EWMH: Contains a geometry for each desktop. These geometries specify an area
* that is completely contained within the viewport. Work area SHOULD be used by
* desktop applications to place desktop icons appropriately.
*
*/
void ewmh_update_workarea();
#endif

View File

@ -3,7 +3,7 @@
*
* i3 - an improved dynamic tiling window manager
*
* © 2009 Michael Stapelberg and contributors
* © 2009-2010 Michael Stapelberg and contributors
*
* See file LICENSE for license information.
*
@ -12,10 +12,19 @@
#define _FLOATING_H
/** Callback for dragging */
typedef void(*callback_t)(Rect*, uint32_t, uint32_t);
typedef void(*callback_t)(xcb_connection_t*, Client*, Rect*, uint32_t, uint32_t, void*);
/** Macro to create a callback function for dragging */
#define DRAGGING_CB(name) \
static void name(xcb_connection_t *conn, Client *client, \
Rect *old_rect, uint32_t new_x, uint32_t new_y, \
void *extra)
/** On which border was the dragging initiated? */
typedef enum { BORDER_LEFT, BORDER_RIGHT, BORDER_TOP, BORDER_BOTTOM} border_t;
typedef enum { BORDER_LEFT = (1 << 0),
BORDER_RIGHT = (1 << 1),
BORDER_TOP = (1 << 2),
BORDER_BOTTOM = (1 << 3)} border_t;
/**
* Enters floating mode for the given client. Correctly takes care of the
@ -56,13 +65,13 @@ void floating_drag_window(xcb_connection_t *conn, Client *client,
xcb_button_press_event_t *event);
/**
* Called when the user right-clicked on the titlebar of a floating window to
* resize it.
* Called when the user clicked on a floating window while holding the
* floating_modifier and the right mouse button.
* Calls the drag_pointer function with the resize_window callback
*
*/
void floating_resize_window(xcb_connection_t *conn, Client *client,
xcb_button_press_event_t *event);
bool proportional, xcb_button_press_event_t *event);
/**
* Changes focus in the given direction for floating clients.
@ -97,6 +106,7 @@ void floating_toggle_hide(xcb_connection_t *conn, Workspace *workspace);
*
*/
void drag_pointer(xcb_connection_t *conn, Client *client, 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);
#endif

View File

@ -3,7 +3,7 @@
*
* i3 - an improved dynamic tiling window manager
*
* (c) 2009 Michael Stapelberg and contributors
* © 2009-2010 Michael Stapelberg and contributors
*
* See file LICENSE for license information.
*
@ -11,13 +11,7 @@
#ifndef _HANDLERS_H
#define _HANDLERS_H
/**
* Due to bindings like Mode_switch + <a>, we need to bind some keys in
* XCB_GRAB_MODE_SYNC. Therefore, we just replay all key presses.
*
*/
int handle_key_release(void *ignored, xcb_connection_t *conn,
xcb_key_release_event_t *event);
#include <xcb/randr.h>
/**
* There was a key press. We compare this key code with our bindings table and
@ -74,6 +68,14 @@ int handle_map_request(void *prophs, xcb_connection_t *conn,
*/
int handle_configure_event(void *prophs, xcb_connection_t *conn, xcb_configure_notify_event_t *event);
/**
* Gets triggered upon a RandR screen change event, that is when the user
* changes the screen configuration in any way (mode, position, …)
*
*/
int handle_screen_change(void *prophs, xcb_connection_t *conn,
xcb_generic_event_t *e);
/**
* Configure requests are received when the application wants to resize
* windows on their own.
@ -92,6 +94,18 @@ int handle_configure_request(void *prophs, xcb_connection_t *conn,
*/
int handle_unmap_notify_event(void *data, xcb_connection_t *conn, xcb_unmap_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).
*
*/
int handle_destroy_notify_event(void *data, xcb_connection_t *conn,
xcb_destroy_notify_event_t *event);
/**
* Called when a window changes its title
*

View File

@ -21,19 +21,20 @@
#ifndef _I3_H
#define _I3_H
#define NUM_ATOMS 18
#define NUM_ATOMS 21
extern xcb_connection_t *global_conn;
extern xcb_key_symbols_t *keysyms;
extern char **start_argv;
extern Display *xkbdpy;
extern int xkb_current_group;
extern TAILQ_HEAD(bindings_head, Binding) *bindings;
extern TAILQ_HEAD(autostarts_head, Autostart) autostarts;
extern TAILQ_HEAD(assignments_head, Assignment) assignments;
extern SLIST_HEAD(stack_wins_head, Stack_Window) stack_wins;
extern xcb_event_handlers_t evenths;
extern int num_screens;
extern uint8_t root_depth;
extern bool xkb_supported;
extern xcb_atom_t atoms[NUM_ATOMS];
extern xcb_window_t root;

View File

@ -3,7 +3,7 @@
*
* i3 - an improved dynamic tiling window manager
*
* © 2009 Michael Stapelberg and contributors
* © 2009-2010 Michael Stapelberg and contributors
*
* See file LICENSE for license information.
*
@ -15,10 +15,53 @@
#ifndef _I3_IPC_H
#define _I3_IPC_H
/*
* Messages from clients to i3
*
*/
/** Never change this, only on major IPC breakage (dont do that) */
#define I3_IPC_MAGIC "i3-ipc"
/** The payload of the message will be interpreted as a command */
#define I3_IPC_MESSAGE_TYPE_COMMAND 0
#define I3_IPC_MESSAGE_TYPE_COMMAND 0
/** Requests the current workspaces from i3 */
#define I3_IPC_MESSAGE_TYPE_GET_WORKSPACES 1
/** Subscribe to the specified events */
#define I3_IPC_MESSAGE_TYPE_SUBSCRIBE 2
/** Requests the current outputs from i3 */
#define I3_IPC_MESSAGE_TYPE_GET_OUTPUTS 3
/*
* Messages from i3 to clients
*
*/
/** Command reply type */
#define I3_IPC_REPLY_TYPE_COMMAND 0
/** Workspaces reply type */
#define I3_IPC_REPLY_TYPE_WORKSPACES 1
/** Subscription reply type */
#define I3_IPC_REPLY_TYPE_SUBSCRIBE 2
/** Outputs reply type */
#define I3_IPC_REPLY_TYPE_OUTPUTS 3
/*
* Events from i3 to clients. Events have the first bit set high.
*
*/
#define I3_IPC_EVENT_MASK (1 << 31)
/* The workspace event will be triggered upon changes in the workspace list */
#define I3_IPC_EVENT_WORKSPACE (I3_IPC_EVENT_MASK | 0)
/* The output event will be triggered upon changes in the output list */
#define I3_IPC_EVENT_OUTPUT (I3_IPC_EVENT_MASK | 1)
#endif

View File

@ -3,7 +3,7 @@
*
* i3 - an improved dynamic tiling window manager
*
* © 2009 Michael Stapelberg and contributors
* © 2009-2010 Michael Stapelberg and contributors
*
* See file LICENSE for license information.
*
@ -16,6 +16,34 @@
#include "i3/ipc.h"
typedef struct ipc_client {
int fd;
/* The events which this client wants to receive */
int num_events;
char **events;
TAILQ_ENTRY(ipc_client) clients;
} ipc_client;
/*
* Callback type for the different message types.
*
* message is the raw packet, as received from the UNIX domain socket. size
* is the remaining size of bytes for this packet.
*
* message_size is the size of the message as the sender specified it.
* message_type is the type of the message as the sender specified it.
*
*/
typedef void(*handler_t)(int, uint8_t*, int, uint32_t, uint32_t);
/* Macro to declare a callback */
#define IPC_HANDLER(name) \
static void handle_ ## name (int fd, uint8_t *message, \
int size, uint32_t message_size, \
uint32_t message_type)
/**
* Handler for activity on the listening socket, meaning that a new client
* has just connected and we should accept() him. Sets up the event handler
@ -32,4 +60,18 @@ void ipc_new_client(EV_P_ struct ev_io *w, int revents);
*/
int ipc_create_socket(const char *filename);
/**
* Sends the specified event to all IPC clients which are currently connected
* and subscribed to this kind of event.
*
*/
void ipc_send_event(const char *event, uint32_t message_type, const char *payload);
/**
* Calls shutdown() on each socket and closes it. This function to be called
* when exiting or restarting only!
*
*/
void ipc_shutdown();
#endif

View File

@ -79,7 +79,7 @@ void ignore_enter_notify_forall(xcb_connection_t *conn, Workspace *workspace,
* Renders the given workspace on the given screen
*
*/
void render_workspace(xcb_connection_t *conn, i3Screen *screen, Workspace *r_ws);
void render_workspace(xcb_connection_t *conn, Output *output, Workspace *r_ws);
/**
* Renders the whole layout, that is: Go through each screen, each workspace,

66
include/log.h Normal file
View File

@ -0,0 +1,66 @@
/*
* vim:ts=8:expandtab
*
* i3 - an improved dynamic tiling window manager
*
* © 2009-2010 Michael Stapelberg and contributors
*
* See file LICENSE for license information.
*
*/
#ifndef _LOG_H
#define _LOG_H
#include <stdarg.h>
#include <stdbool.h>
/** ##__VA_ARGS__ means: leave out __VA_ARGS__ completely if it is empty, that
is, delete the preceding comma */
#define LOG(fmt, ...) verboselog(fmt, ##__VA_ARGS__)
#define ELOG(fmt, ...) errorlog("ERROR: " fmt, ##__VA_ARGS__)
#define DLOG(fmt, ...) debuglog(LOGLEVEL, "%s:%s:%d - " fmt, __FILE__, __FUNCTION__, __LINE__, ##__VA_ARGS__)
extern char *loglevels[];
/**
* Enables the given loglevel.
*
*/
void add_loglevel(const char *level);
/**
* Set verbosity of i3. If verbose is set to true, informative messages will
* be printed to stdout. If verbose is set to false, only errors will be
* printed.
*
*/
void set_verbosity(bool _verbose);
/**
* Logs the given message to stdout while prefixing the current time to it,
* but only if the corresponding debug loglevel was activated.
*
*/
void debuglog(int lev, char *fmt, ...);
/**
* Logs the given message to stdout while prefixing the current time to it.
*
*/
void errorlog(char *fmt, ...);
/**
* Logs the given message to stdout while prefixing the current time to it,
* but only if verbose mode is activated.
*
*/
void verboselog(char *fmt, ...);
/**
* Logs the given message to stdout while prefixing the current time to it.
* This is to be called by LOG() which includes filename/linenumber
*
*/
void slog(char *fmt, va_list args);
#endif

View File

@ -23,6 +23,16 @@
void manage_existing_windows(xcb_connection_t *conn, xcb_property_handlers_t
*prophs, xcb_window_t root);
/**
* Restores the geometry of each window by reparenting it to the root window
* at the position of its frame.
*
* This is to be called *only* before exiting/restarting i3 because of evil
* side-effects which are to be expected when continuing to run i3.
*
*/
void restore_geometry(xcb_connection_t *conn);
/**
* Do some sanity checks and then reparent the window.
*

75
include/randr.h Normal file
View File

@ -0,0 +1,75 @@
/*
* vim:ts=8:expandtab
*
* i3 - an improved dynamic tiling window manager
*
* © 2009-2010 Michael Stapelberg and contributors
*
* See file LICENSE for license information.
*
*/
#include "data.h"
#include <xcb/randr.h>
#ifndef _RANDR_H
#define _RANDR_H
TAILQ_HEAD(outputs_head, xoutput);
extern struct outputs_head outputs;
/**
* We have just established a connection to the X server and need the initial
* XRandR information to setup workspaces for each screen.
*
*/
void initialize_randr(xcb_connection_t *conn, int *event_base);
/**
* Disables RandR support by creating exactly one output with the size of the
* X11 screen.
*
*/
void disable_randr(xcb_connection_t *conn);
/**
* Initializes the specified output, assigning the specified workspace to it.
*
*/
void initialize_output(xcb_connection_t *conn, Output *output, Workspace *workspace);
/**
* (Re-)queries the outputs via RandR and stores them in the list of outputs.
*
*/
void randr_query_outputs(xcb_connection_t *conn);
/**
* Returns the first output which is active.
*
*/
Output *get_first_output();
/**
* Returns the output with the given name if it is active (!) or NULL.
*
*/
Output *get_output_by_name(const char *name);
/**
* Returns the active (!) output which contains the coordinates x, y or NULL
* if there is no output which contains these coordinates.
*
*/
Output *get_output_containing(int x, int y);
/**
* Gets the output which is the last one in the given direction, for example
* the output on the most bottom when direction == D_DOWN, the output most
* right when direction == D_RIGHT and so on.
*
* This function always returns a output.
*
*/
Output *get_output_most(direction_t direction, Output *current);
#endif

21
include/sighandler.h Normal file
View File

@ -0,0 +1,21 @@
/*
* vim:ts=8:expandtab
*
* i3 - an improved dynamic tiling window manager
*
* © 2009-2010 Michael Stapelberg and contributors
* © 2009-2010 Jan-Erik Rediger
*
* See file LICENSE for license information.
*
*/
#ifndef _SIGHANDLER_H
#define _SIGHANDLER_H
/**
* Setup signal handlers to safely handle SIGSEGV and SIGFPE
*
*/
void setup_signal_handler();
#endif

View File

@ -3,7 +3,7 @@
*
* i3 - an improved dynamic tiling window manager
*
* (c) 2009 Michael Stapelberg and contributors
* © 2009 Michael Stapelberg and contributors
*
* See file LICENSE for license information.
*
@ -34,10 +34,6 @@
} \
while (0)
/** ##__VA_ARGS__ means: leave out __VA_ARGS__ completely if it is empty, that
is, delete the preceding comma */
#define LOG(fmt, ...) slog("%s:%s:%d - " fmt, __FILE__, __FUNCTION__, __LINE__, ##__VA_ARGS__)
TAILQ_HEAD(keyvalue_table_head, keyvalue_element);
extern struct keyvalue_table_head by_parent;
extern struct keyvalue_table_head by_child;
@ -46,11 +42,11 @@ int min(int a, int b);
int max(int a, int b);
/**
* Logs the given message to stdout while prefixing the current time to it.
* This is to be called by LOG() which includes filename/linenumber
* Updates *destination with new_value and returns true if it was changed or false
* if it was the same
*
*/
void slog(char *fmt, ...);
bool update_if_necessary(uint32_t *destination, const uint32_t new_value);
/**
* Safe-wrapper around malloc which exits if malloc returns NULL (meaning that
@ -161,6 +157,13 @@ void switch_layout_mode(xcb_connection_t *conn, Container *container, int mode);
Client *get_matching_client(xcb_connection_t *conn,
const char *window_classtitle, Client *specific);
/*
* Restart i3 in-place
* appends -a to argument list to disable autostart
*
*/
void i3_restart();
#if defined(__OpenBSD__)
/* OpenBSD does not provide memmem(), so we provide FreeBSDs implementation */
void *memmem(const void *l, size_t l_len, const void *s, size_t s_len);

View File

@ -3,7 +3,7 @@
*
* i3 - an improved dynamic tiling window manager
*
* © 2009 Michael Stapelberg and contributors
* © 2009-2010 Michael Stapelberg and contributors
*
* See file LICENSE for license information.
*
@ -11,7 +11,7 @@
#include <xcb/xcb.h>
#include "data.h"
#include "xinerama.h"
#include "randr.h"
#ifndef _WORKSPACE_H
#define _WORKSPACE_H
@ -44,6 +44,17 @@ bool workspace_is_visible(Workspace *ws);
/** Switches to the given workspace */
void workspace_show(xcb_connection_t *conn, int workspace);
/**
* Assigns the given workspace to the given screen by correctly updating its
* state and reconfiguring all the clients on this workspace.
*
* This is called when initializing a screen and when re-assigning it to a
* different screen which just got available (if you configured it to be on
* screen 1 and you just plugged in screen 1).
*
*/
void workspace_assign_to(Workspace *ws, Output *screen, bool hide_it);
/**
* Initializes the given workspace if it is not already initialized. The given
* screen is to be understood as a fallback, if the workspace itself either
@ -51,14 +62,14 @@ void workspace_show(xcb_connection_t *conn, int workspace);
* the screen is not attached at the moment.
*
*/
void workspace_initialize(Workspace *ws, i3Screen *screen);
void workspace_initialize(Workspace *ws, Output *screen, bool recheck);
/**
* Gets the first unused workspace for the given screen, taking into account
* the preferred_screen setting of every workspace (workspace assignments).
*
*/
Workspace *get_first_workspace_for_screen(struct screens_head *slist, i3Screen *screen);
Workspace *get_first_workspace_for_output(Output *screen);
/**
* Unmaps all clients (and stack windows) of the given workspace.

View File

@ -61,7 +61,10 @@ enum { _NET_SUPPORTED = 0,
WM_DELETE_WINDOW,
UTF8_STRING,
WM_STATE,
WM_CLIENT_LEADER
WM_CLIENT_LEADER,
_NET_CURRENT_DESKTOP,
_NET_ACTIVE_WINDOW,
_NET_WORKAREA
};
extern unsigned int xcb_numlock_mask;
@ -161,4 +164,10 @@ void cached_pixmap_prepare(xcb_connection_t *conn, struct Cached_Pixmap *pixmap)
int predict_text_width(xcb_connection_t *conn, const char *font_pattern, char *text,
int length);
/**
* Configures the given window to have the size/position specified by given rect
*
*/
void xcb_set_window_rect(xcb_connection_t *conn, xcb_window_t window, Rect r);
#endif

View File

@ -3,7 +3,7 @@
*
* i3 - an improved dynamic tiling window manager
*
* (c) 2009 Michael Stapelberg and contributors
* © 2009-2010 Michael Stapelberg and contributors
*
* See file LICENSE for license information.
*
@ -13,16 +13,6 @@
#ifndef _XINERAMA_H
#define _XINERAMA_H
TAILQ_HEAD(screens_head, Screen);
extern struct screens_head *virtual_screens;
/**
* Returns true if both screen objects describe the same screen (checks their
* size and position).
*
*/
bool screens_are_equal(i3Screen *screen1, i3Screen *screen2);
/**
* We have just established a connection to the X server and need the initial
* Xinerama information to setup workspaces for each screen.
@ -30,33 +20,4 @@ bool screens_are_equal(i3Screen *screen1, i3Screen *screen2);
*/
void initialize_xinerama(xcb_connection_t *conn);
/**
* This is called when the rootwindow receives a configure_notify event and
* therefore the number/position of the Xinerama screens could have changed.
*
*/
void xinerama_requery_screens(xcb_connection_t *conn);
/**
* Looks in virtual_screens for the i3Screen whose start coordinates are x, y
*
*/
i3Screen *get_screen_at(int x, int y, struct screens_head *screenlist);
/**
* Looks in virtual_screens for the i3Screen which contains coordinates x, y
*
*/
i3Screen *get_screen_containing(int x, int y);
/**
* Gets the screen which is the last one in the given direction, for example
* the screen on the most bottom when direction == D_DOWN, the screen most
* right when direction == D_RIGHT and so on.
*
* This function always returns a screen.
*
*/
i3Screen *get_screen_most(direction_t direction, i3Screen *current);
#endif