Provide a notice when build options get disabled
Reformat files and hope it invalidates CI cache :) Signed-off-by: Tin <tin.svagelj@live.com>
This commit is contained in:
parent
484e667450
commit
4936c7492c
|
@ -140,6 +140,7 @@ jobs:
|
|||
-DBUILD_MYSQL=ON \
|
||||
-DBUILD_NVIDIA=ON \
|
||||
-DBUILD_PULSEAUDIO=ON \
|
||||
-DBUILD_CURL=ON \
|
||||
-DBUILD_RSS=ON \
|
||||
-DBUILD_TESTS=ON \
|
||||
-DBUILD_WLAN=ON \
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
cmake_minimum_required(VERSION 3.15)
|
||||
cmake_minimum_required(VERSION 3.17)
|
||||
|
||||
project(conky)
|
||||
|
||||
|
|
|
@ -18,6 +18,9 @@
|
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
include(CMakeDependentOption)
|
||||
include(DependentOption)
|
||||
|
||||
if(NOT CMAKE_BUILD_TYPE)
|
||||
if(MAINTAINER_MODE)
|
||||
set(
|
||||
|
@ -97,33 +100,26 @@ set(DEFAULT_TEXT_BUFFER_SIZE "256"
|
|||
set(MAX_NET_INTERFACES "256" CACHE STRING "Maximum number of network devices")
|
||||
|
||||
# Platform specific options Linux only
|
||||
if(OS_LINUX)
|
||||
option(BUILD_PORT_MONITORS "Build TCP portmon support" true)
|
||||
option(BUILD_IBM "Support for IBM/Lenovo notebooks" true)
|
||||
option(BUILD_HDDTEMP "Support for hddtemp" true)
|
||||
option(BUILD_IPV6 "Enable if you want IPv6 support" true)
|
||||
if(BUILD_X11)
|
||||
cmake_dependent_option(BUILD_PORT_MONITORS "Build TCP portmon support" true
|
||||
"OS_LINUX" false)
|
||||
cmake_dependent_option(BUILD_IBM "Support for IBM/Lenovo notebooks" true
|
||||
"OS_LINUX" false)
|
||||
cmake_dependent_option(BUILD_HDDTEMP "Support for hddtemp" true
|
||||
"OS_LINUX" false)
|
||||
cmake_dependent_option(BUILD_IPV6 "Enable if you want IPv6 support" true
|
||||
"OS_LINUX" false)
|
||||
# nvidia may also work on FreeBSD, not sure
|
||||
option(BUILD_NVIDIA "Enable nvidia support" false)
|
||||
endif(BUILD_X11)
|
||||
else(OS_LINUX)
|
||||
set(BUILD_PORT_MONITORS false)
|
||||
set(BUILD_IBM false)
|
||||
set(BUILD_HDDTEMP false)
|
||||
set(BUILD_NVIDIA false)
|
||||
set(BUILD_IPV6 false)
|
||||
endif(OS_LINUX)
|
||||
cmake_dependent_option(BUILD_NVIDIA "Enable nvidia support" false
|
||||
"OS_LINUX" false)
|
||||
|
||||
# macOS Only
|
||||
if(OS_DARWIN)
|
||||
option(
|
||||
cmake_dependent_option(
|
||||
BUILD_IPGFREQ
|
||||
"Enable cpu freq calculation based on Intel® Power Gadget; otherwise use constant factory value"
|
||||
false)
|
||||
endif(OS_DARWIN)
|
||||
false
|
||||
"OS_DARWIN" false)
|
||||
|
||||
# Optional features etc
|
||||
#
|
||||
|
||||
option(BUILD_WLAN "Enable wireless support" false)
|
||||
|
||||
|
@ -137,55 +133,53 @@ option(BUILD_OLD_CONFIG "Enable support for the old syntax of configurations"
|
|||
option(BUILD_MATH "Enable math support" true)
|
||||
|
||||
option(BUILD_NCURSES "Enable ncurses support" true)
|
||||
if(BUILD_NCURSES)
|
||||
option(
|
||||
LEAKFREE_NCURSES
|
||||
|
||||
dependent_option(LEAKFREE_NCURSES
|
||||
"Enable to hide false ncurses-memleaks in valgrind (works only when ncurses is compiled with --disable-leaks)"
|
||||
false)
|
||||
else(BUILD_NCURSES)
|
||||
set(
|
||||
LEAKFREE_NCURSES false
|
||||
CACHE
|
||||
BOOL
|
||||
"Enable to hide false ncurses-memleaks in valgrind (works only when ncurses is compiled with --disable-leaks)"
|
||||
FORCE)
|
||||
endif(BUILD_NCURSES)
|
||||
false
|
||||
"BUILD_NCURSES" false
|
||||
"LEAKFREE_NCURSES requires ncurses")
|
||||
|
||||
option(BUILD_WAYLAND "Build Wayland support" false)
|
||||
|
||||
option(BUILD_X11 "Build X11 support" true)
|
||||
if(BUILD_X11)
|
||||
option(OWN_WINDOW "Enable own_window support" true)
|
||||
|
||||
# Mac Fix
|
||||
dependent_option(OWN_WINDOW "Enable running conky in a dedicated window" true
|
||||
"BUILD_X11" false
|
||||
"Dedicated window mode only works on X11")
|
||||
|
||||
# On MacOS these cause issues so they're disabled by default
|
||||
if(OS_DARWIN)
|
||||
option(BUILD_XDAMAGE "Build Xdamage support" false)
|
||||
option(BUILD_XFIXES "Build Xfixes support" false)
|
||||
else(OS_DARWIN)
|
||||
option(BUILD_XDAMAGE "Build Xdamage support" true)
|
||||
option(BUILD_XFIXES "Build Xfixes support" true)
|
||||
dependent_option(BUILD_XDAMAGE "Build Xdamage support" false
|
||||
"BUILD_X11" false
|
||||
"Xdamage support requires X11")
|
||||
dependent_option(BUILD_XFIXES "Build Xfixes support" false
|
||||
"BUILD_X11" false
|
||||
"Xfixes support requires X11")
|
||||
else()
|
||||
dependent_option(BUILD_XDAMAGE "Build Xdamage support" true
|
||||
"BUILD_X11" false
|
||||
"Xdamage support requires X11")
|
||||
dependent_option(BUILD_XFIXES "Build Xfixes support" true
|
||||
"BUILD_X11" false
|
||||
"Xfixes support requires X11")
|
||||
endif(OS_DARWIN)
|
||||
|
||||
option(BUILD_XINERAMA "Build Xinerama support" true)
|
||||
option(BUILD_XDBE "Build Xdbe (double-buffer) support" true)
|
||||
option(BUILD_XFT "Build Xft (freetype fonts) support" true)
|
||||
option(BUILD_IMLIB2 "Enable Imlib2 support" true)
|
||||
option(BUILD_XSHAPE "Enable Xshape support" true)
|
||||
|
||||
option(BUILD_LUA_IMLIB2 "Build Imlib2 bindings for Lua" false)
|
||||
else(BUILD_X11)
|
||||
set(OWN_WINDOW false CACHE BOOL "Enable own_window support" FORCE)
|
||||
set(BUILD_XDAMAGE false CACHE BOOL "Build Xdamage support" FORCE)
|
||||
set(BUILD_XFIXES false CACHE BOOL "Build Xfixes support" FORCE)
|
||||
set(BUILD_XINERAMA false CACHE BOOL "Build Xinerama support" FORCE)
|
||||
set(BUILD_XDBE false CACHE BOOL "Build Xdbe (double-buffer) support" FORCE)
|
||||
set(BUILD_XFT false CACHE BOOL "Build Xft (freetype fonts) support" FORCE)
|
||||
set(BUILD_IMLIB2 false CACHE BOOL "Enable Imlib2 support" FORCE)
|
||||
set(BUILD_XSHAPE false CACHE BOOL "Enable Xshape support" FORCE)
|
||||
|
||||
set(BUILD_LUA_IMLIB2 false CACHE BOOL "Build Imlib2 bindings for Lua" FORCE)
|
||||
set(BUILD_NVIDIA false)
|
||||
endif(BUILD_X11)
|
||||
dependent_option(BUILD_XINERAMA "Build Xinerama support" true
|
||||
"BUILD_X11" false
|
||||
"Xinerama support requires X11")
|
||||
dependent_option(BUILD_XDBE "Build Xdbe (double-buffer) support" true
|
||||
"BUILD_X11" false
|
||||
"Xdbe based double-buffering requires X11")
|
||||
dependent_option(BUILD_XFT "Build Xft (freetype fonts) support" true
|
||||
"BUILD_X11" false
|
||||
"Xft (freetype font) support requires X11")
|
||||
dependent_option(BUILD_IMLIB2 "Enable Imlib2 support" true
|
||||
"BUILD_X11" false
|
||||
"Imlib2 support requires X11")
|
||||
dependent_option(BUILD_XSHAPE "Enable Xshape support" true
|
||||
"BUILD_X11" false
|
||||
"Xshape support requires X11")
|
||||
|
||||
# if we build with any GUI support
|
||||
if(BUILD_X11)
|
||||
|
@ -195,25 +189,22 @@ if(BUILD_WAYLAND)
|
|||
set(BUILD_GUI true)
|
||||
endif(BUILD_WAYLAND)
|
||||
|
||||
if(BUILD_GUI)
|
||||
option(BUILD_MOUSE_EVENTS "Enable mouse event support" true)
|
||||
endif(BUILD_GUI)
|
||||
dependent_option(BUILD_MOUSE_EVENTS "Enable mouse event support" true
|
||||
"BUILD_WAYLAND OR OWN_WINDOW" false
|
||||
"Mouse event support requires Wayland or OWN_WINDOW enabled")
|
||||
dependent_option(BUILD_XINPUT "Build Xinput 2 support" true
|
||||
"BUILD_X11;BUILD_MOUSE_EVENTS" false
|
||||
"Xinput 2 support requires X11 and BUILD_MOUSE_EVENTS enabled")
|
||||
|
||||
if(BUILD_GUI AND BUILD_MOUSE_EVENTS)
|
||||
option(BUILD_XINPUT "Build Xinput 2 support" true)
|
||||
else(BUILD_GUI AND BUILD_MOUSE_EVENTS)
|
||||
set(BUILD_XINPUT false CACHE BOOL "Build Xinput 2 support" FORCE)
|
||||
endif(BUILD_GUI AND BUILD_MOUSE_EVENTS)
|
||||
|
||||
if(OWN_WINDOW)
|
||||
option(BUILD_ARGB "Build ARGB (real transparency) support" true)
|
||||
else(OWN_WINDOW)
|
||||
set(BUILD_ARGB false
|
||||
CACHE BOOL "Build ARGB (real transparency) support"
|
||||
FORCE)
|
||||
endif(OWN_WINDOW)
|
||||
dependent_option(BUILD_ARGB "Build ARGB (real transparency) support" true
|
||||
"OWN_WINDOW" false
|
||||
"ARGB support requires OWN_WINDOW enabled")
|
||||
|
||||
# Lua library options
|
||||
option(BUILD_LUA_CAIRO "Build cairo bindings for Lua" false)
|
||||
dependent_option(BUILD_LUA_IMLIB2 "Build Imlib2 bindings for Lua" false
|
||||
"BUILD_X11;BUILD_IMLIB2" false
|
||||
"Imlib2 Lua bindings require X11 and Imlib2")
|
||||
option(BUILD_LUA_RSVG "Build rsvg bindings for Lua" false)
|
||||
|
||||
option(BUILD_AUDACIOUS "Build audacious (music player) support" false)
|
||||
|
@ -228,12 +219,9 @@ option(BUILD_XMMS2 "Enable if you want XMMS2 (music player) support" false)
|
|||
|
||||
option(BUILD_CURL "Enable if you want Curl support" false)
|
||||
|
||||
option(BUILD_RSS "Enable if you want RSS support" false)
|
||||
|
||||
if(BUILD_RSS)
|
||||
# if RSS is enabled, curl is required
|
||||
set(BUILD_CURL true)
|
||||
endif(BUILD_RSS)
|
||||
dependent_option(BUILD_RSS "Enable if you want RSS support" false
|
||||
"BUILD_CURL" false
|
||||
"RSS depends on Curl support")
|
||||
|
||||
option(BUILD_APCUPSD "Enable APCUPSD support" true)
|
||||
|
||||
|
|
|
@ -59,6 +59,8 @@ set(INCLUDE_SEARCH_PATH /usr/include /usr/local/include)
|
|||
# Set system vars
|
||||
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
|
||||
set(OS_LINUX true)
|
||||
else(CMAKE_SYSTEM_NAME MATCHES "Linux")
|
||||
set(OS_LINUX false)
|
||||
endif(CMAKE_SYSTEM_NAME MATCHES "Linux")
|
||||
|
||||
if(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
|
||||
|
@ -68,33 +70,47 @@ if(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
|
|||
if(BUILD_IRC)
|
||||
set(conky_libs ${conky_libs} -lssl -lcrypto)
|
||||
endif(BUILD_IRC)
|
||||
else(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
|
||||
set(OS_FREEBSD false)
|
||||
endif(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
|
||||
|
||||
if(CMAKE_SYSTEM_NAME MATCHES "DragonFly")
|
||||
set(OS_DRAGONFLY true)
|
||||
set(conky_libs ${conky_libs} -ldevstat)
|
||||
else(CMAKE_SYSTEM_NAME MATCHES "DragonFly")
|
||||
set(OS_DRAGONFLY false)
|
||||
endif(CMAKE_SYSTEM_NAME MATCHES "DragonFly")
|
||||
|
||||
if(CMAKE_SYSTEM_NAME MATCHES "OpenBSD")
|
||||
set(OS_OPENBSD true)
|
||||
else(CMAKE_SYSTEM_NAME MATCHES "OpenBSD")
|
||||
set(OS_OPENBSD false)
|
||||
endif(CMAKE_SYSTEM_NAME MATCHES "OpenBSD")
|
||||
|
||||
if(CMAKE_SYSTEM_NAME MATCHES "SunOS")
|
||||
set(OS_SOLARIS true)
|
||||
set(conky_libs ${conky_libs} -lkstat)
|
||||
else(CMAKE_SYSTEM_NAME MATCHES "SunOS")
|
||||
set(OS_SOLARIS false)
|
||||
endif(CMAKE_SYSTEM_NAME MATCHES "SunOS")
|
||||
|
||||
if(CMAKE_SYSTEM_NAME MATCHES "NetBSD")
|
||||
set(OS_NETBSD true)
|
||||
else(CMAKE_SYSTEM_NAME MATCHES "NetBSD")
|
||||
set(OS_NETBSD false)
|
||||
endif(CMAKE_SYSTEM_NAME MATCHES "NetBSD")
|
||||
|
||||
if(CMAKE_SYSTEM_NAME MATCHES "Haiku")
|
||||
set(OS_HAIKU true)
|
||||
set(conky_libs ${conky_libs} -lnetwork -lintl)
|
||||
else(CMAKE_SYSTEM_NAME MATCHES "Haiku")
|
||||
set(OS_HAIKU false)
|
||||
endif(CMAKE_SYSTEM_NAME MATCHES "Haiku")
|
||||
|
||||
if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
|
||||
set(OS_DARWIN true)
|
||||
else(CMAKE_SYSTEM_NAME MATCHES "Darwin")
|
||||
set(OS_DARWIN false)
|
||||
endif(CMAKE_SYSTEM_NAME MATCHES "Darwin")
|
||||
|
||||
if(NOT OS_LINUX
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
||||
# file Copyright.txt or https://cmake.org/licensing for details.
|
||||
|
||||
#[=======================================================================[.rst:
|
||||
DependentOption
|
||||
--------------------
|
||||
Roughly based on CMakeDependentOption:
|
||||
https://github.com/Kitware/CMake/blob/master/Modules/CMakeDependentOption.cmake
|
||||
|
||||
Modified to so it produces warnings instead of hiding an option completely and
|
||||
sets a default value.
|
||||
|
||||
Argument meaning and order are the same, and there's an additional (warn)
|
||||
argument which is the message printed if the end-user enabled a feature which
|
||||
isn't "possible".
|
||||
#]=======================================================================]
|
||||
|
||||
macro(DEPENDENT_OPTION option doc default depends else warn)
|
||||
set(${option}_POSSIBLE 1)
|
||||
foreach(d ${depends})
|
||||
cmake_language(EVAL CODE "
|
||||
if (${d})
|
||||
else()
|
||||
set(${option}_POSSIBLE 0)
|
||||
endif()"
|
||||
)
|
||||
endforeach()
|
||||
option(${option} "${doc}" "${default}")
|
||||
if(NOT ${option}_POSSIBLE)
|
||||
if(NOT ${option} MATCHES ${else})
|
||||
message(NOTICE "${warn}; setting to '${else}'.")
|
||||
endif()
|
||||
set(${option} ${else} CACHE BOOL "${doc}" FORCE)
|
||||
endif()
|
||||
unset(${option}_POSSIBLE)
|
||||
endmacro()
|
|
@ -24,7 +24,7 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <>
|
||||
|
||||
#ifdef BUILD_WAYLAND
|
||||
#include <wayland-client.h>
|
||||
|
@ -62,9 +62,9 @@
|
|||
#include "fonts.h"
|
||||
#endif
|
||||
#ifdef BUILD_MOUSE_EVENTS
|
||||
#include "mouse-events.h"
|
||||
#include <map>
|
||||
#include <array>
|
||||
#include <map>
|
||||
#include "mouse-events.h"
|
||||
#endif
|
||||
|
||||
#pragma GCC diagnostic ignored "-Wunused-parameter"
|
||||
|
@ -443,20 +443,12 @@ static void on_pointer_enter(void *data, wl_pointer *pointer, uint32_t serial,
|
|||
size_t abs_x = w->rectangle.x + x;
|
||||
size_t abs_y = w->rectangle.y + y;
|
||||
|
||||
mouse_crossing_event event {
|
||||
mouse_event_t::AREA_ENTER,
|
||||
x,
|
||||
y,
|
||||
abs_x,
|
||||
abs_y
|
||||
};
|
||||
mouse_crossing_event event{mouse_event_t::AREA_ENTER, x, y, abs_x, abs_y};
|
||||
llua_mouse_hook(event);
|
||||
}
|
||||
|
||||
static void on_pointer_leave(void *data,
|
||||
struct wl_pointer *pointer,
|
||||
uint32_t serial,
|
||||
struct wl_surface *surface) {
|
||||
static void on_pointer_leave(void *data, struct wl_pointer *pointer,
|
||||
uint32_t serial, struct wl_surface *surface) {
|
||||
auto w = reinterpret_cast<struct window *>(data);
|
||||
|
||||
std::array<size_t, 2> last = last_known_positions[pointer];
|
||||
|
@ -465,20 +457,12 @@ static void on_pointer_leave(void *data,
|
|||
size_t abs_x = w->rectangle.x + x;
|
||||
size_t abs_y = w->rectangle.y + y;
|
||||
|
||||
mouse_crossing_event event {
|
||||
mouse_event_t::AREA_LEAVE,
|
||||
x,
|
||||
y,
|
||||
abs_x,
|
||||
abs_y
|
||||
};
|
||||
mouse_crossing_event event{mouse_event_t::AREA_LEAVE, x, y, abs_x, abs_y};
|
||||
llua_mouse_hook(event);
|
||||
}
|
||||
|
||||
static void on_pointer_motion(void *data,
|
||||
struct wl_pointer *pointer,
|
||||
uint32_t _time,
|
||||
wl_fixed_t surface_x,
|
||||
static void on_pointer_motion(void *data, struct wl_pointer *pointer,
|
||||
uint32_t _time, wl_fixed_t surface_x,
|
||||
wl_fixed_t surface_y) {
|
||||
auto w = reinterpret_cast<struct window *>(data);
|
||||
|
||||
|
@ -489,20 +473,12 @@ static void on_pointer_motion(void *data,
|
|||
size_t abs_x = w->rectangle.x + x;
|
||||
size_t abs_y = w->rectangle.y + y;
|
||||
|
||||
mouse_move_event event {
|
||||
x,
|
||||
y,
|
||||
abs_x,
|
||||
abs_y
|
||||
};
|
||||
mouse_move_event event{x, y, abs_x, abs_y};
|
||||
llua_mouse_hook(event);
|
||||
}
|
||||
|
||||
static void on_pointer_button(void *data,
|
||||
struct wl_pointer *pointer,
|
||||
uint32_t serial,
|
||||
uint32_t time,
|
||||
uint32_t button,
|
||||
static void on_pointer_button(void *data, struct wl_pointer *pointer,
|
||||
uint32_t serial, uint32_t time, uint32_t button,
|
||||
uint32_t state) {
|
||||
auto w = reinterpret_cast<struct window *>(data);
|
||||
|
||||
|
@ -513,11 +489,7 @@ static void on_pointer_button(void *data,
|
|||
size_t abs_y = w->rectangle.y + y;
|
||||
|
||||
mouse_button_event event{
|
||||
mouse_event_t::MOUSE_RELEASE,
|
||||
x,
|
||||
y,
|
||||
abs_x,
|
||||
abs_y,
|
||||
mouse_event_t::MOUSE_RELEASE, x, y, abs_x, abs_y,
|
||||
static_cast<mouse_button_t>(button),
|
||||
};
|
||||
|
||||
|
@ -534,11 +506,8 @@ static void on_pointer_button(void *data,
|
|||
llua_mouse_hook(event);
|
||||
}
|
||||
|
||||
void on_pointer_axis(void *data,
|
||||
struct wl_pointer *pointer,
|
||||
uint32_t time,
|
||||
uint32_t axis,
|
||||
wl_fixed_t value) {
|
||||
void on_pointer_axis(void *data, struct wl_pointer *pointer, uint32_t time,
|
||||
uint32_t axis, wl_fixed_t value) {
|
||||
if (value == 0) return;
|
||||
|
||||
auto w = reinterpret_cast<struct window *>(data);
|
||||
|
@ -550,19 +519,17 @@ void on_pointer_axis(void *data,
|
|||
size_t abs_y = w->rectangle.y + y;
|
||||
|
||||
mouse_scroll_event event{
|
||||
x,
|
||||
y,
|
||||
abs_x,
|
||||
abs_y,
|
||||
scroll_direction_t::SCROLL_UP,
|
||||
x, y, abs_x, abs_y, scroll_direction_t::SCROLL_UP,
|
||||
};
|
||||
|
||||
switch (static_cast<wl_pointer_axis>(axis)) {
|
||||
case WL_POINTER_AXIS_VERTICAL_SCROLL:
|
||||
event.direction = value > 0 ? scroll_direction_t::SCROLL_DOWN : scroll_direction_t::SCROLL_UP;
|
||||
event.direction = value > 0 ? scroll_direction_t::SCROLL_DOWN
|
||||
: scroll_direction_t::SCROLL_UP;
|
||||
break;
|
||||
case WL_POINTER_AXIS_HORIZONTAL_SCROLL:
|
||||
event.direction = value > 0 ? scroll_direction_t::SCROLL_RIGHT : scroll_direction_t::SCROLL_LEFT;
|
||||
event.direction = value > 0 ? scroll_direction_t::SCROLL_RIGHT
|
||||
: scroll_direction_t::SCROLL_LEFT;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
|
@ -570,8 +537,10 @@ void on_pointer_axis(void *data,
|
|||
llua_mouse_hook(event);
|
||||
}
|
||||
|
||||
static void seat_capability_listener (void *data, wl_seat *seat, uint32_t capability_int) {
|
||||
wl_seat_capability capabilities = static_cast<wl_seat_capability>(capability_int);
|
||||
static void seat_capability_listener(void *data, wl_seat *seat,
|
||||
uint32_t capability_int) {
|
||||
wl_seat_capability capabilities =
|
||||
static_cast<wl_seat_capability>(capability_int);
|
||||
if (wl_globals.seat == seat) {
|
||||
if ((capabilities & WL_SEAT_CAPABILITY_POINTER) > 0) {
|
||||
wl_globals.pointer = wl_seat_get_pointer(seat);
|
||||
|
@ -587,7 +556,8 @@ static void seat_capability_listener (void *data, wl_seat *seat, uint32_t capabi
|
|||
}
|
||||
}
|
||||
}
|
||||
static void seat_name_listener(void *data, struct wl_seat *wl_seat, const char *name) {}
|
||||
static void seat_name_listener(void *data, struct wl_seat *wl_seat,
|
||||
const char *name) {}
|
||||
#endif /* BUILD_MOUSE_EVENTS */
|
||||
|
||||
bool display_output_wayland::initialize() {
|
||||
|
|
|
@ -382,7 +382,7 @@ bool display_output_x11::main_loop_wait(double t) {
|
|||
|
||||
XNextEvent(display, &ev);
|
||||
|
||||
#if defined(BUILD_MOUSE_EVENTS) && defined(BUILD_XINPUT)
|
||||
#if defined(OWN_WINDOW) && defined(BUILD_MOUSE_EVENTS) && defined(BUILD_XINPUT)
|
||||
// no need to check whether these events have been consumed because
|
||||
// they're global and shouldn't be propagated
|
||||
if (ev.type == GenericEvent && ev.xcookie.extension == window.xi_opcode) {
|
||||
|
|
|
@ -527,9 +527,12 @@ bool llua_mouse_hook(const EventT &ev) {
|
|||
if (ty == LUA_TNIL) {
|
||||
int ty_raw = lua_getglobal(lua_L, raw_hook_name.c_str());
|
||||
if (ty_raw == LUA_TFUNCTION) {
|
||||
// TODO: (1.22.0) Force conky_ prefix on use_mouse_hook like llua_do_call does
|
||||
// TODO: (1.22.0) Force conky_ prefix on use_mouse_hook like llua_do_call
|
||||
// does
|
||||
// - keep only else case, remove ty_raw and make hook_name const.
|
||||
NORM_ERR("llua_mouse_hook: hook %s declaration is missing 'conky_' prefix", raw_hook_name.c_str());
|
||||
NORM_ERR(
|
||||
"llua_mouse_hook: hook %s declaration is missing 'conky_' prefix",
|
||||
raw_hook_name.c_str());
|
||||
hook_name = raw_hook_name;
|
||||
ty = ty_raw;
|
||||
lua_insert(lua_L, -2);
|
||||
|
|
|
@ -30,8 +30,8 @@
|
|||
#ifndef _LOGGING_H
|
||||
#define _LOGGING_H
|
||||
|
||||
#include <cstdio>
|
||||
#include <cinttypes>
|
||||
#include <cstdio>
|
||||
#include <stdexcept>
|
||||
#include "config.h"
|
||||
#include "i18n.h"
|
||||
|
@ -82,9 +82,10 @@ void NORM_ERR(const char *format, Args &&...args) {
|
|||
|
||||
/* critical error with additional cleanup */
|
||||
template <typename... Args>
|
||||
__attribute__((noreturn))
|
||||
inline void CRIT_ERR_FREE(void *memtofree1, void *memtofree2,
|
||||
const char *format, Args &&...args) {
|
||||
__attribute__((noreturn)) inline void CRIT_ERR_FREE(void *memtofree1,
|
||||
void *memtofree2,
|
||||
const char *format,
|
||||
Args &&...args) {
|
||||
NORM_ERR(format, args...);
|
||||
free(memtofree1);
|
||||
free(memtofree2);
|
||||
|
@ -94,8 +95,8 @@ inline void CRIT_ERR_FREE(void *memtofree1, void *memtofree2,
|
|||
|
||||
/* critical error */
|
||||
template <typename... Args>
|
||||
__attribute__((noreturn))
|
||||
inline void CRIT_ERR(const char *format, Args &&...args) {
|
||||
__attribute__((noreturn)) inline void CRIT_ERR(const char *format,
|
||||
Args &&...args) {
|
||||
CRIT_ERR_FREE(nullptr, nullptr, format, args...);
|
||||
}
|
||||
|
||||
|
|
|
@ -20,10 +20,10 @@
|
|||
|
||||
#include "mouse-events.h"
|
||||
|
||||
#include <array>
|
||||
#include <string>
|
||||
#include <lua.h>
|
||||
#include <time.h>
|
||||
#include <array>
|
||||
#include <string>
|
||||
#include <type_traits>
|
||||
#include "logging.h"
|
||||
|
||||
|
@ -35,8 +35,8 @@ void push_table_value(lua_State *L, std::string key, std::string value) {
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
typename std::enable_if<std::is_integral<T>::value>::type
|
||||
push_table_value(lua_State *L, std::string key, T value) {
|
||||
typename std::enable_if<std::is_integral<T>::value>::type push_table_value(
|
||||
lua_State *L, std::string key, T value) {
|
||||
lua_pushstring(L, key.c_str());
|
||||
lua_pushinteger(L, value);
|
||||
lua_settable(L, -3);
|
||||
|
@ -82,7 +82,8 @@ void push_mods(lua_State *L, modifier_state_t mods) {
|
|||
inline size_t current_time_ms() {
|
||||
struct timespec spec;
|
||||
clock_gettime(CLOCK_REALTIME, &spec);
|
||||
return static_cast<size_t>(static_cast<uint64_t>(spec.tv_sec)*1'000 + spec.tv_nsec/1'000'000);
|
||||
return static_cast<size_t>(static_cast<uint64_t>(spec.tv_sec) * 1'000 +
|
||||
spec.tv_nsec / 1'000'000);
|
||||
}
|
||||
|
||||
void push_table_value(lua_State *L, std::string key, mouse_event_t type) {
|
||||
|
@ -113,7 +114,8 @@ void push_table_value(lua_State *L, std::string key, mouse_event_t type) {
|
|||
lua_settable(L, -3);
|
||||
}
|
||||
|
||||
void push_table_value(lua_State *L, std::string key, scroll_direction_t direction) {
|
||||
void push_table_value(lua_State *L, std::string key,
|
||||
scroll_direction_t direction) {
|
||||
lua_pushstring(L, key.c_str());
|
||||
switch (direction) {
|
||||
case SCROLL_DOWN:
|
||||
|
@ -135,7 +137,6 @@ void push_table_value(lua_State *L, std::string key, scroll_direction_t directio
|
|||
lua_settable(L, -3);
|
||||
}
|
||||
|
||||
|
||||
void push_table_value(lua_State *L, std::string key, mouse_button_t button) {
|
||||
lua_pushstring(L, key.c_str());
|
||||
switch (button) {
|
||||
|
@ -162,7 +163,8 @@ void push_table_value(lua_State *L, std::string key, mouse_button_t button) {
|
|||
}
|
||||
|
||||
/* Class methods */
|
||||
mouse_event::mouse_event(mouse_event_t type): type(type), time(current_time_ms()) {};
|
||||
mouse_event::mouse_event(mouse_event_t type)
|
||||
: type(type), time(current_time_ms()){};
|
||||
|
||||
void mouse_event::push_lua_table(lua_State *L) const {
|
||||
lua_newtable(L);
|
||||
|
|
|
@ -22,8 +22,8 @@
|
|||
#define MOUSE_EVENTS_H
|
||||
|
||||
#include <bitset>
|
||||
#include <string>
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
#include "config.h"
|
||||
#include "logging.h"
|
||||
|
@ -119,7 +119,9 @@ struct mouse_positioned_event : public mouse_event {
|
|||
size_t x = 0, y = 0; // position relative to window
|
||||
size_t x_abs = 0, y_abs = 0; // position relative to root
|
||||
|
||||
mouse_positioned_event(mouse_event_t type, size_t x, size_t y, size_t x_abs, size_t y_abs): mouse_event(type), x(x), y(y), x_abs(x_abs), y_abs() {};
|
||||
mouse_positioned_event(mouse_event_t type, size_t x, size_t y, size_t x_abs,
|
||||
size_t y_abs)
|
||||
: mouse_event(type), x(x), y(y), x_abs(x_abs), y_abs(){};
|
||||
|
||||
void push_lua_data(lua_State *L) const;
|
||||
};
|
||||
|
@ -152,7 +154,10 @@ inline modifier_state_t x11_modifier_state(unsigned int mods) {
|
|||
struct mouse_move_event : public mouse_positioned_event {
|
||||
modifier_state_t mods; // held buttons and modifiers (ctrl, shift, ...)
|
||||
|
||||
mouse_move_event(size_t x, size_t y, size_t x_abs, size_t y_abs, modifier_state_t mods = 0): mouse_positioned_event{mouse_event_t::MOUSE_MOVE, x, y, x_abs, y_abs}, mods(mods) {};
|
||||
mouse_move_event(size_t x, size_t y, size_t x_abs, size_t y_abs,
|
||||
modifier_state_t mods = 0)
|
||||
: mouse_positioned_event{mouse_event_t::MOUSE_MOVE, x, y, x_abs, y_abs},
|
||||
mods(mods){};
|
||||
|
||||
void push_lua_data(lua_State *L) const;
|
||||
};
|
||||
|
@ -190,7 +195,11 @@ struct mouse_scroll_event : public mouse_positioned_event {
|
|||
modifier_state_t mods; // held buttons and modifiers (ctrl, shift, ...)
|
||||
scroll_direction_t direction;
|
||||
|
||||
mouse_scroll_event(size_t x, size_t y, size_t x_abs, size_t y_abs, scroll_direction_t direction, modifier_state_t mods = 0): mouse_positioned_event{mouse_event_t::MOUSE_SCROLL, x, y, x_abs, y_abs}, direction(direction), mods(mods) {};
|
||||
mouse_scroll_event(size_t x, size_t y, size_t x_abs, size_t y_abs,
|
||||
scroll_direction_t direction, modifier_state_t mods = 0)
|
||||
: mouse_positioned_event{mouse_event_t::MOUSE_SCROLL, x, y, x_abs, y_abs},
|
||||
direction(direction),
|
||||
mods(mods){};
|
||||
|
||||
void push_lua_data(lua_State *L) const;
|
||||
};
|
||||
|
@ -199,13 +208,20 @@ struct mouse_button_event : public mouse_positioned_event {
|
|||
modifier_state_t mods; // held buttons and modifiers (ctrl, shift, ...)
|
||||
mouse_button_t button;
|
||||
|
||||
mouse_button_event(mouse_event_t type, size_t x, size_t y, size_t x_abs, size_t y_abs, mouse_button_t button, modifier_state_t mods = 0): mouse_positioned_event{type, x, y, x_abs, y_abs}, button(button), mods(mods) {};
|
||||
mouse_button_event(mouse_event_t type, size_t x, size_t y, size_t x_abs,
|
||||
size_t y_abs, mouse_button_t button,
|
||||
modifier_state_t mods = 0)
|
||||
: mouse_positioned_event{type, x, y, x_abs, y_abs},
|
||||
button(button),
|
||||
mods(mods){};
|
||||
|
||||
void push_lua_data(lua_State *L) const;
|
||||
};
|
||||
|
||||
struct mouse_crossing_event : public mouse_positioned_event {
|
||||
mouse_crossing_event(mouse_event_t type, size_t x, size_t y, size_t x_abs, size_t y_abs): mouse_positioned_event{type, x, y, x_abs, y_abs} {};
|
||||
mouse_crossing_event(mouse_event_t type, size_t x, size_t y, size_t x_abs,
|
||||
size_t y_abs)
|
||||
: mouse_positioned_event{type, x, y, x_abs, y_abs} {};
|
||||
};
|
||||
|
||||
#endif /* MOUSE_EVENTS_H */
|
||||
|
|
67
src/x11.cc
67
src/x11.cc
|
@ -27,21 +27,22 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#include "x11.h"
|
||||
|
||||
#include <X11/X.h>
|
||||
#include <X11/extensions/XI2.h>
|
||||
#include <sys/types.h>
|
||||
#include "common.h"
|
||||
#include "config.h"
|
||||
#include "conky.h"
|
||||
#include "gui.h"
|
||||
#include "logging.h"
|
||||
#include "x11.h"
|
||||
|
||||
#include <array>
|
||||
#include <cstddef>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <string>
|
||||
#include <array>
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wvariadic-macros"
|
||||
|
@ -52,7 +53,7 @@
|
|||
#include <X11/Xlib.h>
|
||||
#include <X11/Xmd.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include "gui.h"
|
||||
|
||||
#ifdef BUILD_IMLIB2
|
||||
#include "imlib2.h"
|
||||
#endif /* BUILD_IMLIB2 */
|
||||
|
@ -72,8 +73,8 @@
|
|||
#include <X11/extensions/Xfixes.h>
|
||||
#endif /* BUILD_XFIXES */
|
||||
#ifdef BUILD_XINPUT
|
||||
#include <vector>
|
||||
#include <X11/extensions/XInput2.h>
|
||||
#include <vector>
|
||||
#endif /* BUILD_XINPUT */
|
||||
#ifdef HAVE_XCB_ERRORS
|
||||
#include <xcb/xcb.h>
|
||||
|
@ -83,7 +84,6 @@
|
|||
/* some basic X11 stuff */
|
||||
Display *display = nullptr;
|
||||
|
||||
|
||||
#ifdef HAVE_XCB_ERRORS
|
||||
xcb_connection_t *xcb_connection;
|
||||
xcb_errors_context_t *xcb_errors_ctx;
|
||||
|
@ -239,8 +239,7 @@ imlib_cache_size_setting imlib_cache_size;
|
|||
/******************** </SETTINGS> ************************/
|
||||
|
||||
/* WARNING, this type not in Xlib spec */
|
||||
static int
|
||||
x11_error_handler(Display *d, XErrorEvent *err) {
|
||||
static int x11_error_handler(Display *d, XErrorEvent *err) {
|
||||
char *error_name = nullptr;
|
||||
bool name_allocated = false;
|
||||
|
||||
|
@ -250,7 +249,8 @@ x11_error_handler(Display *d, XErrorEvent *err) {
|
|||
#ifdef HAVE_XCB_ERRORS
|
||||
if (xcb_errors_ctx != nullptr) {
|
||||
const char *extension;
|
||||
const char *base_name = xcb_errors_get_name_for_error(xcb_errors_ctx, err->error_code, &extension);
|
||||
const char *base_name = xcb_errors_get_name_for_error(
|
||||
xcb_errors_ctx, err->error_code, &extension);
|
||||
if (extension != nullptr) {
|
||||
const size_t size = strlen(base_name) + strlen(extension) + 4;
|
||||
error_name = new char(size);
|
||||
|
@ -260,8 +260,10 @@ x11_error_handler(Display *d, XErrorEvent *err) {
|
|||
error_name = const_cast<char *>(base_name);
|
||||
}
|
||||
|
||||
const char *major = xcb_errors_get_name_for_major_code(xcb_errors_ctx, err->request_code);
|
||||
const char *minor = xcb_errors_get_name_for_minor_code(xcb_errors_ctx, err->request_code, err->minor_code);
|
||||
const char *major =
|
||||
xcb_errors_get_name_for_major_code(xcb_errors_ctx, err->request_code);
|
||||
const char *minor = xcb_errors_get_name_for_minor_code(
|
||||
xcb_errors_ctx, err->request_code, err->minor_code);
|
||||
if (minor != nullptr) {
|
||||
const size_t size = strlen(base_name) + strlen(extension) + 4;
|
||||
code_description = new char(size);
|
||||
|
@ -276,10 +278,10 @@ x11_error_handler(Display *d, XErrorEvent *err) {
|
|||
if (error_name == nullptr) {
|
||||
if (err->error_code > 0 && err->error_code < 17) {
|
||||
static std::array<std::string, 17> NAMES = {
|
||||
"request", "value", "window", "pixmap", "atom", "cursor", "font", "match",
|
||||
"drawable", "access", "alloc", "colormap", "G context", "ID choice",
|
||||
"name", "length", "implementation"
|
||||
};
|
||||
"request", "value", "window", "pixmap", "atom",
|
||||
"cursor", "font", "match", "drawable", "access",
|
||||
"alloc", "colormap", "G context", "ID choice", "name",
|
||||
"length", "implementation"};
|
||||
error_name = const_cast<char *>(NAMES[err->error_code].c_str());
|
||||
} else {
|
||||
static char code_name_buffer[4];
|
||||
|
@ -290,7 +292,8 @@ x11_error_handler(Display *d, XErrorEvent *err) {
|
|||
if (code_description == nullptr) {
|
||||
const size_t size = 37;
|
||||
code_description = new char(size);
|
||||
snprintf(code_description, size, "error code: [major: %i, minor: %i]", err->request_code, err->minor_code);
|
||||
snprintf(code_description, size, "error code: [major: %i, minor: %i]",
|
||||
err->request_code, err->minor_code);
|
||||
code_allocated = true;
|
||||
}
|
||||
|
||||
|
@ -298,11 +301,8 @@ x11_error_handler(Display *d, XErrorEvent *err) {
|
|||
"X %s Error:\n"
|
||||
"Display: %lx, XID: %li, Serial: %lu\n"
|
||||
"%s",
|
||||
error_name,
|
||||
reinterpret_cast<uint64_t>(err->display),
|
||||
static_cast<int64_t>(err->resourceid), err->serial,
|
||||
code_description
|
||||
);
|
||||
error_name, reinterpret_cast<uint64_t>(err->display),
|
||||
static_cast<int64_t>(err->resourceid), err->serial, code_description);
|
||||
|
||||
if (name_allocated) free(error_name);
|
||||
if (code_allocated) free(code_description);
|
||||
|
@ -310,8 +310,7 @@ x11_error_handler(Display *d, XErrorEvent *err) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
__attribute__((noreturn))
|
||||
static int x11_ioerror_handler(Display *d) {
|
||||
__attribute__((noreturn)) static int x11_ioerror_handler(Display *d) {
|
||||
CRIT_ERR("X IO Error: Display %lx\n", reinterpret_cast<uint64_t>(d));
|
||||
}
|
||||
|
||||
|
@ -962,7 +961,8 @@ void x11_init_window(lua::state &l, bool own) {
|
|||
#ifdef BUILD_XINPUT
|
||||
do { // not loop
|
||||
int _ignored; // segfault if NULL
|
||||
if (!XQueryExtension(display, "XInputExtension", &window.xi_opcode, &_ignored, &_ignored)) {
|
||||
if (!XQueryExtension(display, "XInputExtension", &window.xi_opcode,
|
||||
&_ignored, &_ignored)) {
|
||||
// events will still ~work but let the user know why they're buggy
|
||||
NORM_ERR("XInput extension is not supported by X11!");
|
||||
break;
|
||||
|
@ -1356,8 +1356,8 @@ void print_mouse_speed(struct text_object *obj, char *p,
|
|||
}
|
||||
|
||||
InputEvent *xev_as_input_event(XEvent &ev) {
|
||||
if (ev.type == KeyPress || ev.type == KeyRelease ||
|
||||
ev.type == ButtonPress || ev.type == ButtonRelease || ev.type == MotionNotify ||
|
||||
if (ev.type == KeyPress || ev.type == KeyRelease || ev.type == ButtonPress ||
|
||||
ev.type == ButtonRelease || ev.type == MotionNotify ||
|
||||
ev.type == EnterNotify || ev.type == LeaveNotify) {
|
||||
return reinterpret_cast<InputEvent *>(&ev);
|
||||
} else {
|
||||
|
@ -1380,9 +1380,7 @@ void propagate_x11_event(XEvent &ev) {
|
|||
XGetInputFocus(display, &focused, &_revert_to);
|
||||
if (focused == window.window) {
|
||||
Time time = CurrentTime;
|
||||
if (i_ev != nullptr) {
|
||||
time = i_ev->common.time;
|
||||
}
|
||||
if (i_ev != nullptr) { time = i_ev->common.time; }
|
||||
XSetInputFocus(display, window.desktop, RevertToPointerRoot, time);
|
||||
}
|
||||
}
|
||||
|
@ -1396,7 +1394,9 @@ inline Window last_descendant(Display* display, Window parent) {
|
|||
|
||||
Window current = parent;
|
||||
|
||||
while (XQueryTree(display, current, &_ignored, &_ignored, &children, &count) && count != 0) {
|
||||
while (
|
||||
XQueryTree(display, current, &_ignored, &_ignored, &children, &count) &&
|
||||
count != 0) {
|
||||
current = children[count - 1];
|
||||
XFree(children);
|
||||
}
|
||||
|
@ -1413,9 +1413,8 @@ Window query_x11_window_at_pos(Display* display, int x, int y) {
|
|||
unsigned int mask_return;
|
||||
|
||||
Window last = None;
|
||||
XQueryPointer(display, window.root, &root_return, &last,
|
||||
&root_x_return, &root_y_return, &win_x_return, &win_y_return, &mask_return
|
||||
);
|
||||
XQueryPointer(display, window.root, &root_return, &last, &root_x_return,
|
||||
&root_y_return, &win_x_return, &win_y_return, &mask_return);
|
||||
|
||||
// X11 correctly returns a window which covers conky area, but returned window
|
||||
// is not window.window, but instead a parent node in some cases and the
|
||||
|
|
|
@ -24,20 +24,21 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "setting.hh"
|
||||
|
||||
#include <X11/Xatom.h>
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wvariadic-macros"
|
||||
#include <X11/Xlib.h>
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
#ifdef BUILD_XFT
|
||||
#include <X11/Xft/Xft.h>
|
||||
#endif
|
||||
|
||||
#ifdef BUILD_XDBE
|
||||
#include <X11/extensions/Xdbe.h>
|
||||
#endif
|
||||
|
||||
#include "setting.hh"
|
||||
#include <cstdint>
|
||||
|
||||
#ifdef BUILD_ARGB
|
||||
|
@ -146,7 +147,8 @@ union InputEvent {
|
|||
XEvent base;
|
||||
};
|
||||
|
||||
// Returns InputEvent pointer to provided XEvent is an input event; nullptr otherwise.
|
||||
// Returns InputEvent pointer to provided XEvent is an input event; nullptr
|
||||
// otherwise.
|
||||
InputEvent *xev_as_input_event(XEvent &ev);
|
||||
void propagate_x11_event(XEvent &ev);
|
||||
|
||||
|
|
Loading…
Reference in New Issue