Skip to content

Commit

Permalink
Feature chjj#80: D-Bus support
Browse files Browse the repository at this point in the history
- Add D-Bus support. Currently 7 methods are available: "reset" (same as
  SIGUSR1), "list_win" (list the windows compton manages), "win_get"
  (get a property of the window), "win_set" (set a property of the
  window), "find_win" (find window based on client window / focus),
  "opts_get" (get the value of a compton option), and "opts_set" (set
  the value of a compton option), together with 4 signals: "win_added",
  "win_destroyed", "win_mapped", "win_unmapped".

- D-Bus support depends on libdbus.

- As there are many items and my time is tight, no much tests are done.
  Bugs to be expected.

- Create a new header file `common.h` that contains shared content.

- Fix some bugs in timeout handling.

- Update file headers in all source files.

- Re-enable --unredir-if-possible on multi-screen set-ups, as the user
  could turn if off manually anyway.

- Check if the window is mapped in `repair_win()`.

- Add ps->track_atom_lst and its handlers, to prepare for the new
  condition format.

- Known issue 1: "win_get", "win_set", "opts_get", "opts_set" support a
  very limited number of targets only. New ones will be added gradually.

- Known issue 2: Accidental drop of D-Bus connection is not handled.

- Known issue 3: Introspection does not reveal all available methods,
  because some methods have unpredictable prototypes. Still hesitating
  about what to do...

- Known issue 4: Error handling is not finished yet. Compton does not
  always reply with the correct error message (but it does print out the
  correct error message, usually).
  • Loading branch information
richardgv committed Jan 19, 2013
1 parent e60fe72 commit 58c0ece
Show file tree
Hide file tree
Showing 8 changed files with 2,715 additions and 1,280 deletions.
14 changes: 8 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ PACKAGES = x11 xcomposite xfixes xdamage xrender xext xrandr
LIBS = -lm -lrt
INCS =

OBJS = compton.o

# === Configuration flags ===
CFG =

Expand Down Expand Up @@ -46,10 +48,11 @@ ifeq "$(NO_VSYNC_OPENGL)" ""
endif

# ==== D-Bus ====
# ifeq "$(NO_DBUS)" ""
# CFG += -DCONFIG_DBUS
# PACKAGES += dbus-1
# endif
ifeq "$(NO_DBUS)" ""
CFG += -DCONFIG_DBUS
PACKAGES += dbus-1
OBJS += dbus.o
endif

# === Version string ===
COMPTON_VERSION ?= git-$(shell git describe --always --dirty)-$(shell git log -1 --date=short --pretty=format:%cd)
Expand All @@ -63,14 +66,13 @@ LIBS += $(shell pkg-config --libs $(PACKAGES))
INCS += $(shell pkg-config --cflags $(PACKAGES))

CFLAGS += -Wall -std=c99
OBJS = compton.o
MANPAGES = man/compton.1 man/compton-trans.1
MANPAGES_HTML = $(addsuffix .html,$(MANPAGES))

# === Recipes ===
.DEFAULT_GOAL := compton

%.o: src/%.c src/%.h
%.o: src/%.c src/%.h src/common.h
$(CC) $(CFLAGS) $(INCS) -c src/$*.c

compton: $(OBJS)
Expand Down
22 changes: 12 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,18 @@ partially doing this out of a desire to learn Xlib.

## Changes from xcompmgr:

* __inactive window transparency__ (specified with `-i`)
* __inactive window transparency / dimming__
* __titlebar/frame transparency__ (specified with `-e`)
* menu transparency (thanks to Dana)
* shadows are now enabled for argb windows, e.g. terminals with transparency
* removed serverside shadows (and simple compositing) to clean the code,
the only option that remains is clientside shadows
* configuration files (specified with `--config`)
* colored shadows (with `--shadow-[red/green/blue] value`)
* configuration files (see the man page for more details)
* colored shadows (`--shadow-[red/green/blue]`)
* a new fade system
* vsync (still under development)
* several more options
* VSync support (not always working)
* Blur of background of transparent windows, window color inversion (bad in performance)
* Some more options...

## Fixes from the original xcompmgr:

Expand Down Expand Up @@ -51,10 +52,11 @@ __R__ for runtime
* xproto / x11proto (B)
* bash (R)
* xprop,xwininfo / x11-utils (R)
* libpcre (B,R) (Will probably be made optional soon)
* libconfig (B,R) (Will probably be made optional soon)
* libdrm (B) (Will probably be made optional soon)
* libGL (B,R) (Will probably be made optional soon)
* libpcre (B,R) (Can be disabled with `NO_REGEX_PCRE` at compile time)
* libconfig (B,R) (Can be disabled with `NO_LIBCONFIG` at compile time)
* libdrm (B) (Can be disabled with `NO_VSYNC_DRM` at compile time)
* libGL (B,R) (Can be disabled with `NO_VSYNC_OPENGL` at compile time)
* libdbus (B,R) (Can be disabled with `NO_DBUS` at compile time)
* asciidoc (B)

### How to build
Expand All @@ -64,7 +66,7 @@ To build, make sure you have the dependencies above:
``` bash
# Make the main program
$ make
# Make the newer man pages
# Make the man pages
$ make docs
# Install
$ make install
Expand Down
45 changes: 45 additions & 0 deletions dbus-examples/cdbus-driver.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/bin/sh

# === Get connection parameters ===

dpy=$(echo -n "$DISPLAY" | tr -c '[:alnum:]' _)

if [ -z "$dpy" ]; then
echo "Cannot find display."
exit 1
fi

service="com.github.chjj.compton.${dpy}"
interface='com.github.chjj.compton'
object='/com/github/chjj/compton'
type_win='uint32'
type_enum='uint16'

# === DBus methods ===

# List all window ID compton manages (except destroyed ones)
dbus-send --print-reply --dest="$service" "$object" "${interface}.list_win"

# Get window ID of currently focused window
focused=$(dbus-send --print-reply --dest="$service" "$object" "${interface}.find_win" string:focused | sed -n 's/^[[:space:]]*'${type_win}'\s*\([[:digit:]]*\).*/\1/p')

if [ -n "$focused" ]; then
# Get invert_color_force property of the window
dbus-send --print-reply --dest="$service" "$object" "${interface}.win_get" "${type_win}:${focused}" string:invert_color_force

# Set the window to have inverted color
dbus-send --print-reply --dest="$service" "$object" "${interface}.win_set" "${type_win}:${focused}" string:invert_color_force "${type_enum}:1"
else
echo "Cannot find focused window."
fi

# Set the clear_shadow setting to true
dbus-send --print-reply --dest="$service" "$object" "${interface}.opts_set" string:clear_shadow boolean:true

# Get the clear_shadow setting
dbus-send --print-reply --dest="$service" "$object" "${interface}.opts_get" string:clear_shadow

# Reset compton
sleep 3
dbus-send --print-reply --dest="$service" "$object" "${interface}.reset"

Loading

0 comments on commit 58c0ece

Please sign in to comment.