2008-01-13 15:44:01 +01:00
|
|
|
/*
|
2009-09-07 17:22:32 +02:00
|
|
|
* globalconf.h - basic globalconf.header
|
2008-01-13 15:44:01 +01:00
|
|
|
*
|
2009-09-07 17:22:32 +02:00
|
|
|
* Copyright © 2007-2009 Julien Danjou <julien@danjou.info>
|
2008-01-13 15:44:01 +01:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2009-09-07 17:22:32 +02:00
|
|
|
#ifndef AWESOME_GLOBALCONF_H
|
|
|
|
#define AWESOME_GLOBALCONF_H
|
2008-01-13 15:44:01 +01:00
|
|
|
|
2009-04-03 16:30:18 +02:00
|
|
|
#define SN_API_NOT_YET_FROZEN
|
|
|
|
#include <libsn/sn.h>
|
|
|
|
|
2012-11-21 21:01:12 +01:00
|
|
|
#include <glib.h>
|
2009-08-17 16:38:56 +02:00
|
|
|
|
2008-09-03 12:07:53 +02:00
|
|
|
#include <xcb/xcb_icccm.h>
|
2009-04-17 16:52:25 +02:00
|
|
|
#include <xcb/xcb_keysyms.h>
|
2013-09-19 16:48:10 +02:00
|
|
|
#include <xcb/xcb_cursor.h>
|
2016-10-30 18:47:52 +01:00
|
|
|
#include <xcb/xcb_xrm.h>
|
2015-05-14 22:57:22 +02:00
|
|
|
#include <X11/Xresource.h>
|
2008-03-21 16:50:17 +01:00
|
|
|
|
Use xcb-errors library if it is available
This library allows to get a human-readable string describing X11
requests, events, and errors. We now use this library to pretty-print
X11 errors if we get any.
To test this code, I added the following two lines to AwesomeWM so that
X11 errors are generated:
xcb_set_input_focus(globalconf.connection, 42, 42, 42);
xcb_randr_set_output_primary(globalconf.connection,
globalconf.screen->root, 42);
Output without xcb-errors:
X error: request=SetInputFocus (major 42, minor 0), error=BadValue (2)
X error: request=(null) (major 140, minor 30), error=(null) (147)
Output with xcb-errors:
X error: request=SetInputFocus (major 42, minor 0), error=Value (2)
X error: request=RandR-SetOutputPrimary (major 140, minor 30), error=RandR-BadOutput (147)
Signed-off-by: Uli Schlachter <psychon@znc.in>
2019-02-17 15:09:21 +01:00
|
|
|
#include "config.h"
|
|
|
|
#ifdef WITH_XCB_ERRORS
|
|
|
|
#include <xcb/xcb_errors.h>
|
|
|
|
#endif
|
|
|
|
|
2009-09-14 20:27:56 +02:00
|
|
|
#include "objects/key.h"
|
2008-06-14 18:12:16 +02:00
|
|
|
#include "common/xembed.h"
|
2011-10-23 15:59:15 +02:00
|
|
|
#include "common/buffer.h"
|
2008-01-13 15:44:01 +01:00
|
|
|
|
2011-10-19 14:55:57 +02:00
|
|
|
#define ROOT_WINDOW_EVENT_MASK \
|
|
|
|
(const uint32_t []) { \
|
|
|
|
XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT | XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY \
|
|
|
|
| XCB_EVENT_MASK_ENTER_WINDOW \
|
|
|
|
| XCB_EVENT_MASK_LEAVE_WINDOW \
|
|
|
|
| XCB_EVENT_MASK_STRUCTURE_NOTIFY \
|
|
|
|
| XCB_EVENT_MASK_BUTTON_PRESS \
|
|
|
|
| XCB_EVENT_MASK_BUTTON_RELEASE \
|
|
|
|
| XCB_EVENT_MASK_FOCUS_CHANGE \
|
2012-04-07 21:52:24 +02:00
|
|
|
| XCB_EVENT_MASK_PROPERTY_CHANGE \
|
2011-10-19 14:55:57 +02:00
|
|
|
}
|
|
|
|
|
2012-10-14 17:14:22 +02:00
|
|
|
typedef struct drawable_t drawable_t;
|
2018-08-06 22:43:01 +02:00
|
|
|
typedef struct a_screen_area screen_area_t;
|
2010-10-06 13:35:14 +02:00
|
|
|
typedef struct drawin_t drawin_t;
|
2009-04-17 16:14:09 +02:00
|
|
|
typedef struct a_screen screen_t;
|
2008-06-03 18:41:54 +02:00
|
|
|
typedef struct button_t button_t;
|
|
|
|
typedef struct client_t client_t;
|
2008-10-21 17:33:16 +02:00
|
|
|
typedef struct tag tag_t;
|
2014-03-07 13:49:24 +01:00
|
|
|
typedef struct xproperty xproperty_t;
|
2016-09-25 07:04:47 +02:00
|
|
|
struct sequence_pair {
|
|
|
|
xcb_void_cookie_t begin;
|
|
|
|
xcb_void_cookie_t end;
|
|
|
|
};
|
|
|
|
typedef struct sequence_pair sequence_pair_t;
|
2008-01-13 15:44:01 +01:00
|
|
|
|
2008-10-24 20:38:29 +02:00
|
|
|
ARRAY_TYPE(button_t *, button)
|
2009-04-17 16:14:09 +02:00
|
|
|
ARRAY_TYPE(tag_t *, tag)
|
2014-03-30 16:37:19 +02:00
|
|
|
ARRAY_TYPE(screen_t *, screen)
|
2008-10-21 17:33:16 +02:00
|
|
|
ARRAY_TYPE(client_t *, client)
|
2010-10-06 13:35:14 +02:00
|
|
|
ARRAY_TYPE(drawin_t *, drawin)
|
2014-03-07 13:49:24 +01:00
|
|
|
ARRAY_TYPE(xproperty_t, xproperty)
|
2016-09-25 07:04:47 +02:00
|
|
|
DO_ARRAY(sequence_pair_t, sequence_pair, DO_NOTHING)
|
2016-10-07 00:46:57 +02:00
|
|
|
DO_ARRAY(xcb_window_t, window, DO_NOTHING)
|
2008-01-13 15:44:01 +01:00
|
|
|
|
|
|
|
/** Main configuration structure */
|
2009-09-07 17:23:54 +02:00
|
|
|
typedef struct
|
2008-01-13 15:44:01 +01:00
|
|
|
{
|
2008-03-21 16:50:17 +01:00
|
|
|
/** Connection ref */
|
|
|
|
xcb_connection_t *connection;
|
2016-10-30 18:47:52 +01:00
|
|
|
/** X Resources DB */
|
|
|
|
xcb_xrm_database_t *xrmdb;
|
2008-03-21 16:50:17 +01:00
|
|
|
/** Default screen number */
|
|
|
|
int default_screen;
|
2013-09-19 16:48:10 +02:00
|
|
|
/** xcb-cursor context */
|
|
|
|
xcb_cursor_context_t *cursor_ctx;
|
Use xcb-errors library if it is available
This library allows to get a human-readable string describing X11
requests, events, and errors. We now use this library to pretty-print
X11 errors if we get any.
To test this code, I added the following two lines to AwesomeWM so that
X11 errors are generated:
xcb_set_input_focus(globalconf.connection, 42, 42, 42);
xcb_randr_set_output_primary(globalconf.connection,
globalconf.screen->root, 42);
Output without xcb-errors:
X error: request=SetInputFocus (major 42, minor 0), error=BadValue (2)
X error: request=(null) (major 140, minor 30), error=(null) (147)
Output with xcb-errors:
X error: request=SetInputFocus (major 42, minor 0), error=Value (2)
X error: request=RandR-SetOutputPrimary (major 140, minor 30), error=RandR-BadOutput (147)
Signed-off-by: Uli Schlachter <psychon@znc.in>
2019-02-17 15:09:21 +01:00
|
|
|
#ifdef WITH_XCB_ERRORS
|
|
|
|
/** xcb-errors context */
|
|
|
|
xcb_errors_context_t *errors_ctx;
|
|
|
|
#endif
|
2008-03-24 00:48:42 +01:00
|
|
|
/** Keys symbol table */
|
|
|
|
xcb_key_symbols_t *keysyms;
|
2008-01-13 15:44:01 +01:00
|
|
|
/** Logical screens */
|
2009-04-17 16:14:09 +02:00
|
|
|
screen_array_t screens;
|
2016-02-27 15:44:25 +01:00
|
|
|
/** The primary screen, access through screen_get_primary() */
|
|
|
|
screen_t *primary_screen;
|
2009-01-05 16:59:20 +01:00
|
|
|
/** Root window key bindings */
|
2009-08-14 16:46:35 +02:00
|
|
|
key_array_t keys;
|
2009-01-05 16:59:20 +01:00
|
|
|
/** Root window mouse bindings */
|
2009-08-14 16:46:35 +02:00
|
|
|
button_array_t buttons;
|
2015-10-10 21:59:12 +02:00
|
|
|
/** Atom for WM_Sn */
|
|
|
|
xcb_atom_t selection_atom;
|
2015-10-10 21:51:04 +02:00
|
|
|
/** Window owning the WM_Sn selection */
|
|
|
|
xcb_window_t selection_owner_window;
|
2016-04-09 15:44:54 +02:00
|
|
|
/** Do we have RandR 1.3 or newer? */
|
|
|
|
bool have_randr_13;
|
2016-04-15 20:29:08 +02:00
|
|
|
/** Do we have RandR 1.5 or newer? */
|
|
|
|
bool have_randr_15;
|
|
|
|
/** Do we have a RandR screen update pending? */
|
2019-02-18 10:42:29 +01:00
|
|
|
bool screen_refresh_pending;
|
2018-08-06 22:43:01 +02:00
|
|
|
/** Should screens be created before rc.lua is loaded? */
|
|
|
|
bool no_auto_screen;
|
|
|
|
/** Should the screen be created automatically? */
|
|
|
|
bool ignore_screens;
|
2008-12-29 17:03:17 +01:00
|
|
|
/** Check for XTest extension */
|
|
|
|
bool have_xtest;
|
2014-01-03 16:51:16 +01:00
|
|
|
/** Check for SHAPE extension */
|
|
|
|
bool have_shape;
|
2017-01-26 10:43:49 +01:00
|
|
|
/** Check for SHAPE extension with input shape support */
|
|
|
|
bool have_input_shape;
|
2016-11-04 17:24:08 +01:00
|
|
|
/** Check for XKB extension */
|
|
|
|
bool have_xkb;
|
2019-02-06 09:21:26 +01:00
|
|
|
/** Check for XFixes extension */
|
|
|
|
bool have_xfixes;
|
2016-04-09 15:44:54 +02:00
|
|
|
uint8_t event_base_shape;
|
|
|
|
uint8_t event_base_xkb;
|
|
|
|
uint8_t event_base_randr;
|
2019-02-06 09:30:16 +01:00
|
|
|
uint8_t event_base_xfixes;
|
2008-06-03 18:41:54 +02:00
|
|
|
/** Clients list */
|
2009-04-09 17:17:10 +02:00
|
|
|
client_array_t clients;
|
2008-06-14 18:12:16 +02:00
|
|
|
/** Embedded windows */
|
2008-12-01 16:43:44 +01:00
|
|
|
xembed_window_array_t embedded;
|
2008-05-25 19:30:54 +02:00
|
|
|
/** Stack client history */
|
2009-04-17 23:26:26 +02:00
|
|
|
client_array_t stack;
|
2014-12-06 11:56:58 +01:00
|
|
|
/** Lua VM state (opaque to avoid mis-use, see globalconf_get_lua_State()) */
|
|
|
|
struct {
|
|
|
|
lua_State *real_L_dont_use_directly;
|
|
|
|
} L;
|
2011-10-23 15:59:15 +02:00
|
|
|
/** All errors messages from loading config files */
|
|
|
|
buffer_t startup_errors;
|
2012-11-21 21:01:12 +01:00
|
|
|
/** main loop that awesome is running on */
|
|
|
|
GMainLoop *loop;
|
2008-06-10 16:50:55 +02:00
|
|
|
/** The key grabber function */
|
2009-07-28 10:29:30 +02:00
|
|
|
int keygrabber;
|
2008-11-13 16:08:34 +01:00
|
|
|
/** The mouse pointer grabber function */
|
2009-07-28 10:29:30 +02:00
|
|
|
int mousegrabber;
|
2015-09-17 16:32:56 +02:00
|
|
|
/** The drawable that currently contains the pointer */
|
|
|
|
drawable_t *drawable_under_mouse;
|
2010-10-10 14:46:56 +02:00
|
|
|
/** Input focus information */
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
/** Focused client */
|
|
|
|
client_t *client;
|
2010-10-10 14:50:35 +02:00
|
|
|
/** Is there a focus change pending? */
|
|
|
|
bool need_update;
|
2015-09-23 20:48:56 +02:00
|
|
|
/** When nothing has the input focus, this window actually is focused */
|
|
|
|
xcb_window_t window_no_focus;
|
2010-10-10 14:46:56 +02:00
|
|
|
} focus;
|
2010-10-06 13:35:14 +02:00
|
|
|
/** Drawins */
|
|
|
|
drawin_array_t drawins;
|
2009-04-03 16:30:18 +02:00
|
|
|
/** The startup notification display struct */
|
|
|
|
SnDisplay *sndisplay;
|
2010-08-12 14:37:39 +02:00
|
|
|
/** Latest timestamp we got from the X server */
|
|
|
|
xcb_timestamp_t timestamp;
|
2010-08-16 13:55:12 +02:00
|
|
|
/** Window that contains the systray */
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
xcb_window_t window;
|
2014-08-20 11:40:50 +02:00
|
|
|
/** Atom for _NET_SYSTEM_TRAY_%d */
|
|
|
|
xcb_atom_t atom;
|
2014-08-20 11:47:47 +02:00
|
|
|
/** Do we own the systray selection? */
|
|
|
|
bool registered;
|
2010-08-16 13:55:12 +02:00
|
|
|
/** Systray window parent */
|
2010-10-06 15:38:44 +02:00
|
|
|
drawin_t *parent;
|
2015-08-12 10:26:27 +02:00
|
|
|
/** Background color */
|
|
|
|
uint32_t background_pixel;
|
2010-08-16 13:55:12 +02:00
|
|
|
} systray;
|
2010-08-16 13:57:31 +02:00
|
|
|
/** The monitor of startup notifications */
|
|
|
|
SnMonitorContext *snmonitor;
|
2012-04-07 21:32:45 +02:00
|
|
|
/** The visual, used to draw */
|
2010-08-16 13:59:51 +02:00
|
|
|
xcb_visualtype_t *visual;
|
2012-04-07 21:32:45 +02:00
|
|
|
/** The screen's default visual */
|
|
|
|
xcb_visualtype_t *default_visual;
|
2010-08-16 14:10:58 +02:00
|
|
|
/** The screen's information */
|
|
|
|
xcb_screen_t *screen;
|
2010-08-17 15:44:44 +02:00
|
|
|
/** A graphic context. */
|
|
|
|
xcb_gcontext_t gc;
|
2010-09-30 12:48:24 +02:00
|
|
|
/** Our default depth */
|
|
|
|
uint8_t default_depth;
|
|
|
|
/** Our default color map */
|
|
|
|
xcb_colormap_t default_cmap;
|
2011-03-27 19:57:06 +02:00
|
|
|
/** Do we have to reban clients? */
|
|
|
|
bool need_lazy_banning;
|
2012-10-20 17:33:32 +02:00
|
|
|
/** Tag list */
|
|
|
|
tag_array_t tags;
|
2014-03-07 13:49:24 +01:00
|
|
|
/** List of registered xproperties */
|
|
|
|
xproperty_array_t xproperties;
|
2015-05-14 12:12:06 +02:00
|
|
|
/* xkb context */
|
|
|
|
struct xkb_context *xkb_ctx;
|
|
|
|
/* xkb state of dead keys on keyboard */
|
|
|
|
struct xkb_state *xkb_state;
|
2019-02-18 13:45:34 +01:00
|
|
|
/* Do we have a pending xkb update call? */
|
|
|
|
bool xkb_update_pending;
|
2017-03-28 10:23:09 +02:00
|
|
|
/* Do we have a pending reload? */
|
|
|
|
bool xkb_reload_keymap;
|
|
|
|
/* Do we have a pending map change? */
|
|
|
|
bool xkb_map_changed;
|
|
|
|
/* Do we have a pending group change? */
|
|
|
|
bool xkb_group_changed;
|
2015-11-30 20:26:26 +01:00
|
|
|
/** The preferred size of client icons for this screen */
|
|
|
|
uint32_t preferred_icon_size;
|
2016-03-27 11:28:02 +02:00
|
|
|
/** Cached wallpaper information */
|
|
|
|
cairo_surface_t *wallpaper;
|
2016-09-25 07:04:47 +02:00
|
|
|
/** List of enter/leave events to ignore */
|
|
|
|
sequence_pair_array_t ignore_enter_leave_events;
|
|
|
|
xcb_void_cookie_t pending_enter_leave_begin;
|
2016-10-07 00:46:57 +02:00
|
|
|
/** List of windows to be destroyed later */
|
|
|
|
window_array_t destroy_later_windows;
|
2016-10-22 10:46:49 +02:00
|
|
|
/** Pending event that still needs to be handled */
|
|
|
|
xcb_generic_event_t *pending_event;
|
2016-10-27 10:40:53 +02:00
|
|
|
/** The exit code that main() will return with */
|
|
|
|
int exit_code;
|
2020-02-03 00:57:26 +01:00
|
|
|
/** The Global API level */
|
|
|
|
int api_level;
|
2009-09-07 17:23:54 +02:00
|
|
|
} awesome_t;
|
2008-01-13 15:44:01 +01:00
|
|
|
|
2009-04-10 13:28:21 +02:00
|
|
|
extern awesome_t globalconf;
|
|
|
|
|
2014-12-06 11:56:58 +01:00
|
|
|
/** You should always use this as lua_State *L = globalconf_get_lua_State().
|
|
|
|
* That way it becomes harder to introduce coroutine-related problems.
|
|
|
|
*/
|
|
|
|
static inline lua_State *globalconf_get_lua_State(void) {
|
|
|
|
return globalconf.L.real_L_dont_use_directly;
|
|
|
|
}
|
|
|
|
|
2016-03-27 11:28:02 +02:00
|
|
|
/* Defined in root.c */
|
|
|
|
void root_update_wallpaper(void);
|
|
|
|
|
2008-01-13 15:44:01 +01:00
|
|
|
#endif
|
2011-09-11 16:50:01 +02:00
|
|
|
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|