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_MYSQL=ON \
|
||||||
-DBUILD_NVIDIA=ON \
|
-DBUILD_NVIDIA=ON \
|
||||||
-DBUILD_PULSEAUDIO=ON \
|
-DBUILD_PULSEAUDIO=ON \
|
||||||
|
-DBUILD_CURL=ON \
|
||||||
-DBUILD_RSS=ON \
|
-DBUILD_RSS=ON \
|
||||||
-DBUILD_TESTS=ON \
|
-DBUILD_TESTS=ON \
|
||||||
-DBUILD_WLAN=ON \
|
-DBUILD_WLAN=ON \
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# 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)
|
project(conky)
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,9 @@
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
|
|
||||||
|
include(CMakeDependentOption)
|
||||||
|
include(DependentOption)
|
||||||
|
|
||||||
if(NOT CMAKE_BUILD_TYPE)
|
if(NOT CMAKE_BUILD_TYPE)
|
||||||
if(MAINTAINER_MODE)
|
if(MAINTAINER_MODE)
|
||||||
set(
|
set(
|
||||||
|
@ -97,33 +100,26 @@ set(DEFAULT_TEXT_BUFFER_SIZE "256"
|
||||||
set(MAX_NET_INTERFACES "256" CACHE STRING "Maximum number of network devices")
|
set(MAX_NET_INTERFACES "256" CACHE STRING "Maximum number of network devices")
|
||||||
|
|
||||||
# Platform specific options Linux only
|
# Platform specific options Linux only
|
||||||
if(OS_LINUX)
|
cmake_dependent_option(BUILD_PORT_MONITORS "Build TCP portmon support" true
|
||||||
option(BUILD_PORT_MONITORS "Build TCP portmon support" true)
|
"OS_LINUX" false)
|
||||||
option(BUILD_IBM "Support for IBM/Lenovo notebooks" true)
|
cmake_dependent_option(BUILD_IBM "Support for IBM/Lenovo notebooks" true
|
||||||
option(BUILD_HDDTEMP "Support for hddtemp" true)
|
"OS_LINUX" false)
|
||||||
option(BUILD_IPV6 "Enable if you want IPv6 support" true)
|
cmake_dependent_option(BUILD_HDDTEMP "Support for hddtemp" true
|
||||||
if(BUILD_X11)
|
"OS_LINUX" false)
|
||||||
# nvidia may also work on FreeBSD, not sure
|
cmake_dependent_option(BUILD_IPV6 "Enable if you want IPv6 support" true
|
||||||
option(BUILD_NVIDIA "Enable nvidia support" false)
|
"OS_LINUX" false)
|
||||||
endif(BUILD_X11)
|
# nvidia may also work on FreeBSD, not sure
|
||||||
else(OS_LINUX)
|
cmake_dependent_option(BUILD_NVIDIA "Enable nvidia support" false
|
||||||
set(BUILD_PORT_MONITORS false)
|
"OS_LINUX" false)
|
||||||
set(BUILD_IBM false)
|
|
||||||
set(BUILD_HDDTEMP false)
|
|
||||||
set(BUILD_NVIDIA false)
|
|
||||||
set(BUILD_IPV6 false)
|
|
||||||
endif(OS_LINUX)
|
|
||||||
|
|
||||||
# macOS Only
|
# macOS Only
|
||||||
if(OS_DARWIN)
|
cmake_dependent_option(
|
||||||
option(
|
BUILD_IPGFREQ
|
||||||
BUILD_IPGFREQ
|
"Enable cpu freq calculation based on Intel® Power Gadget; otherwise use constant factory value"
|
||||||
"Enable cpu freq calculation based on Intel® Power Gadget; otherwise use constant factory value"
|
false
|
||||||
false)
|
"OS_DARWIN" false)
|
||||||
endif(OS_DARWIN)
|
|
||||||
|
|
||||||
# Optional features etc
|
# Optional features etc
|
||||||
#
|
|
||||||
|
|
||||||
option(BUILD_WLAN "Enable wireless support" false)
|
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_MATH "Enable math support" true)
|
||||||
|
|
||||||
option(BUILD_NCURSES "Enable ncurses support" true)
|
option(BUILD_NCURSES "Enable ncurses support" true)
|
||||||
if(BUILD_NCURSES)
|
|
||||||
option(
|
dependent_option(LEAKFREE_NCURSES
|
||||||
LEAKFREE_NCURSES
|
"Enable to hide false ncurses-memleaks in valgrind (works only when ncurses is compiled with --disable-leaks)"
|
||||||
"Enable to hide false ncurses-memleaks in valgrind (works only when ncurses is compiled with --disable-leaks)"
|
false
|
||||||
false)
|
"BUILD_NCURSES" false
|
||||||
else(BUILD_NCURSES)
|
"LEAKFREE_NCURSES requires 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)
|
|
||||||
|
|
||||||
option(BUILD_WAYLAND "Build Wayland support" false)
|
option(BUILD_WAYLAND "Build Wayland support" false)
|
||||||
|
|
||||||
option(BUILD_X11 "Build X11 support" true)
|
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
|
||||||
if(OS_DARWIN)
|
"BUILD_X11" false
|
||||||
option(BUILD_XDAMAGE "Build Xdamage support" false)
|
"Dedicated window mode only works on X11")
|
||||||
option(BUILD_XFIXES "Build Xfixes support" false)
|
|
||||||
else(OS_DARWIN)
|
|
||||||
option(BUILD_XDAMAGE "Build Xdamage support" true)
|
|
||||||
option(BUILD_XFIXES "Build Xfixes support" true)
|
|
||||||
endif(OS_DARWIN)
|
|
||||||
|
|
||||||
option(BUILD_XINERAMA "Build Xinerama support" true)
|
# On MacOS these cause issues so they're disabled by default
|
||||||
option(BUILD_XDBE "Build Xdbe (double-buffer) support" true)
|
if(OS_DARWIN)
|
||||||
option(BUILD_XFT "Build Xft (freetype fonts) support" true)
|
dependent_option(BUILD_XDAMAGE "Build Xdamage support" false
|
||||||
option(BUILD_IMLIB2 "Enable Imlib2 support" true)
|
"BUILD_X11" false
|
||||||
option(BUILD_XSHAPE "Enable Xshape support" true)
|
"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_LUA_IMLIB2 "Build Imlib2 bindings for Lua" false)
|
dependent_option(BUILD_XINERAMA "Build Xinerama support" true
|
||||||
else(BUILD_X11)
|
"BUILD_X11" false
|
||||||
set(OWN_WINDOW false CACHE BOOL "Enable own_window support" FORCE)
|
"Xinerama support requires X11")
|
||||||
set(BUILD_XDAMAGE false CACHE BOOL "Build Xdamage support" FORCE)
|
dependent_option(BUILD_XDBE "Build Xdbe (double-buffer) support" true
|
||||||
set(BUILD_XFIXES false CACHE BOOL "Build Xfixes support" FORCE)
|
"BUILD_X11" false
|
||||||
set(BUILD_XINERAMA false CACHE BOOL "Build Xinerama support" FORCE)
|
"Xdbe based double-buffering requires X11")
|
||||||
set(BUILD_XDBE false CACHE BOOL "Build Xdbe (double-buffer) support" FORCE)
|
dependent_option(BUILD_XFT "Build Xft (freetype fonts) support" true
|
||||||
set(BUILD_XFT false CACHE BOOL "Build Xft (freetype fonts) support" FORCE)
|
"BUILD_X11" false
|
||||||
set(BUILD_IMLIB2 false CACHE BOOL "Enable Imlib2 support" FORCE)
|
"Xft (freetype font) support requires X11")
|
||||||
set(BUILD_XSHAPE false CACHE BOOL "Enable Xshape support" FORCE)
|
dependent_option(BUILD_IMLIB2 "Enable Imlib2 support" true
|
||||||
|
"BUILD_X11" false
|
||||||
set(BUILD_LUA_IMLIB2 false CACHE BOOL "Build Imlib2 bindings for Lua" FORCE)
|
"Imlib2 support requires X11")
|
||||||
set(BUILD_NVIDIA false)
|
dependent_option(BUILD_XSHAPE "Enable Xshape support" true
|
||||||
endif(BUILD_X11)
|
"BUILD_X11" false
|
||||||
|
"Xshape support requires X11")
|
||||||
|
|
||||||
# if we build with any GUI support
|
# if we build with any GUI support
|
||||||
if(BUILD_X11)
|
if(BUILD_X11)
|
||||||
|
@ -195,25 +189,22 @@ if(BUILD_WAYLAND)
|
||||||
set(BUILD_GUI true)
|
set(BUILD_GUI true)
|
||||||
endif(BUILD_WAYLAND)
|
endif(BUILD_WAYLAND)
|
||||||
|
|
||||||
if(BUILD_GUI)
|
dependent_option(BUILD_MOUSE_EVENTS "Enable mouse event support" true
|
||||||
option(BUILD_MOUSE_EVENTS "Enable mouse event support" true)
|
"BUILD_WAYLAND OR OWN_WINDOW" false
|
||||||
endif(BUILD_GUI)
|
"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)
|
dependent_option(BUILD_ARGB "Build ARGB (real transparency) support" true
|
||||||
option(BUILD_XINPUT "Build Xinput 2 support" true)
|
"OWN_WINDOW" false
|
||||||
else(BUILD_GUI AND BUILD_MOUSE_EVENTS)
|
"ARGB support requires OWN_WINDOW enabled")
|
||||||
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)
|
|
||||||
|
|
||||||
|
# Lua library options
|
||||||
option(BUILD_LUA_CAIRO "Build cairo bindings for Lua" false)
|
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_LUA_RSVG "Build rsvg bindings for Lua" false)
|
||||||
|
|
||||||
option(BUILD_AUDACIOUS "Build audacious (music player) support" 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_CURL "Enable if you want Curl support" false)
|
||||||
|
|
||||||
option(BUILD_RSS "Enable if you want RSS support" false)
|
dependent_option(BUILD_RSS "Enable if you want RSS support" false
|
||||||
|
"BUILD_CURL" false
|
||||||
if(BUILD_RSS)
|
"RSS depends on Curl support")
|
||||||
# if RSS is enabled, curl is required
|
|
||||||
set(BUILD_CURL true)
|
|
||||||
endif(BUILD_RSS)
|
|
||||||
|
|
||||||
option(BUILD_APCUPSD "Enable APCUPSD support" true)
|
option(BUILD_APCUPSD "Enable APCUPSD support" true)
|
||||||
|
|
||||||
|
|
|
@ -59,6 +59,8 @@ set(INCLUDE_SEARCH_PATH /usr/include /usr/local/include)
|
||||||
# Set system vars
|
# Set system vars
|
||||||
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
|
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
|
||||||
set(OS_LINUX true)
|
set(OS_LINUX true)
|
||||||
|
else(CMAKE_SYSTEM_NAME MATCHES "Linux")
|
||||||
|
set(OS_LINUX false)
|
||||||
endif(CMAKE_SYSTEM_NAME MATCHES "Linux")
|
endif(CMAKE_SYSTEM_NAME MATCHES "Linux")
|
||||||
|
|
||||||
if(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
|
if(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
|
||||||
|
@ -68,33 +70,47 @@ if(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
|
||||||
if(BUILD_IRC)
|
if(BUILD_IRC)
|
||||||
set(conky_libs ${conky_libs} -lssl -lcrypto)
|
set(conky_libs ${conky_libs} -lssl -lcrypto)
|
||||||
endif(BUILD_IRC)
|
endif(BUILD_IRC)
|
||||||
|
else(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
|
||||||
|
set(OS_FREEBSD false)
|
||||||
endif(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
|
endif(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
|
||||||
|
|
||||||
if(CMAKE_SYSTEM_NAME MATCHES "DragonFly")
|
if(CMAKE_SYSTEM_NAME MATCHES "DragonFly")
|
||||||
set(OS_DRAGONFLY true)
|
set(OS_DRAGONFLY true)
|
||||||
set(conky_libs ${conky_libs} -ldevstat)
|
set(conky_libs ${conky_libs} -ldevstat)
|
||||||
|
else(CMAKE_SYSTEM_NAME MATCHES "DragonFly")
|
||||||
|
set(OS_DRAGONFLY false)
|
||||||
endif(CMAKE_SYSTEM_NAME MATCHES "DragonFly")
|
endif(CMAKE_SYSTEM_NAME MATCHES "DragonFly")
|
||||||
|
|
||||||
if(CMAKE_SYSTEM_NAME MATCHES "OpenBSD")
|
if(CMAKE_SYSTEM_NAME MATCHES "OpenBSD")
|
||||||
set(OS_OPENBSD true)
|
set(OS_OPENBSD true)
|
||||||
|
else(CMAKE_SYSTEM_NAME MATCHES "OpenBSD")
|
||||||
|
set(OS_OPENBSD false)
|
||||||
endif(CMAKE_SYSTEM_NAME MATCHES "OpenBSD")
|
endif(CMAKE_SYSTEM_NAME MATCHES "OpenBSD")
|
||||||
|
|
||||||
if(CMAKE_SYSTEM_NAME MATCHES "SunOS")
|
if(CMAKE_SYSTEM_NAME MATCHES "SunOS")
|
||||||
set(OS_SOLARIS true)
|
set(OS_SOLARIS true)
|
||||||
set(conky_libs ${conky_libs} -lkstat)
|
set(conky_libs ${conky_libs} -lkstat)
|
||||||
|
else(CMAKE_SYSTEM_NAME MATCHES "SunOS")
|
||||||
|
set(OS_SOLARIS false)
|
||||||
endif(CMAKE_SYSTEM_NAME MATCHES "SunOS")
|
endif(CMAKE_SYSTEM_NAME MATCHES "SunOS")
|
||||||
|
|
||||||
if(CMAKE_SYSTEM_NAME MATCHES "NetBSD")
|
if(CMAKE_SYSTEM_NAME MATCHES "NetBSD")
|
||||||
set(OS_NETBSD true)
|
set(OS_NETBSD true)
|
||||||
|
else(CMAKE_SYSTEM_NAME MATCHES "NetBSD")
|
||||||
|
set(OS_NETBSD false)
|
||||||
endif(CMAKE_SYSTEM_NAME MATCHES "NetBSD")
|
endif(CMAKE_SYSTEM_NAME MATCHES "NetBSD")
|
||||||
|
|
||||||
if(CMAKE_SYSTEM_NAME MATCHES "Haiku")
|
if(CMAKE_SYSTEM_NAME MATCHES "Haiku")
|
||||||
set(OS_HAIKU true)
|
set(OS_HAIKU true)
|
||||||
set(conky_libs ${conky_libs} -lnetwork -lintl)
|
set(conky_libs ${conky_libs} -lnetwork -lintl)
|
||||||
|
else(CMAKE_SYSTEM_NAME MATCHES "Haiku")
|
||||||
|
set(OS_HAIKU false)
|
||||||
endif(CMAKE_SYSTEM_NAME MATCHES "Haiku")
|
endif(CMAKE_SYSTEM_NAME MATCHES "Haiku")
|
||||||
|
|
||||||
if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
|
if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
|
||||||
set(OS_DARWIN true)
|
set(OS_DARWIN true)
|
||||||
|
else(CMAKE_SYSTEM_NAME MATCHES "Darwin")
|
||||||
|
set(OS_DARWIN false)
|
||||||
endif(CMAKE_SYSTEM_NAME MATCHES "Darwin")
|
endif(CMAKE_SYSTEM_NAME MATCHES "Darwin")
|
||||||
|
|
||||||
if(NOT OS_LINUX
|
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
|
#ifdef BUILD_WAYLAND
|
||||||
#include <wayland-client.h>
|
#include <wayland-client.h>
|
||||||
|
@ -62,9 +62,9 @@
|
||||||
#include "fonts.h"
|
#include "fonts.h"
|
||||||
#endif
|
#endif
|
||||||
#ifdef BUILD_MOUSE_EVENTS
|
#ifdef BUILD_MOUSE_EVENTS
|
||||||
#include "mouse-events.h"
|
|
||||||
#include <map>
|
|
||||||
#include <array>
|
#include <array>
|
||||||
|
#include <map>
|
||||||
|
#include "mouse-events.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#pragma GCC diagnostic ignored "-Wunused-parameter"
|
#pragma GCC diagnostic ignored "-Wunused-parameter"
|
||||||
|
@ -429,11 +429,11 @@ void window_layer_surface_set_size(struct window *window) {
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef BUILD_MOUSE_EVENTS
|
#ifdef BUILD_MOUSE_EVENTS
|
||||||
static std::map<wl_pointer*, std::array<size_t, 2>> last_known_positions{};
|
static std::map<wl_pointer *, std::array<size_t, 2>> last_known_positions{};
|
||||||
|
|
||||||
static void on_pointer_enter(void *data, wl_pointer *pointer, uint32_t serial,
|
static void on_pointer_enter(void *data, wl_pointer *pointer, uint32_t serial,
|
||||||
wl_surface *surface, wl_fixed_t surface_x,
|
wl_surface *surface, wl_fixed_t surface_x,
|
||||||
wl_fixed_t surface_y) {
|
wl_fixed_t surface_y) {
|
||||||
auto w = reinterpret_cast<struct window *>(data);
|
auto w = reinterpret_cast<struct window *>(data);
|
||||||
|
|
||||||
size_t x = static_cast<size_t>(wl_fixed_to_double(surface_x));
|
size_t x = static_cast<size_t>(wl_fixed_to_double(surface_x));
|
||||||
|
@ -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_x = w->rectangle.x + x;
|
||||||
size_t abs_y = w->rectangle.y + y;
|
size_t abs_y = w->rectangle.y + y;
|
||||||
|
|
||||||
mouse_crossing_event event {
|
mouse_crossing_event event{mouse_event_t::AREA_ENTER, x, y, abs_x, abs_y};
|
||||||
mouse_event_t::AREA_ENTER,
|
|
||||||
x,
|
|
||||||
y,
|
|
||||||
abs_x,
|
|
||||||
abs_y
|
|
||||||
};
|
|
||||||
llua_mouse_hook(event);
|
llua_mouse_hook(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void on_pointer_leave(void *data,
|
static void on_pointer_leave(void *data, struct wl_pointer *pointer,
|
||||||
struct wl_pointer *pointer,
|
uint32_t serial, struct wl_surface *surface) {
|
||||||
uint32_t serial,
|
|
||||||
struct wl_surface *surface) {
|
|
||||||
auto w = reinterpret_cast<struct window *>(data);
|
auto w = reinterpret_cast<struct window *>(data);
|
||||||
|
|
||||||
std::array<size_t, 2> last = last_known_positions[pointer];
|
std::array<size_t, 2> last = last_known_positions[pointer];
|
||||||
|
@ -465,21 +457,13 @@ static void on_pointer_leave(void *data,
|
||||||
size_t abs_x = w->rectangle.x + x;
|
size_t abs_x = w->rectangle.x + x;
|
||||||
size_t abs_y = w->rectangle.y + y;
|
size_t abs_y = w->rectangle.y + y;
|
||||||
|
|
||||||
mouse_crossing_event event {
|
mouse_crossing_event event{mouse_event_t::AREA_LEAVE, x, y, abs_x, abs_y};
|
||||||
mouse_event_t::AREA_LEAVE,
|
|
||||||
x,
|
|
||||||
y,
|
|
||||||
abs_x,
|
|
||||||
abs_y
|
|
||||||
};
|
|
||||||
llua_mouse_hook(event);
|
llua_mouse_hook(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void on_pointer_motion(void *data,
|
static void on_pointer_motion(void *data, struct wl_pointer *pointer,
|
||||||
struct wl_pointer *pointer,
|
uint32_t _time, wl_fixed_t surface_x,
|
||||||
uint32_t _time,
|
wl_fixed_t surface_y) {
|
||||||
wl_fixed_t surface_x,
|
|
||||||
wl_fixed_t surface_y) {
|
|
||||||
auto w = reinterpret_cast<struct window *>(data);
|
auto w = reinterpret_cast<struct window *>(data);
|
||||||
|
|
||||||
size_t x = static_cast<size_t>(wl_fixed_to_double(surface_x));
|
size_t x = static_cast<size_t>(wl_fixed_to_double(surface_x));
|
||||||
|
@ -489,21 +473,13 @@ static void on_pointer_motion(void *data,
|
||||||
size_t abs_x = w->rectangle.x + x;
|
size_t abs_x = w->rectangle.x + x;
|
||||||
size_t abs_y = w->rectangle.y + y;
|
size_t abs_y = w->rectangle.y + y;
|
||||||
|
|
||||||
mouse_move_event event {
|
mouse_move_event event{x, y, abs_x, abs_y};
|
||||||
x,
|
|
||||||
y,
|
|
||||||
abs_x,
|
|
||||||
abs_y
|
|
||||||
};
|
|
||||||
llua_mouse_hook(event);
|
llua_mouse_hook(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void on_pointer_button(void *data,
|
static void on_pointer_button(void *data, struct wl_pointer *pointer,
|
||||||
struct wl_pointer *pointer,
|
uint32_t serial, uint32_t time, uint32_t button,
|
||||||
uint32_t serial,
|
uint32_t state) {
|
||||||
uint32_t time,
|
|
||||||
uint32_t button,
|
|
||||||
uint32_t state) {
|
|
||||||
auto w = reinterpret_cast<struct window *>(data);
|
auto w = reinterpret_cast<struct window *>(data);
|
||||||
|
|
||||||
std::array<size_t, 2> last = last_known_positions[pointer];
|
std::array<size_t, 2> last = last_known_positions[pointer];
|
||||||
|
@ -512,13 +488,9 @@ static void on_pointer_button(void *data,
|
||||||
size_t abs_x = w->rectangle.x + x;
|
size_t abs_x = w->rectangle.x + x;
|
||||||
size_t abs_y = w->rectangle.y + y;
|
size_t abs_y = w->rectangle.y + y;
|
||||||
|
|
||||||
mouse_button_event event {
|
mouse_button_event event{
|
||||||
mouse_event_t::MOUSE_RELEASE,
|
mouse_event_t::MOUSE_RELEASE, x, y, abs_x, abs_y,
|
||||||
x,
|
static_cast<mouse_button_t>(button),
|
||||||
y,
|
|
||||||
abs_x,
|
|
||||||
abs_y,
|
|
||||||
static_cast<mouse_button_t>(button),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
switch (static_cast<wl_pointer_button_state>(state)) {
|
switch (static_cast<wl_pointer_button_state>(state)) {
|
||||||
|
@ -534,11 +506,8 @@ static void on_pointer_button(void *data,
|
||||||
llua_mouse_hook(event);
|
llua_mouse_hook(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void on_pointer_axis(void *data,
|
void on_pointer_axis(void *data, struct wl_pointer *pointer, uint32_t time,
|
||||||
struct wl_pointer *pointer,
|
uint32_t axis, wl_fixed_t value) {
|
||||||
uint32_t time,
|
|
||||||
uint32_t axis,
|
|
||||||
wl_fixed_t value) {
|
|
||||||
if (value == 0) return;
|
if (value == 0) return;
|
||||||
|
|
||||||
auto w = reinterpret_cast<struct window *>(data);
|
auto w = reinterpret_cast<struct window *>(data);
|
||||||
|
@ -549,20 +518,18 @@ void on_pointer_axis(void *data,
|
||||||
size_t abs_x = w->rectangle.x + x;
|
size_t abs_x = w->rectangle.x + x;
|
||||||
size_t abs_y = w->rectangle.y + y;
|
size_t abs_y = w->rectangle.y + y;
|
||||||
|
|
||||||
mouse_scroll_event event {
|
mouse_scroll_event event{
|
||||||
x,
|
x, y, abs_x, abs_y, scroll_direction_t::SCROLL_UP,
|
||||||
y,
|
|
||||||
abs_x,
|
|
||||||
abs_y,
|
|
||||||
scroll_direction_t::SCROLL_UP,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
switch (static_cast<wl_pointer_axis>(axis)) {
|
switch (static_cast<wl_pointer_axis>(axis)) {
|
||||||
case WL_POINTER_AXIS_VERTICAL_SCROLL:
|
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;
|
break;
|
||||||
case WL_POINTER_AXIS_HORIZONTAL_SCROLL:
|
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;
|
break;
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
|
@ -570,24 +537,27 @@ void on_pointer_axis(void *data,
|
||||||
llua_mouse_hook(event);
|
llua_mouse_hook(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void seat_capability_listener (void *data, wl_seat *seat, uint32_t capability_int) {
|
static void seat_capability_listener(void *data, wl_seat *seat,
|
||||||
wl_seat_capability capabilities = static_cast<wl_seat_capability>(capability_int);
|
uint32_t capability_int) {
|
||||||
|
wl_seat_capability capabilities =
|
||||||
|
static_cast<wl_seat_capability>(capability_int);
|
||||||
if (wl_globals.seat == seat) {
|
if (wl_globals.seat == seat) {
|
||||||
if ((capabilities & WL_SEAT_CAPABILITY_POINTER) > 0) {
|
if ((capabilities & WL_SEAT_CAPABILITY_POINTER) > 0) {
|
||||||
wl_globals.pointer = wl_seat_get_pointer(seat);
|
wl_globals.pointer = wl_seat_get_pointer(seat);
|
||||||
|
|
||||||
static wl_pointer_listener listener {
|
static wl_pointer_listener listener{
|
||||||
.enter = on_pointer_enter,
|
.enter = on_pointer_enter,
|
||||||
.leave = on_pointer_leave,
|
.leave = on_pointer_leave,
|
||||||
.motion = on_pointer_motion,
|
.motion = on_pointer_motion,
|
||||||
.button = on_pointer_button,
|
.button = on_pointer_button,
|
||||||
.axis = on_pointer_axis,
|
.axis = on_pointer_axis,
|
||||||
};
|
};
|
||||||
wl_pointer_add_listener(wl_globals.pointer, &listener, data);
|
wl_pointer_add_listener(wl_globals.pointer, &listener, data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
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 */
|
#endif /* BUILD_MOUSE_EVENTS */
|
||||||
|
|
||||||
bool display_output_wayland::initialize() {
|
bool display_output_wayland::initialize() {
|
||||||
|
@ -619,13 +589,13 @@ bool display_output_wayland::initialize() {
|
||||||
zwlr_layer_surface_v1_add_listener(global_window->layer_surface,
|
zwlr_layer_surface_v1_add_listener(global_window->layer_surface,
|
||||||
&layer_surface_listener, nullptr);
|
&layer_surface_listener, nullptr);
|
||||||
|
|
||||||
#ifdef BUILD_MOUSE_EVENTS
|
#ifdef BUILD_MOUSE_EVENTS
|
||||||
wl_seat_listener listener {
|
wl_seat_listener listener{
|
||||||
.capabilities = seat_capability_listener,
|
.capabilities = seat_capability_listener,
|
||||||
.name = seat_name_listener,
|
.name = seat_name_listener,
|
||||||
};
|
};
|
||||||
wl_seat_add_listener(wl_globals.seat, &listener, global_window);
|
wl_seat_add_listener(wl_globals.seat, &listener, global_window);
|
||||||
#endif /* BUILD_MOUSE_EVENTS */
|
#endif /* BUILD_MOUSE_EVENTS */
|
||||||
|
|
||||||
wl_surface_commit(global_window->surface);
|
wl_surface_commit(global_window->surface);
|
||||||
wl_display_roundtrip(global_display);
|
wl_display_roundtrip(global_display);
|
||||||
|
@ -1046,8 +1016,8 @@ void display_output_wayland::load_fonts(bool utf8) {
|
||||||
// pango_fc_font_description_from_pattern requires a FAMILY to be set,
|
// pango_fc_font_description_from_pattern requires a FAMILY to be set,
|
||||||
// so set an empty one if none is present.
|
// so set an empty one if none is present.
|
||||||
FcValue dummy;
|
FcValue dummy;
|
||||||
if (FcPatternGet (fc_pattern, FC_FAMILY, 0, &dummy) != FcResultMatch) {
|
if (FcPatternGet(fc_pattern, FC_FAMILY, 0, &dummy) != FcResultMatch) {
|
||||||
FcPatternAddString (fc_pattern, FC_FAMILY, (FcChar8 *) "");
|
FcPatternAddString(fc_pattern, FC_FAMILY, (FcChar8 *)"");
|
||||||
}
|
}
|
||||||
pango_font_entry.desc =
|
pango_font_entry.desc =
|
||||||
pango_fc_font_description_from_pattern(fc_pattern, true);
|
pango_fc_font_description_from_pattern(fc_pattern, true);
|
||||||
|
|
|
@ -382,7 +382,7 @@ bool display_output_x11::main_loop_wait(double t) {
|
||||||
|
|
||||||
XNextEvent(display, &ev);
|
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
|
// no need to check whether these events have been consumed because
|
||||||
// they're global and shouldn't be propagated
|
// they're global and shouldn't be propagated
|
||||||
if (ev.type == GenericEvent && ev.xcookie.extension == window.xi_opcode) {
|
if (ev.type == GenericEvent && ev.xcookie.extension == window.xi_opcode) {
|
||||||
|
|
15
src/llua.cc
15
src/llua.cc
|
@ -210,9 +210,9 @@ void llua_init() {
|
||||||
#endif /* BUILD_X11 */
|
#endif /* BUILD_X11 */
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool file_exists (const char *path) {
|
inline bool file_exists(const char *path) {
|
||||||
struct stat buffer;
|
struct stat buffer;
|
||||||
return (stat (path, &buffer) == 0);
|
return (stat(path, &buffer) == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void llua_load(const char *script) {
|
void llua_load(const char *script) {
|
||||||
|
@ -522,14 +522,17 @@ bool llua_mouse_hook(const EventT &ev) {
|
||||||
} else {
|
} else {
|
||||||
hook_name = "conky_" + raw_hook_name;
|
hook_name = "conky_" + raw_hook_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ty = lua_getglobal(lua_L, hook_name.c_str());
|
int ty = lua_getglobal(lua_L, hook_name.c_str());
|
||||||
if (ty == LUA_TNIL) {
|
if (ty == LUA_TNIL) {
|
||||||
int ty_raw = lua_getglobal(lua_L, raw_hook_name.c_str());
|
int ty_raw = lua_getglobal(lua_L, raw_hook_name.c_str());
|
||||||
if (ty_raw == LUA_TFUNCTION) {
|
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.
|
// - 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;
|
hook_name = raw_hook_name;
|
||||||
ty = ty_raw;
|
ty = ty_raw;
|
||||||
lua_insert(lua_L, -2);
|
lua_insert(lua_L, -2);
|
||||||
|
|
|
@ -30,8 +30,8 @@
|
||||||
#ifndef _LOGGING_H
|
#ifndef _LOGGING_H
|
||||||
#define _LOGGING_H
|
#define _LOGGING_H
|
||||||
|
|
||||||
#include <cstdio>
|
|
||||||
#include <cinttypes>
|
#include <cinttypes>
|
||||||
|
#include <cstdio>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "i18n.h"
|
#include "i18n.h"
|
||||||
|
@ -82,9 +82,10 @@ void NORM_ERR(const char *format, Args &&...args) {
|
||||||
|
|
||||||
/* critical error with additional cleanup */
|
/* critical error with additional cleanup */
|
||||||
template <typename... Args>
|
template <typename... Args>
|
||||||
__attribute__((noreturn))
|
__attribute__((noreturn)) inline void CRIT_ERR_FREE(void *memtofree1,
|
||||||
inline void CRIT_ERR_FREE(void *memtofree1, void *memtofree2,
|
void *memtofree2,
|
||||||
const char *format, Args &&...args) {
|
const char *format,
|
||||||
|
Args &&...args) {
|
||||||
NORM_ERR(format, args...);
|
NORM_ERR(format, args...);
|
||||||
free(memtofree1);
|
free(memtofree1);
|
||||||
free(memtofree2);
|
free(memtofree2);
|
||||||
|
@ -94,8 +95,8 @@ inline void CRIT_ERR_FREE(void *memtofree1, void *memtofree2,
|
||||||
|
|
||||||
/* critical error */
|
/* critical error */
|
||||||
template <typename... Args>
|
template <typename... Args>
|
||||||
__attribute__((noreturn))
|
__attribute__((noreturn)) inline void CRIT_ERR(const char *format,
|
||||||
inline void CRIT_ERR(const char *format, Args &&...args) {
|
Args &&...args) {
|
||||||
CRIT_ERR_FREE(nullptr, nullptr, format, args...);
|
CRIT_ERR_FREE(nullptr, nullptr, format, args...);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,10 +20,10 @@
|
||||||
|
|
||||||
#include "mouse-events.h"
|
#include "mouse-events.h"
|
||||||
|
|
||||||
#include <array>
|
|
||||||
#include <string>
|
|
||||||
#include <lua.h>
|
#include <lua.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
#include <array>
|
||||||
|
#include <string>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include "logging.h"
|
#include "logging.h"
|
||||||
|
|
||||||
|
@ -35,11 +35,11 @@ void push_table_value(lua_State *L, std::string key, std::string value) {
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
typename std::enable_if<std::is_integral<T>::value>::type
|
typename std::enable_if<std::is_integral<T>::value>::type push_table_value(
|
||||||
push_table_value(lua_State *L, std::string key, T value) {
|
lua_State *L, std::string key, T value) {
|
||||||
lua_pushstring(L, key.c_str());
|
lua_pushstring(L, key.c_str());
|
||||||
lua_pushinteger(L, value);
|
lua_pushinteger(L, value);
|
||||||
lua_settable(L, -3);
|
lua_settable(L, -3);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
@ -64,12 +64,12 @@ void push_bitset(lua_State *L, std::bitset<N> it,
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::array<std::string, 6> mod_names = {{
|
const std::array<std::string, 6> mod_names = {{
|
||||||
"shift",
|
"shift",
|
||||||
"control",
|
"control",
|
||||||
"alt",
|
"alt",
|
||||||
"super",
|
"super",
|
||||||
"caps_lock",
|
"caps_lock",
|
||||||
"num_lock",
|
"num_lock",
|
||||||
}};
|
}};
|
||||||
|
|
||||||
void push_mods(lua_State *L, modifier_state_t mods) {
|
void push_mods(lua_State *L, modifier_state_t mods) {
|
||||||
|
@ -80,9 +80,10 @@ void push_mods(lua_State *L, modifier_state_t mods) {
|
||||||
|
|
||||||
// Returns ms since Epoch.
|
// Returns ms since Epoch.
|
||||||
inline size_t current_time_ms() {
|
inline size_t current_time_ms() {
|
||||||
struct timespec spec;
|
struct timespec spec;
|
||||||
clock_gettime(CLOCK_REALTIME, &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) {
|
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);
|
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());
|
lua_pushstring(L, key.c_str());
|
||||||
switch (direction) {
|
switch (direction) {
|
||||||
case SCROLL_DOWN:
|
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);
|
lua_settable(L, -3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void push_table_value(lua_State *L, std::string key, mouse_button_t button) {
|
void push_table_value(lua_State *L, std::string key, mouse_button_t button) {
|
||||||
lua_pushstring(L, key.c_str());
|
lua_pushstring(L, key.c_str());
|
||||||
switch (button) {
|
switch (button) {
|
||||||
|
@ -162,7 +163,8 @@ void push_table_value(lua_State *L, std::string key, mouse_button_t button) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Class methods */
|
/* 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 {
|
void mouse_event::push_lua_table(lua_State *L) const {
|
||||||
lua_newtable(L);
|
lua_newtable(L);
|
||||||
|
|
|
@ -22,8 +22,8 @@
|
||||||
#define MOUSE_EVENTS_H
|
#define MOUSE_EVENTS_H
|
||||||
|
|
||||||
#include <bitset>
|
#include <bitset>
|
||||||
#include <string>
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "logging.h"
|
#include "logging.h"
|
||||||
|
@ -57,19 +57,19 @@ enum mouse_event_t {
|
||||||
// above list if it has other event codes or a standard file containing them.
|
// above list if it has other event codes or a standard file containing them.
|
||||||
|
|
||||||
// Left mouse button event code
|
// Left mouse button event code
|
||||||
#define BTN_LEFT 0x110
|
#define BTN_LEFT 0x110
|
||||||
// Right mouse button event code
|
// Right mouse button event code
|
||||||
#define BTN_RIGHT 0x111
|
#define BTN_RIGHT 0x111
|
||||||
// Middle mouse button event code
|
// Middle mouse button event code
|
||||||
#define BTN_MIDDLE 0x112
|
#define BTN_MIDDLE 0x112
|
||||||
|
|
||||||
// Back mouse button event code
|
// Back mouse button event code
|
||||||
#define BTN_BACK 0x116
|
#define BTN_BACK 0x116
|
||||||
// Forward mouse button event code
|
// Forward mouse button event code
|
||||||
#define BTN_FORWARD 0x115
|
#define BTN_FORWARD 0x115
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
enum mouse_button_t: uint32_t {
|
enum mouse_button_t : uint32_t {
|
||||||
BUTTON_LEFT = BTN_LEFT,
|
BUTTON_LEFT = BTN_LEFT,
|
||||||
BUTTON_RIGHT = BTN_RIGHT,
|
BUTTON_RIGHT = BTN_RIGHT,
|
||||||
BUTTON_MIDDLE = BTN_MIDDLE,
|
BUTTON_MIDDLE = BTN_MIDDLE,
|
||||||
|
@ -105,8 +105,8 @@ inline mouse_button_t x11_mouse_button_code(unsigned int x11_mouse_button) {
|
||||||
#endif /* BUILD_X11 */
|
#endif /* BUILD_X11 */
|
||||||
|
|
||||||
struct mouse_event {
|
struct mouse_event {
|
||||||
mouse_event_t type; // type of event
|
mouse_event_t type; // type of event
|
||||||
size_t time; // ms since epoch when the event happened
|
size_t time; // ms since epoch when the event happened
|
||||||
|
|
||||||
explicit mouse_event(mouse_event_t type);
|
explicit mouse_event(mouse_event_t type);
|
||||||
|
|
||||||
|
@ -119,13 +119,15 @@ struct mouse_positioned_event : public mouse_event {
|
||||||
size_t x = 0, y = 0; // position relative to window
|
size_t x = 0, y = 0; // position relative to window
|
||||||
size_t x_abs = 0, y_abs = 0; // position relative to root
|
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;
|
void push_lua_data(lua_State *L) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::bitset<6> modifier_state_t;
|
typedef std::bitset<6> modifier_state_t;
|
||||||
enum modifier_key: uint32_t {
|
enum modifier_key : uint32_t {
|
||||||
MOD_SHIFT = 0,
|
MOD_SHIFT = 0,
|
||||||
MOD_CONTROL = 1,
|
MOD_CONTROL = 1,
|
||||||
MOD_ALT = 2,
|
MOD_ALT = 2,
|
||||||
|
@ -138,26 +140,29 @@ std::string modifier_name(modifier_key key);
|
||||||
|
|
||||||
#ifdef BUILD_X11
|
#ifdef BUILD_X11
|
||||||
inline modifier_state_t x11_modifier_state(unsigned int mods) {
|
inline modifier_state_t x11_modifier_state(unsigned int mods) {
|
||||||
modifier_state_t result;
|
modifier_state_t result;
|
||||||
result[MOD_SHIFT] = mods & ShiftMask;
|
result[MOD_SHIFT] = mods & ShiftMask;
|
||||||
result[MOD_CONTROL] = mods & ControlMask;
|
result[MOD_CONTROL] = mods & ControlMask;
|
||||||
result[MOD_ALT] = mods & Mod1Mask;
|
result[MOD_ALT] = mods & Mod1Mask;
|
||||||
result[MOD_SUPER] = mods & Mod4Mask;
|
result[MOD_SUPER] = mods & Mod4Mask;
|
||||||
result[MOD_CAPS_LOCK] = mods & LockMask;
|
result[MOD_CAPS_LOCK] = mods & LockMask;
|
||||||
result[MOD_NUM_LOCK] = mods & Mod2Mask;
|
result[MOD_NUM_LOCK] = mods & Mod2Mask;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
#endif /* BUILD_X11 */
|
#endif /* BUILD_X11 */
|
||||||
|
|
||||||
struct mouse_move_event : public mouse_positioned_event {
|
struct mouse_move_event : public mouse_positioned_event {
|
||||||
modifier_state_t mods; // held buttons and modifiers (ctrl, shift, ...)
|
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;
|
void push_lua_data(lua_State *L) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum scroll_direction_t: uint8_t {
|
enum scroll_direction_t : uint8_t {
|
||||||
SCROLL_UNKNOWN = 0,
|
SCROLL_UNKNOWN = 0,
|
||||||
SCROLL_UP,
|
SCROLL_UP,
|
||||||
SCROLL_DOWN,
|
SCROLL_DOWN,
|
||||||
|
@ -190,7 +195,11 @@ struct mouse_scroll_event : public mouse_positioned_event {
|
||||||
modifier_state_t mods; // held buttons and modifiers (ctrl, shift, ...)
|
modifier_state_t mods; // held buttons and modifiers (ctrl, shift, ...)
|
||||||
scroll_direction_t direction;
|
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;
|
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, ...)
|
modifier_state_t mods; // held buttons and modifiers (ctrl, shift, ...)
|
||||||
mouse_button_t button;
|
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;
|
void push_lua_data(lua_State *L) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct mouse_crossing_event : public mouse_positioned_event {
|
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 */
|
#endif /* MOUSE_EVENTS_H */
|
||||||
|
|
139
src/x11.cc
139
src/x11.cc
|
@ -27,21 +27,22 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "x11.h"
|
||||||
|
|
||||||
#include <X11/X.h>
|
#include <X11/X.h>
|
||||||
#include <X11/extensions/XI2.h>
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "conky.h"
|
#include "conky.h"
|
||||||
|
#include "gui.h"
|
||||||
#include "logging.h"
|
#include "logging.h"
|
||||||
#include "x11.h"
|
|
||||||
|
|
||||||
|
#include <array>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstring>
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
#include <cstring>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <array>
|
|
||||||
|
|
||||||
#pragma GCC diagnostic push
|
#pragma GCC diagnostic push
|
||||||
#pragma GCC diagnostic ignored "-Wvariadic-macros"
|
#pragma GCC diagnostic ignored "-Wvariadic-macros"
|
||||||
|
@ -52,7 +53,7 @@
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
#include <X11/Xmd.h>
|
#include <X11/Xmd.h>
|
||||||
#include <X11/Xutil.h>
|
#include <X11/Xutil.h>
|
||||||
#include "gui.h"
|
|
||||||
#ifdef BUILD_IMLIB2
|
#ifdef BUILD_IMLIB2
|
||||||
#include "imlib2.h"
|
#include "imlib2.h"
|
||||||
#endif /* BUILD_IMLIB2 */
|
#endif /* BUILD_IMLIB2 */
|
||||||
|
@ -72,8 +73,8 @@
|
||||||
#include <X11/extensions/Xfixes.h>
|
#include <X11/extensions/Xfixes.h>
|
||||||
#endif /* BUILD_XFIXES */
|
#endif /* BUILD_XFIXES */
|
||||||
#ifdef BUILD_XINPUT
|
#ifdef BUILD_XINPUT
|
||||||
#include <vector>
|
|
||||||
#include <X11/extensions/XInput2.h>
|
#include <X11/extensions/XInput2.h>
|
||||||
|
#include <vector>
|
||||||
#endif /* BUILD_XINPUT */
|
#endif /* BUILD_XINPUT */
|
||||||
#ifdef HAVE_XCB_ERRORS
|
#ifdef HAVE_XCB_ERRORS
|
||||||
#include <xcb/xcb.h>
|
#include <xcb/xcb.h>
|
||||||
|
@ -83,7 +84,6 @@
|
||||||
/* some basic X11 stuff */
|
/* some basic X11 stuff */
|
||||||
Display *display = nullptr;
|
Display *display = nullptr;
|
||||||
|
|
||||||
|
|
||||||
#ifdef HAVE_XCB_ERRORS
|
#ifdef HAVE_XCB_ERRORS
|
||||||
xcb_connection_t *xcb_connection;
|
xcb_connection_t *xcb_connection;
|
||||||
xcb_errors_context_t *xcb_errors_ctx;
|
xcb_errors_context_t *xcb_errors_ctx;
|
||||||
|
@ -239,79 +239,78 @@ imlib_cache_size_setting imlib_cache_size;
|
||||||
/******************** </SETTINGS> ************************/
|
/******************** </SETTINGS> ************************/
|
||||||
|
|
||||||
/* WARNING, this type not in Xlib spec */
|
/* WARNING, this type not in Xlib spec */
|
||||||
static int
|
static int x11_error_handler(Display *d, XErrorEvent *err) {
|
||||||
x11_error_handler(Display *d, XErrorEvent *err) {
|
|
||||||
char *error_name = nullptr;
|
char *error_name = nullptr;
|
||||||
bool name_allocated = false;
|
bool name_allocated = false;
|
||||||
|
|
||||||
char *code_description = nullptr;
|
char *code_description = nullptr;
|
||||||
bool code_allocated = false;
|
bool code_allocated = false;
|
||||||
|
|
||||||
#ifdef HAVE_XCB_ERRORS
|
#ifdef HAVE_XCB_ERRORS
|
||||||
if (xcb_errors_ctx != nullptr) {
|
if (xcb_errors_ctx != nullptr) {
|
||||||
const char *extension;
|
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(
|
||||||
if (extension != nullptr) {
|
xcb_errors_ctx, err->error_code, &extension);
|
||||||
const size_t size = strlen(base_name) + strlen(extension) + 4;
|
if (extension != nullptr) {
|
||||||
error_name = new char(size);
|
const size_t size = strlen(base_name) + strlen(extension) + 4;
|
||||||
snprintf(error_name, size, "%s (%s)", base_name, extension);
|
error_name = new char(size);
|
||||||
name_allocated = true;
|
snprintf(error_name, size, "%s (%s)", base_name, extension);
|
||||||
} else {
|
name_allocated = true;
|
||||||
error_name = const_cast<char*>(base_name);
|
} else {
|
||||||
}
|
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);
|
|
||||||
if (minor != nullptr) {
|
|
||||||
const size_t size = strlen(base_name) + strlen(extension) + 4;
|
|
||||||
code_description = new char(size);
|
|
||||||
snprintf(code_description, size, "%s - %s", major, minor);
|
|
||||||
code_allocated = true;
|
|
||||||
} else {
|
|
||||||
code_description = const_cast<char*>(major);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
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);
|
||||||
|
snprintf(code_description, size, "%s - %s", major, minor);
|
||||||
|
code_allocated = true;
|
||||||
|
} else {
|
||||||
|
code_description = const_cast<char *>(major);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (error_name == nullptr) {
|
if (error_name == nullptr) {
|
||||||
if (err->error_code > 0 && err->error_code < 17) {
|
if (err->error_code > 0 && err->error_code < 17) {
|
||||||
static std::array<std::string, 17> NAMES = {
|
static std::array<std::string, 17> NAMES = {
|
||||||
"request", "value", "window", "pixmap", "atom", "cursor", "font", "match",
|
"request", "value", "window", "pixmap", "atom",
|
||||||
"drawable", "access", "alloc", "colormap", "G context", "ID choice",
|
"cursor", "font", "match", "drawable", "access",
|
||||||
"name", "length", "implementation"
|
"alloc", "colormap", "G context", "ID choice", "name",
|
||||||
};
|
"length", "implementation"};
|
||||||
error_name = const_cast<char*>(NAMES[err->error_code].c_str());
|
error_name = const_cast<char *>(NAMES[err->error_code].c_str());
|
||||||
} else {
|
} else {
|
||||||
static char code_name_buffer[4];
|
static char code_name_buffer[4];
|
||||||
error_name = reinterpret_cast<char*>(&code_name_buffer);
|
error_name = reinterpret_cast<char *>(&code_name_buffer);
|
||||||
snprintf(error_name, 3, "%d", err->error_code);
|
snprintf(error_name, 3, "%d", err->error_code);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (code_description == nullptr) {
|
if (code_description == nullptr) {
|
||||||
const size_t size = 37;
|
const size_t size = 37;
|
||||||
code_description = new char(size);
|
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;
|
code_allocated = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
DBGP(
|
DBGP(
|
||||||
"X %s Error:\n"
|
"X %s Error:\n"
|
||||||
"Display: %lx, XID: %li, Serial: %lu\n"
|
"Display: %lx, XID: %li, Serial: %lu\n"
|
||||||
"%s",
|
"%s",
|
||||||
error_name,
|
error_name, reinterpret_cast<uint64_t>(err->display),
|
||||||
reinterpret_cast<uint64_t>(err->display),
|
static_cast<int64_t>(err->resourceid), err->serial, code_description);
|
||||||
static_cast<int64_t>(err->resourceid), err->serial,
|
|
||||||
code_description
|
|
||||||
);
|
|
||||||
|
|
||||||
if (name_allocated) free(error_name);
|
if (name_allocated) free(error_name);
|
||||||
if (code_allocated) free(code_description);
|
if (code_allocated) free(code_description);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
__attribute__((noreturn))
|
__attribute__((noreturn)) static int x11_ioerror_handler(Display *d) {
|
||||||
static int x11_ioerror_handler(Display *d) {
|
|
||||||
CRIT_ERR("X IO Error: Display %lx\n", reinterpret_cast<uint64_t>(d));
|
CRIT_ERR("X IO Error: Display %lx\n", reinterpret_cast<uint64_t>(d));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -351,15 +350,15 @@ static void init_x11() {
|
||||||
|
|
||||||
update_workarea();
|
update_workarea();
|
||||||
|
|
||||||
#ifdef HAVE_XCB_ERRORS
|
#ifdef HAVE_XCB_ERRORS
|
||||||
auto connection = xcb_connect(NULL, NULL);
|
auto connection = xcb_connect(NULL, NULL);
|
||||||
if (!xcb_connection_has_error(connection)) {
|
if (!xcb_connection_has_error(connection)) {
|
||||||
if (xcb_errors_context_new(connection, &xcb_errors_ctx) != Success) {
|
if (xcb_errors_context_new(connection, &xcb_errors_ctx) != Success) {
|
||||||
xcb_errors_ctx = nullptr;
|
xcb_errors_ctx = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* HAVE_XCB_ERRORS */
|
#endif /* HAVE_XCB_ERRORS */
|
||||||
|
|
||||||
/* WARNING, this type not in Xlib spec */
|
/* WARNING, this type not in Xlib spec */
|
||||||
XSetErrorHandler(&x11_error_handler);
|
XSetErrorHandler(&x11_error_handler);
|
||||||
XSetIOErrorHandler(&x11_ioerror_handler);
|
XSetIOErrorHandler(&x11_ioerror_handler);
|
||||||
|
@ -960,9 +959,10 @@ void x11_init_window(lua::state &l, bool own) {
|
||||||
}
|
}
|
||||||
bool xinput_ok = false;
|
bool xinput_ok = false;
|
||||||
#ifdef BUILD_XINPUT
|
#ifdef BUILD_XINPUT
|
||||||
do { // not loop
|
do { // not loop
|
||||||
int _ignored; // segfault if NULL
|
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
|
// events will still ~work but let the user know why they're buggy
|
||||||
NORM_ERR("XInput extension is not supported by X11!");
|
NORM_ERR("XInput extension is not supported by X11!");
|
||||||
break;
|
break;
|
||||||
|
@ -976,7 +976,7 @@ void x11_init_window(lua::state &l, bool own) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const size_t mask_size = (XI_LASTEVENT + 7) / 8;
|
const size_t mask_size = (XI_LASTEVENT + 7) / 8;
|
||||||
unsigned char mask_bytes[mask_size] = {0}; /* must be zeroed! */
|
unsigned char mask_bytes[mask_size] = {0}; /* must be zeroed! */
|
||||||
XISetMask(mask_bytes, XI_Motion);
|
XISetMask(mask_bytes, XI_Motion);
|
||||||
|
|
||||||
XIEventMask ev_masks[1];
|
XIEventMask ev_masks[1];
|
||||||
|
@ -1356,10 +1356,10 @@ void print_mouse_speed(struct text_object *obj, char *p,
|
||||||
}
|
}
|
||||||
|
|
||||||
InputEvent *xev_as_input_event(XEvent &ev) {
|
InputEvent *xev_as_input_event(XEvent &ev) {
|
||||||
if (ev.type == KeyPress || ev.type == KeyRelease ||
|
if (ev.type == KeyPress || ev.type == KeyRelease || ev.type == ButtonPress ||
|
||||||
ev.type == ButtonPress || ev.type == ButtonRelease || ev.type == MotionNotify ||
|
ev.type == ButtonRelease || ev.type == MotionNotify ||
|
||||||
ev.type == EnterNotify || ev.type == LeaveNotify) {
|
ev.type == EnterNotify || ev.type == LeaveNotify) {
|
||||||
return reinterpret_cast<InputEvent*>(&ev);
|
return reinterpret_cast<InputEvent *>(&ev);
|
||||||
} else {
|
} else {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -1380,9 +1380,7 @@ void propagate_x11_event(XEvent &ev) {
|
||||||
XGetInputFocus(display, &focused, &_revert_to);
|
XGetInputFocus(display, &focused, &_revert_to);
|
||||||
if (focused == window.window) {
|
if (focused == window.window) {
|
||||||
Time time = CurrentTime;
|
Time time = CurrentTime;
|
||||||
if (i_ev != nullptr) {
|
if (i_ev != nullptr) { time = i_ev->common.time; }
|
||||||
time = i_ev->common.time;
|
|
||||||
}
|
|
||||||
XSetInputFocus(display, window.desktop, RevertToPointerRoot, time);
|
XSetInputFocus(display, window.desktop, RevertToPointerRoot, time);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1390,13 +1388,15 @@ void propagate_x11_event(XEvent &ev) {
|
||||||
#ifdef BUILD_MOUSE_EVENTS
|
#ifdef BUILD_MOUSE_EVENTS
|
||||||
// Assuming parent has a simple linear stack of descendants, this function
|
// Assuming parent has a simple linear stack of descendants, this function
|
||||||
// returns the last leaf on the graph.
|
// returns the last leaf on the graph.
|
||||||
inline Window last_descendant(Display* display, Window parent) {
|
inline Window last_descendant(Display *display, Window parent) {
|
||||||
Window _ignored, *children;
|
Window _ignored, *children;
|
||||||
uint32_t count;
|
uint32_t count;
|
||||||
|
|
||||||
Window current = 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];
|
current = children[count - 1];
|
||||||
XFree(children);
|
XFree(children);
|
||||||
}
|
}
|
||||||
|
@ -1404,7 +1404,7 @@ inline Window last_descendant(Display* display, Window parent) {
|
||||||
return current;
|
return current;
|
||||||
}
|
}
|
||||||
|
|
||||||
Window query_x11_window_at_pos(Display* display, int x, int y) {
|
Window query_x11_window_at_pos(Display *display, int x, int y) {
|
||||||
Window root = DefaultRootWindow(display);
|
Window root = DefaultRootWindow(display);
|
||||||
|
|
||||||
// these values are ignored but NULL can't be passed
|
// these values are ignored but NULL can't be passed
|
||||||
|
@ -1413,9 +1413,8 @@ Window query_x11_window_at_pos(Display* display, int x, int y) {
|
||||||
unsigned int mask_return;
|
unsigned int mask_return;
|
||||||
|
|
||||||
Window last = None;
|
Window last = None;
|
||||||
XQueryPointer(display, window.root, &root_return, &last,
|
XQueryPointer(display, window.root, &root_return, &last, &root_x_return,
|
||||||
&root_x_return, &root_y_return, &win_x_return, &win_y_return, &mask_return
|
&root_y_return, &win_x_return, &win_y_return, &mask_return);
|
||||||
);
|
|
||||||
|
|
||||||
// X11 correctly returns a window which covers conky area, but returned window
|
// 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
|
// is not window.window, but instead a parent node in some cases and the
|
||||||
|
|
22
src/x11.h
22
src/x11.h
|
@ -24,20 +24,21 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "setting.hh"
|
||||||
|
|
||||||
#include <X11/Xatom.h>
|
#include <X11/Xatom.h>
|
||||||
#pragma GCC diagnostic push
|
#pragma GCC diagnostic push
|
||||||
#pragma GCC diagnostic ignored "-Wvariadic-macros"
|
#pragma GCC diagnostic ignored "-Wvariadic-macros"
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
#pragma GCC diagnostic pop
|
#pragma GCC diagnostic pop
|
||||||
|
|
||||||
#ifdef BUILD_XFT
|
#ifdef BUILD_XFT
|
||||||
#include <X11/Xft/Xft.h>
|
#include <X11/Xft/Xft.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef BUILD_XDBE
|
#ifdef BUILD_XDBE
|
||||||
#include <X11/extensions/Xdbe.h>
|
#include <X11/extensions/Xdbe.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "setting.hh"
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
#ifdef BUILD_ARGB
|
#ifdef BUILD_ARGB
|
||||||
|
@ -130,28 +131,29 @@ struct InputEventCommon {
|
||||||
};
|
};
|
||||||
|
|
||||||
union InputEvent {
|
union InputEvent {
|
||||||
int type; // event type
|
int type; // event type
|
||||||
|
|
||||||
InputEventCommon common;
|
InputEventCommon common;
|
||||||
|
|
||||||
// Discrete interfaces
|
// Discrete interfaces
|
||||||
XAnyEvent xany; // common event interface
|
XAnyEvent xany; // common event interface
|
||||||
XKeyEvent xkey; // KeyPress & KeyRelease events
|
XKeyEvent xkey; // KeyPress & KeyRelease events
|
||||||
XButtonEvent xbutton; // ButtonPress & ButtonRelease events
|
XButtonEvent xbutton; // ButtonPress & ButtonRelease events
|
||||||
XMotionEvent xmotion; // MotionNotify event
|
XMotionEvent xmotion; // MotionNotify event
|
||||||
XCrossingEvent xcrossing; // EnterNotify & LeaveNotify events
|
XCrossingEvent xcrossing; // EnterNotify & LeaveNotify events
|
||||||
|
|
||||||
// Ensures InputEvent matches memory layout of XEvent.
|
// Ensures InputEvent matches memory layout of XEvent.
|
||||||
// Accessing base variant is as code smell.
|
// Accessing base variant is as code smell.
|
||||||
XEvent base;
|
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);
|
InputEvent *xev_as_input_event(XEvent &ev);
|
||||||
void propagate_x11_event(XEvent &ev);
|
void propagate_x11_event(XEvent &ev);
|
||||||
|
|
||||||
#ifdef BUILD_MOUSE_EVENTS
|
#ifdef BUILD_MOUSE_EVENTS
|
||||||
Window query_x11_window_at_pos(Display* display, int x, int y);
|
Window query_x11_window_at_pos(Display *display, int x, int y);
|
||||||
#endif /* BUILD_MOUSE_EVENTS */
|
#endif /* BUILD_MOUSE_EVENTS */
|
||||||
|
|
||||||
#ifdef BUILD_XDBE
|
#ifdef BUILD_XDBE
|
||||||
|
|
Loading…
Reference in New Issue