2018-05-12 12:03:00 -04:00
|
|
|
/*
|
2010-01-06 19:45:19 -08:00
|
|
|
*
|
|
|
|
* Conky, a system monitor, based on torsmo
|
|
|
|
*
|
|
|
|
* Please see COPYING for details
|
|
|
|
*
|
2021-02-27 09:14:19 -06:00
|
|
|
* Copyright (c) 2005-2021 Brenden Matthews, Philip Kovacs, et. al.
|
2023-11-09 13:04:32 +01:00
|
|
|
* (see AUTHORS)
|
2010-01-06 19:45:19 -08:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* 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 3 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, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*/
|
2009-07-28 23:44:22 +02:00
|
|
|
|
2022-12-26 01:39:08 +00:00
|
|
|
#pragma once
|
2008-06-14 18:41:12 +00:00
|
|
|
|
2023-11-10 12:31:01 +01:00
|
|
|
#include "setting.hh"
|
|
|
|
|
2008-06-14 18:41:12 +00:00
|
|
|
#include <X11/Xatom.h>
|
2018-12-20 21:20:43 -05:00
|
|
|
#pragma GCC diagnostic push
|
|
|
|
#pragma GCC diagnostic ignored "-Wvariadic-macros"
|
2018-05-12 12:03:00 -04:00
|
|
|
#include <X11/Xlib.h>
|
2018-12-20 21:20:43 -05:00
|
|
|
#pragma GCC diagnostic pop
|
2023-11-10 12:31:01 +01:00
|
|
|
|
2010-01-06 18:38:12 -08:00
|
|
|
#ifdef BUILD_XFT
|
2008-06-14 18:41:12 +00:00
|
|
|
#include <X11/Xft/Xft.h>
|
|
|
|
#endif
|
2010-01-06 18:38:12 -08:00
|
|
|
#ifdef BUILD_XDBE
|
2008-06-14 18:41:12 +00:00
|
|
|
#include <X11/extensions/Xdbe.h>
|
|
|
|
#endif
|
|
|
|
|
2023-11-09 13:04:32 +01:00
|
|
|
#include <cstdint>
|
2010-02-24 20:51:33 +01:00
|
|
|
|
2023-02-24 13:13:48 +00:00
|
|
|
#ifdef BUILD_ARGB
|
|
|
|
/* true if use_argb_visual=true and argb visual was found*/
|
|
|
|
extern bool have_argb_visual;
|
|
|
|
#endif /* BUILD_ARGB */
|
|
|
|
|
2008-06-14 18:41:12 +00:00
|
|
|
#define ATOM(a) XInternAtom(display, #a, False)
|
|
|
|
|
|
|
|
#ifdef OWN_WINDOW
|
2010-02-26 18:48:57 +01:00
|
|
|
enum window_type {
|
2018-05-12 12:03:00 -04:00
|
|
|
TYPE_NORMAL = 0,
|
|
|
|
TYPE_DOCK,
|
|
|
|
TYPE_PANEL,
|
|
|
|
TYPE_DESKTOP,
|
2023-02-17 04:03:14 +01:00
|
|
|
TYPE_OVERRIDE,
|
|
|
|
TYPE_UTILITY
|
2008-06-14 18:41:12 +00:00
|
|
|
};
|
|
|
|
|
2010-03-02 20:30:15 +01:00
|
|
|
enum window_hints {
|
2018-05-12 12:03:00 -04:00
|
|
|
HINT_UNDECORATED = 0,
|
|
|
|
HINT_BELOW,
|
|
|
|
HINT_ABOVE,
|
|
|
|
HINT_STICKY,
|
|
|
|
HINT_SKIP_TASKBAR,
|
|
|
|
HINT_SKIP_PAGER
|
2008-06-14 18:41:12 +00:00
|
|
|
};
|
|
|
|
|
2018-05-12 12:03:00 -04:00
|
|
|
#define SET_HINT(mask, hint) (mask |= (1 << (hint)))
|
|
|
|
#define TEST_HINT(mask, hint) (mask & (1 << (hint)))
|
2008-06-14 18:41:12 +00:00
|
|
|
#endif
|
|
|
|
|
2022-11-28 19:23:23 +00:00
|
|
|
extern Display *display;
|
|
|
|
|
|
|
|
struct conky_x11_window {
|
2018-05-12 12:03:00 -04:00
|
|
|
Window root, window, desktop;
|
|
|
|
Drawable drawable;
|
|
|
|
Visual *visual;
|
|
|
|
Colormap colourmap;
|
|
|
|
GC gc;
|
2009-07-08 02:09:06 -06:00
|
|
|
|
2023-11-09 13:04:32 +01:00
|
|
|
// Mask containing all events captured by conky
|
|
|
|
int64_t event_mask;
|
|
|
|
|
2010-01-06 18:38:12 -08:00
|
|
|
#ifdef BUILD_XDBE
|
2018-05-12 12:03:00 -04:00
|
|
|
XdbeBackBuffer back_buffer;
|
2022-12-24 09:44:03 -05:00
|
|
|
#else /*BUILD_XDBE*/
|
2018-05-12 12:03:00 -04:00
|
|
|
Pixmap back_buffer;
|
2022-11-28 19:23:23 +00:00
|
|
|
#endif /*BUILD_XDBE*/
|
2010-01-06 18:38:12 -08:00
|
|
|
#ifdef BUILD_XFT
|
2018-05-12 12:03:00 -04:00
|
|
|
XftDraw *xftdraw;
|
2022-11-28 19:23:23 +00:00
|
|
|
#endif /*BUILD_XFT*/
|
2023-11-10 07:08:02 +01:00
|
|
|
#ifdef BUILD_MOUSE_EVENTS
|
|
|
|
// Don't feature gate with BUILD_XINPUT; controls fallback.
|
2023-11-09 13:04:32 +01:00
|
|
|
int32_t xi_opcode;
|
2023-11-10 07:08:02 +01:00
|
|
|
#endif /* BUILD_MOUSE_EVENTS */
|
2008-06-14 18:41:12 +00:00
|
|
|
|
2018-05-12 12:03:00 -04:00
|
|
|
int width;
|
|
|
|
int height;
|
2008-06-14 18:41:12 +00:00
|
|
|
#ifdef OWN_WINDOW
|
2018-05-12 12:03:00 -04:00
|
|
|
int x;
|
|
|
|
int y;
|
2008-06-14 18:41:12 +00:00
|
|
|
#endif
|
2009-08-07 01:24:24 -06:00
|
|
|
};
|
2008-06-14 18:41:12 +00:00
|
|
|
|
2022-11-28 19:23:23 +00:00
|
|
|
extern struct conky_x11_window window;
|
2022-12-26 01:39:08 +00:00
|
|
|
extern conky::simple_config_setting<std::string> display_name;
|
2009-08-07 01:24:24 -06:00
|
|
|
|
2009-05-19 21:34:43 -06:00
|
|
|
void destroy_window(void);
|
2008-06-14 18:41:12 +00:00
|
|
|
void create_gc(void);
|
2010-02-27 22:28:33 +01:00
|
|
|
void set_transparent_background(Window win);
|
2018-05-12 19:26:31 -04:00
|
|
|
void get_x11_desktop_info(Display *current_display, Atom atom);
|
2009-06-13 23:36:28 +02:00
|
|
|
void set_struts(int);
|
2022-11-28 19:23:23 +00:00
|
|
|
void x11_init_window(lua::state &l, bool own);
|
2023-08-12 02:23:45 +02:00
|
|
|
void deinit_x11();
|
2018-08-04 22:26:40 +02:00
|
|
|
|
2023-11-09 13:04:32 +01:00
|
|
|
// Fields common to all X11 input events
|
|
|
|
struct InputEventCommon {
|
|
|
|
int type; /* event type */
|
|
|
|
uint64_t serial; /* # of last request processed by server */
|
|
|
|
Bool send_event; /* true if this came from a SendEvent request */
|
|
|
|
Display *display; /* Display the event was read from */
|
|
|
|
Window window; /* "event" window reported relative to */
|
|
|
|
Window root; /* root window that the event occurred on */
|
|
|
|
Window subwindow; /* child window */
|
|
|
|
Time time; /* milliseconds */
|
|
|
|
int32_t x, y; /* pointer x, y coordinates in event window */
|
|
|
|
int32_t x_root, y_root; /* coordinates relative to root */
|
|
|
|
uint32_t state; /* key or button mask */
|
|
|
|
};
|
|
|
|
|
|
|
|
union InputEvent {
|
2023-11-10 12:31:01 +01:00
|
|
|
int type; // event type
|
2023-11-09 13:04:32 +01:00
|
|
|
|
|
|
|
InputEventCommon common;
|
|
|
|
|
|
|
|
// Discrete interfaces
|
2023-11-10 12:31:01 +01:00
|
|
|
XAnyEvent xany; // common event interface
|
|
|
|
XKeyEvent xkey; // KeyPress & KeyRelease events
|
|
|
|
XButtonEvent xbutton; // ButtonPress & ButtonRelease events
|
|
|
|
XMotionEvent xmotion; // MotionNotify event
|
|
|
|
XCrossingEvent xcrossing; // EnterNotify & LeaveNotify events
|
2023-11-09 13:04:32 +01:00
|
|
|
|
|
|
|
// Ensures InputEvent matches memory layout of XEvent.
|
|
|
|
// Accessing base variant is as code smell.
|
|
|
|
XEvent base;
|
|
|
|
};
|
|
|
|
|
2023-11-10 12:31:01 +01:00
|
|
|
// Returns InputEvent pointer to provided XEvent is an input event; nullptr
|
|
|
|
// otherwise.
|
2023-11-09 13:04:32 +01:00
|
|
|
InputEvent *xev_as_input_event(XEvent &ev);
|
|
|
|
void propagate_x11_event(XEvent &ev);
|
|
|
|
|
|
|
|
#ifdef BUILD_MOUSE_EVENTS
|
2023-11-10 12:31:01 +01:00
|
|
|
Window query_x11_window_at_pos(Display *display, int x, int y);
|
2023-11-09 13:04:32 +01:00
|
|
|
#endif /* BUILD_MOUSE_EVENTS */
|
|
|
|
|
2010-01-06 18:38:12 -08:00
|
|
|
#ifdef BUILD_XDBE
|
2009-08-05 15:41:29 -06:00
|
|
|
void xdbe_swap_buffers(void);
|
2012-04-11 11:06:47 -05:00
|
|
|
#else
|
|
|
|
void xpmdb_swap_buffers(void);
|
2010-01-06 18:38:12 -08:00
|
|
|
#endif /* BUILD_XDBE */
|
2009-08-05 15:41:29 -06:00
|
|
|
|
2010-03-10 20:01:26 +01:00
|
|
|
namespace priv {
|
2018-05-12 12:03:00 -04:00
|
|
|
class out_to_x_setting : public conky::simple_config_setting<bool> {
|
|
|
|
typedef conky::simple_config_setting<bool> Base;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual void lua_setter(lua::state &l, bool init);
|
|
|
|
virtual void cleanup(lua::state &l);
|
|
|
|
|
|
|
|
public:
|
|
|
|
out_to_x_setting() : Base("out_to_x", true, false) {}
|
|
|
|
};
|
|
|
|
|
2018-08-08 15:02:05 +02:00
|
|
|
#ifdef BUILD_XDBE
|
2018-05-12 12:03:00 -04:00
|
|
|
class use_xdbe_setting : public conky::simple_config_setting<bool> {
|
|
|
|
typedef conky::simple_config_setting<bool> Base;
|
|
|
|
|
|
|
|
bool set_up(lua::state &l);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual void lua_setter(lua::state &l, bool init);
|
|
|
|
|
|
|
|
public:
|
|
|
|
use_xdbe_setting() : Base("double_buffer", false, false) {}
|
|
|
|
};
|
|
|
|
|
2018-08-08 15:02:05 +02:00
|
|
|
#else
|
2018-05-12 12:03:00 -04:00
|
|
|
class use_xpmdb_setting : public conky::simple_config_setting<bool> {
|
|
|
|
typedef conky::simple_config_setting<bool> Base;
|
|
|
|
|
|
|
|
bool set_up(lua::state &l);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual void lua_setter(lua::state &l, bool init);
|
|
|
|
|
|
|
|
public:
|
|
|
|
use_xpmdb_setting() : Base("double_buffer", false, false) {}
|
|
|
|
};
|
2018-08-08 15:02:05 +02:00
|
|
|
#endif
|
2022-11-28 19:23:23 +00:00
|
|
|
} /* namespace priv */
|
2018-05-12 12:03:00 -04:00
|
|
|
|
|
|
|
extern priv::out_to_x_setting out_to_x;
|
2019-02-24 16:45:48 +02:00
|
|
|
|
2010-04-21 19:33:39 +02:00
|
|
|
#ifdef BUILD_XFT
|
2018-05-12 12:03:00 -04:00
|
|
|
extern conky::simple_config_setting<bool> use_xft;
|
2010-04-21 19:33:39 +02:00
|
|
|
#endif
|
|
|
|
|
2010-04-23 21:54:40 +02:00
|
|
|
#ifdef BUILD_XDBE
|
2018-05-12 12:03:00 -04:00
|
|
|
extern priv::use_xdbe_setting use_xdbe;
|
2012-04-11 11:06:47 -05:00
|
|
|
#else
|
2018-05-12 12:03:00 -04:00
|
|
|
extern priv::use_xpmdb_setting use_xpmdb;
|
2010-04-23 21:54:40 +02:00
|
|
|
#endif
|