awesome/globalconf.h

249 lines
7.8 KiB
C
Raw Permalink Normal View History

2008-01-13 15:44:01 +01:00
/*
* globalconf.h - basic globalconf.header
2008-01-13 15:44:01 +01: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.
*
*/
#ifndef AWESOME_GLOBALCONF_H
#define AWESOME_GLOBALCONF_H
2008-01-13 15:44:01 +01:00
#define SN_API_NOT_YET_FROZEN
#include <libsn/sn.h>
#include <glib.h>
#include <xcb/xcb_icccm.h>
#include <xcb/xcb_keysyms.h>
#include <xcb/xcb_cursor.h>
#include <xcb/xcb_xrm.h>
#include <X11/Xresource.h>
2008-03-21 16:50:17 +01:00
#include "config.h"
#ifdef WITH_XCB_ERRORS
#include <xcb/xcb_errors.h>
#endif
#include "objects/key.h"
#include "common/xembed.h"
#include "common/buffer.h"
2008-01-13 15:44:01 +01: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 \
| XCB_EVENT_MASK_PROPERTY_CHANGE \
}
typedef struct drawable_t drawable_t;
init: Add a command line option to start AwesomeWM without screens. This commit add an optional `--screen off` command to initialize Lua without first adding the screens. This is inconvinient for most users since it restrict the APIs that are usable out of the box. However, this allows AwesomeWM to work independently from the hardware. This means that when a screen is unplugged, it is the Lua code that will remove the screen instead of CAPI pulling the carpet from under. It also allows to ignore some screen areas before the screen is ever created. Combined, it makes it possible to work with screens even when they are physically disconnected. Finally, it will allow for an awful.rules like API to control how screens are created. All in all, some people need this for their setup and some people might want to do it anyway for fine grained and/or dynamaic multi-screen setups. This commit also adds 4 new signals to `capi` to be able to execute code at specific points during the initialization. The commit improves naughty error notifications to work even if problems occurs before the screens are added. Note that AwesomeWM will exit if no screens are created. While it would be easy to just call `refresh_screen();` after unsetting the magic variable, doing so would have corner cases. Better be harsher and prevent the user from shooting themselves in the foot from not reading the f****** manual. Code introduced in future commits will take care of automatically calling fake_screen in the event nothing is created. Fixes #1382
2018-08-06 22:43:01 +02:00
typedef struct a_screen_area screen_area_t;
typedef struct drawin_t drawin_t;
typedef struct a_screen screen_t;
typedef struct button_t button_t;
typedef struct client_t client_t;
typedef struct tag tag_t;
typedef struct xproperty xproperty_t;
Speed up client_ignore_enterleave_events() There are some situations where we do things that can make the mouse pointer enter another window. We do not want to react to these "self inflicted" mouse enter and leave events, because they aren't "real" (= generated by the user). Before this commit, this is done by going through all windows and toggling the "please send us enter and leave events"-bit on them. This becomes slower when many windows are visible and floods the server with requests. This commit changes this to a constant-time logic. Each event contains the sequence number of the last request that the X11 server handled. Thus, we just remember the right sequence numbers and ignore any events that comes in whose sequence number falls into the ignored range. In detail, we keep a list of "begin" and "end" sequence numbers and ignore any enter and leave events that fall in this range. If we get any event with a sequence number higher than "end", we remove this pair from the list, since it is no longer needed. To generate these pairs, we use a GrabServer request in client_ignore_enterleave_events(). This gives us a sequence number and makes sure that nothing else besides us can cause events. The server is ours! In client_restore_enterleave_events(), we first do a NoOperation request to generate the sequence number for the end of the pair and then do UngrabServer. Any event that is generated after UngrabServer will have at least the sequence number of the UngrabServer request and thus no longer fails between begin and end. Fixes: https://github.com/awesomeWM/awesome/issues/1107 Signed-off-by: Uli Schlachter <psychon@znc.in>
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
ARRAY_TYPE(button_t *, button)
ARRAY_TYPE(tag_t *, tag)
ARRAY_TYPE(screen_t *, screen)
ARRAY_TYPE(client_t *, client)
ARRAY_TYPE(drawin_t *, drawin)
ARRAY_TYPE(xproperty_t, xproperty)
Speed up client_ignore_enterleave_events() There are some situations where we do things that can make the mouse pointer enter another window. We do not want to react to these "self inflicted" mouse enter and leave events, because they aren't "real" (= generated by the user). Before this commit, this is done by going through all windows and toggling the "please send us enter and leave events"-bit on them. This becomes slower when many windows are visible and floods the server with requests. This commit changes this to a constant-time logic. Each event contains the sequence number of the last request that the X11 server handled. Thus, we just remember the right sequence numbers and ignore any events that comes in whose sequence number falls into the ignored range. In detail, we keep a list of "begin" and "end" sequence numbers and ignore any enter and leave events that fall in this range. If we get any event with a sequence number higher than "end", we remove this pair from the list, since it is no longer needed. To generate these pairs, we use a GrabServer request in client_ignore_enterleave_events(). This gives us a sequence number and makes sure that nothing else besides us can cause events. The server is ours! In client_restore_enterleave_events(), we first do a NoOperation request to generate the sequence number for the end of the pair and then do UngrabServer. Any event that is generated after UngrabServer will have at least the sequence number of the UngrabServer request and thus no longer fails between begin and end. Fixes: https://github.com/awesomeWM/awesome/issues/1107 Signed-off-by: Uli Schlachter <psychon@znc.in>
2016-09-25 07:04:47 +02:00
DO_ARRAY(sequence_pair_t, sequence_pair, DO_NOTHING)
DO_ARRAY(xcb_window_t, window, DO_NOTHING)
2008-01-13 15:44:01 +01:00
/** Main configuration structure */
typedef struct
2008-01-13 15:44:01 +01:00
{
2008-03-21 16:50:17 +01:00
/** Connection ref */
xcb_connection_t *connection;
/** X Resources DB */
xcb_xrm_database_t *xrmdb;
2008-03-21 16:50:17 +01:00
/** Default screen number */
int default_screen;
/** xcb-cursor context */
xcb_cursor_context_t *cursor_ctx;
#ifdef WITH_XCB_ERRORS
/** xcb-errors context */
xcb_errors_context_t *errors_ctx;
#endif
/** Keys symbol table */
xcb_key_symbols_t *keysyms;
2008-01-13 15:44:01 +01:00
/** Logical screens */
screen_array_t screens;
/** The primary screen, access through screen_get_primary() */
screen_t *primary_screen;
/** Root window key bindings */
key_array_t keys;
/** Root window mouse bindings */
button_array_t buttons;
/** Atom for WM_Sn */
xcb_atom_t selection_atom;
/** Window owning the WM_Sn selection */
xcb_window_t selection_owner_window;
/** Do we have RandR 1.3 or newer? */
bool have_randr_13;
/** Do we have RandR 1.5 or newer? */
bool have_randr_15;
/** Do we have a RandR screen update pending? */
bool screen_refresh_pending;
init: Add a command line option to start AwesomeWM without screens. This commit add an optional `--screen off` command to initialize Lua without first adding the screens. This is inconvinient for most users since it restrict the APIs that are usable out of the box. However, this allows AwesomeWM to work independently from the hardware. This means that when a screen is unplugged, it is the Lua code that will remove the screen instead of CAPI pulling the carpet from under. It also allows to ignore some screen areas before the screen is ever created. Combined, it makes it possible to work with screens even when they are physically disconnected. Finally, it will allow for an awful.rules like API to control how screens are created. All in all, some people need this for their setup and some people might want to do it anyway for fine grained and/or dynamaic multi-screen setups. This commit also adds 4 new signals to `capi` to be able to execute code at specific points during the initialization. The commit improves naughty error notifications to work even if problems occurs before the screens are added. Note that AwesomeWM will exit if no screens are created. While it would be easy to just call `refresh_screen();` after unsetting the magic variable, doing so would have corner cases. Better be harsher and prevent the user from shooting themselves in the foot from not reading the f****** manual. Code introduced in future commits will take care of automatically calling fake_screen in the event nothing is created. Fixes #1382
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;
/** Check for XTest extension */
bool have_xtest;
/** Check for SHAPE extension */
bool have_shape;
/** Check for SHAPE extension with input shape support */
bool have_input_shape;
/** Check for XKB extension */
bool have_xkb;
/** Check for XFixes extension */
bool have_xfixes;
/** Custom searchpaths are present, the runtime is tinted */
bool have_searchpaths;
/** When --no-argb is used in the modeline or command line */
bool had_overriden_depth;
uint8_t event_base_shape;
uint8_t event_base_xkb;
uint8_t event_base_randr;
uint8_t event_base_xfixes;
/** Clients list */
client_array_t clients;
/** Embedded windows */
xembed_window_array_t embedded;
/** Stack client history */
client_array_t stack;
/** Lua VM state (opaque to avoid mis-use, see globalconf_get_lua_State()) */
struct {
lua_State *real_L_dont_use_directly;
} L;
/** All errors messages from loading config files */
buffer_t startup_errors;
/** main loop that awesome is running on */
GMainLoop *loop;
/** The key grabber function */
int keygrabber;
/** The mouse pointer grabber function */
int mousegrabber;
/** The drawable that currently contains the pointer */
drawable_t *drawable_under_mouse;
/** Input focus information */
struct
{
/** Focused client */
client_t *client;
/** Is there a focus change pending? */
bool need_update;
/** When nothing has the input focus, this window actually is focused */
xcb_window_t window_no_focus;
} focus;
/** Drawins */
drawin_array_t drawins;
/** The startup notification display struct */
SnDisplay *sndisplay;
/** Latest timestamp we got from the X server */
xcb_timestamp_t timestamp;
/** Window that contains the systray */
struct
{
xcb_window_t window;
/** Atom for _NET_SYSTEM_TRAY_%d */
xcb_atom_t atom;
/** Do we own the systray selection? */
bool registered;
/** Systray window parent */
drawin_t *parent;
/** Background color */
uint32_t background_pixel;
} systray;
/** The monitor of startup notifications */
SnMonitorContext *snmonitor;
/** The visual, used to draw */
xcb_visualtype_t *visual;
/** The screen's default visual */
xcb_visualtype_t *default_visual;
/** The screen's information */
xcb_screen_t *screen;
/** A graphic context. */
xcb_gcontext_t gc;
/** Our default depth */
uint8_t default_depth;
/** Our default color map */
xcb_colormap_t default_cmap;
/** Do we have to reban clients? */
bool need_lazy_banning;
/** Tag list */
tag_array_t tags;
/** List of registered xproperties */
xproperty_array_t xproperties;
/* xkb context */
struct xkb_context *xkb_ctx;
/* xkb state of dead keys on keyboard */
struct xkb_state *xkb_state;
/* Do we have a pending xkb update call? */
bool xkb_update_pending;
/* 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;
/** The preferred size of client icons for this screen */
uint32_t preferred_icon_size;
/** Cached wallpaper information */
cairo_surface_t *wallpaper;
Speed up client_ignore_enterleave_events() There are some situations where we do things that can make the mouse pointer enter another window. We do not want to react to these "self inflicted" mouse enter and leave events, because they aren't "real" (= generated by the user). Before this commit, this is done by going through all windows and toggling the "please send us enter and leave events"-bit on them. This becomes slower when many windows are visible and floods the server with requests. This commit changes this to a constant-time logic. Each event contains the sequence number of the last request that the X11 server handled. Thus, we just remember the right sequence numbers and ignore any events that comes in whose sequence number falls into the ignored range. In detail, we keep a list of "begin" and "end" sequence numbers and ignore any enter and leave events that fall in this range. If we get any event with a sequence number higher than "end", we remove this pair from the list, since it is no longer needed. To generate these pairs, we use a GrabServer request in client_ignore_enterleave_events(). This gives us a sequence number and makes sure that nothing else besides us can cause events. The server is ours! In client_restore_enterleave_events(), we first do a NoOperation request to generate the sequence number for the end of the pair and then do UngrabServer. Any event that is generated after UngrabServer will have at least the sequence number of the UngrabServer request and thus no longer fails between begin and end. Fixes: https://github.com/awesomeWM/awesome/issues/1107 Signed-off-by: Uli Schlachter <psychon@znc.in>
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;
/** List of windows to be destroyed later */
window_array_t destroy_later_windows;
/** Pending event that still needs to be handled */
xcb_generic_event_t *pending_event;
/** The exit code that main() will return with */
int exit_code;
/** The Global API level */
int api_level;
} awesome_t;
2008-01-13 15:44:01 +01:00
extern awesome_t globalconf;
/** 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;
}
/* Defined in root.c */
void root_update_wallpaper(void);
2008-01-13 15:44:01 +01:00
#endif
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80