1
0
Fork 0
mirror of https://github.com/yshui/picom.git synced 2024-11-18 13:55:36 -05:00

dbus: add stubs for when dbus support is disabled

So we can reduce the number of ifdefs used.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
Yuxuan Shui 2024-03-23 13:48:40 +00:00
parent 9a29e465a3
commit 5b3b72403e
No known key found for this signature in database
GPG key ID: D3A4405BE6CC17F4
5 changed files with 38 additions and 56 deletions

View file

@ -501,17 +501,6 @@ static inline bool wid_has_prop(xcb_connection_t *c, xcb_window_t w, xcb_atom_t
void force_repaint(session_t *ps); void force_repaint(session_t *ps);
/** @name DBus handling
*/
///@{
#ifdef CONFIG_DBUS
/** @name DBus hooks
*/
///@{
void opts_set_no_fading_openclose(session_t *ps, bool newval);
//!@}
#endif
/** /**
* Set a <code>bool</code> array of all wintypes to true. * Set a <code>bool</code> array of all wintypes to true.
*/ */

View file

@ -1322,7 +1322,7 @@ static bool cdbus_process_opts_set(session_t *ps, DBusMessage *msg) {
if (!cdbus_msg_get_arg(msg, 1, DBUS_TYPE_BOOLEAN, &val)) { if (!cdbus_msg_get_arg(msg, 1, DBUS_TYPE_BOOLEAN, &val)) {
return false; return false;
} }
opts_set_no_fading_openclose(ps, val); ps->o.no_fading_openclose = val;
goto cdbus_process_opts_set_success; goto cdbus_process_opts_set_success;
} }

View file

@ -11,11 +11,11 @@
#include <stdbool.h> #include <stdbool.h>
#include <dbus/dbus.h>
typedef struct session session_t; typedef struct session session_t;
struct win; struct win;
#ifdef CONFIG_DBUS
#include <dbus/dbus.h>
/** /**
* Return a string representation of a D-Bus message type. * Return a string representation of a D-Bus message type.
*/ */
@ -51,4 +51,29 @@ void cdbus_ev_win_focusout(session_t *ps, struct win *w);
/// Generate dbus win_focusin signal /// Generate dbus win_focusin signal
void cdbus_ev_win_focusin(session_t *ps, struct win *w); void cdbus_ev_win_focusin(session_t *ps, struct win *w);
#else
static inline void
cdbus_ev_win_unmapped(session_t *ps attr_unused, struct win *w attr_unused) {
}
static inline void cdbus_ev_win_mapped(session_t *ps attr_unused, struct win *w attr_unused) {
}
static inline void
cdbus_ev_win_destroyed(session_t *ps attr_unused, struct win *w attr_unused) {
}
static inline void cdbus_ev_win_added(session_t *ps attr_unused, struct win *w attr_unused) {
}
static inline void
cdbus_ev_win_focusout(session_t *ps attr_unused, struct win *w attr_unused) {
}
static inline void cdbus_ev_win_focusin(session_t *ps attr_unused, struct win *w attr_unused) {
}
#endif
// vim: set noet sw=8 ts=8 : // vim: set noet sw=8 ts=8 :

View file

@ -53,27 +53,25 @@
#ifdef CONFIG_OPENGL #ifdef CONFIG_OPENGL
#include "opengl.h" #include "opengl.h"
#endif #endif
#include "atom.h"
#include "backend/backend.h" #include "backend/backend.h"
#include "c2.h" #include "c2.h"
#include "diagnostic.h"
#include "log.h"
#include "region.h"
#include "render.h"
#include "types.h"
#include "utils.h"
#include "win.h"
#include "x.h"
#ifdef CONFIG_DBUS
#include "dbus.h" #include "dbus.h"
#endif #include "diagnostic.h"
#include "atom.h"
#include "event.h" #include "event.h"
#include "file_watch.h" #include "file_watch.h"
#include "list.h" #include "list.h"
#include "log.h"
#include "options.h" #include "options.h"
#include "region.h"
#include "render.h"
#include "statistics.h" #include "statistics.h"
#include "types.h"
#include "uthash_extra.h" #include "uthash_extra.h"
#include "utils.h"
#include "vblank.h" #include "vblank.h"
#include "win.h"
#include "x.h"
/// Get session_t pointer from a pointer to a member of session_t /// Get session_t pointer from a pointer to a member of session_t
#define session_ptr(ptr, member) \ #define session_ptr(ptr, member) \
@ -1232,23 +1230,6 @@ void force_repaint(session_t *ps) {
add_damage(ps, &ps->screen_reg); add_damage(ps, &ps->screen_reg);
} }
#ifdef CONFIG_DBUS
/** @name DBus hooks
*/
///@{
/**
* Set no_fading_openclose option.
*
* Don't affect fading already in progress
*/
void opts_set_no_fading_openclose(session_t *ps, bool newval) {
ps->o.no_fading_openclose = newval;
}
//!@}
#endif
/** /**
* Setup window properties, then register us with the compositor selection (_NET_WM_CM_S) * Setup window properties, then register us with the compositor selection (_NET_WM_CM_S)
* *
@ -1692,12 +1673,10 @@ static void handle_new_windows(session_t *ps) {
// us to find out. So just blindly mark it damaged // us to find out. So just blindly mark it damaged
mw->ever_damaged = true; mw->ever_damaged = true;
} }
#ifdef CONFIG_DBUS
// Send D-Bus signal // Send D-Bus signal
if (ps->o.dbus) { if (ps->o.dbus) {
cdbus_ev_win_added(ps, new_w); cdbus_ev_win_added(ps, new_w);
} }
#endif
} }
} }
} }

View file

@ -21,6 +21,7 @@
#include "common.h" #include "common.h"
#include "compiler.h" #include "compiler.h"
#include "config.h" #include "config.h"
#include "dbus.h"
#include "list.h" #include "list.h"
#include "log.h" #include "log.h"
#include "picom.h" #include "picom.h"
@ -34,10 +35,6 @@
#include "win_defs.h" #include "win_defs.h"
#include "x.h" #include "x.h"
#ifdef CONFIG_DBUS
#include "dbus.h"
#endif
#ifdef CONFIG_OPENGL #ifdef CONFIG_OPENGL
// TODO(yshui) Get rid of this include // TODO(yshui) Get rid of this include
#include "opengl.h" #include "opengl.h"
@ -1957,7 +1954,6 @@ static void win_on_focus_change(session_t *ps, struct managed_win *w) {
// Update everything related to conditions // Update everything related to conditions
win_on_factor_change(ps, w); win_on_factor_change(ps, w);
#ifdef CONFIG_DBUS
// Send D-Bus signal // Send D-Bus signal
if (ps->o.dbus) { if (ps->o.dbus) {
if (win_is_focused_raw(w)) { if (win_is_focused_raw(w)) {
@ -1966,7 +1962,6 @@ static void win_on_focus_change(session_t *ps, struct managed_win *w) {
cdbus_ev_win_focusout(ps, &w->base); cdbus_ev_win_focusout(ps, &w->base);
} }
} }
#endif
} }
/** /**
@ -2392,12 +2387,10 @@ void destroy_win_start(session_t *ps, struct win *w) {
} }
// don't need win_ev_stop because the window is gone anyway // don't need win_ev_stop because the window is gone anyway
#ifdef CONFIG_DBUS
// Send D-Bus signal // Send D-Bus signal
if (ps->o.dbus) { if (ps->o.dbus) {
cdbus_ev_win_destroyed(ps, w); cdbus_ev_win_destroyed(ps, w);
} }
#endif
if (!ps->redirected && w->managed) { if (!ps->redirected && w->managed) {
// Skip transition if we are not rendering // Skip transition if we are not rendering
@ -2429,12 +2422,10 @@ void unmap_win_start(session_t *ps, struct managed_win *w) {
w->state = WSTATE_UNMAPPED; w->state = WSTATE_UNMAPPED;
win_start_fade(ps, w, 0); win_start_fade(ps, w, 0);
#ifdef CONFIG_DBUS
// Send D-Bus signal // Send D-Bus signal
if (ps->o.dbus) { if (ps->o.dbus) {
cdbus_ev_win_unmapped(ps, &w->base); cdbus_ev_win_unmapped(ps, &w->base);
} }
#endif
if (!ps->redirected || !w->ever_damaged) { if (!ps->redirected || !w->ever_damaged) {
// If we are not redirected, we skip fading because we aren't // If we are not redirected, we skip fading because we aren't
@ -2517,12 +2508,10 @@ void map_win_start(session_t *ps, struct managed_win *w) {
log_debug("Window %#010x has opacity %f, opacity target is %f", w->base.id, log_debug("Window %#010x has opacity %f, opacity target is %f", w->base.id,
animatable_get(&w->opacity), w->opacity.target); animatable_get(&w->opacity), w->opacity.target);
#ifdef CONFIG_DBUS
// Send D-Bus signal // Send D-Bus signal
if (ps->o.dbus) { if (ps->o.dbus) {
cdbus_ev_win_mapped(ps, &w->base); cdbus_ev_win_mapped(ps, &w->base);
} }
#endif
if (!ps->redirected) { if (!ps->redirected) {
win_skip_fading(w); win_skip_fading(w);