mirror of
https://github.com/lbonn/rofi
synced 2025-02-17 05:18:31 +00:00
commit
3f1e7820c9
47 changed files with 1832 additions and 2134 deletions
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
[submodule "libgwater"]
|
||||
path = libgwater
|
||||
url = git://github.com/sardemff7/libgwater
|
11
.travis.yml
11
.travis.yml
|
@ -4,15 +4,21 @@ language: c
|
|||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- libxinerama-dev
|
||||
- autoconf
|
||||
- automake
|
||||
- make
|
||||
- libxft-dev
|
||||
- libx11-dev
|
||||
- libpango1.0-dev
|
||||
- libcairo2-dev
|
||||
- libstartup-notification0-dev
|
||||
- libxkbcommon-dev
|
||||
- libxkbcommon-x11-dev
|
||||
- libxcb-ewmh-dev
|
||||
- libxcb-icccm4-dev
|
||||
- libxcb-util0-dev
|
||||
- libxcb-xinerama0-dev
|
||||
- libxcb-xkb-dev
|
||||
- libxcb1-dev
|
||||
- xvfb
|
||||
- discount
|
||||
- xdotool
|
||||
|
@ -22,6 +28,7 @@ compiler:
|
|||
- gcc
|
||||
|
||||
before_install:
|
||||
- git submodule update --init
|
||||
- autoreconf -i
|
||||
|
||||
script:
|
||||
|
|
11
INSTALL.md
11
INSTALL.md
|
@ -13,14 +13,21 @@
|
|||
|
||||
### External libraries
|
||||
|
||||
* libxinerama
|
||||
* libpango
|
||||
* libpangocairo
|
||||
* libcairo
|
||||
* libcairo-xlib
|
||||
* libcairo-xcb
|
||||
* libglib2.0 >= 2.40
|
||||
* libx11
|
||||
* libstartup-notification-1.0
|
||||
* libxkbcommon-dev
|
||||
* libxkbcommon-x11-dev
|
||||
* libxcb-ewmh-dev
|
||||
* libxcb-icccm4-dev
|
||||
* libxcb-util0-dev
|
||||
* libxcb-xinerama0-dev
|
||||
* libxcb-xkb-dev
|
||||
* libxcb1-dev
|
||||
|
||||
On debian based systems, the developer packages are in the form of: `<package>-dev` on rpm based
|
||||
'<package>-devel'.
|
||||
|
|
257
Makefile.am
257
Makefile.am
|
@ -1,6 +1,11 @@
|
|||
# Specify automake version.
|
||||
AUTOMAKE_OPTIONS = 1.11.3
|
||||
|
||||
ACLOCAL_AMFLAGS = -I libgwater ${ACLOCAL_FLAGS}
|
||||
|
||||
noinst_LIBRARIES =
|
||||
include $(top_srcdir)/libgwater-xcb-nolibtool.mk
|
||||
|
||||
##
|
||||
# Rofi the program
|
||||
##
|
||||
|
@ -8,52 +13,31 @@ bin_PROGRAMS=rofi
|
|||
|
||||
dist_bin_SCRIPTS=script/rofi-sensible-terminal
|
||||
|
||||
LIBS=\
|
||||
@glib_LIBS@\
|
||||
@x11_LIBS@\
|
||||
@xinerama_LIBS@\
|
||||
@libsn_LIBS@\
|
||||
@pango_LIBS@\
|
||||
@cairo_LIBS@
|
||||
|
||||
AM_CFLAGS=\
|
||||
@EXTRA_CFLAGS@\
|
||||
@glib_CFLAGS@\
|
||||
@x11_CFLAGS@\
|
||||
@xinerama_CFLAGS@\
|
||||
@pango_CFLAGS@\
|
||||
@libsn_CFLAGS@\
|
||||
@cairo_CFLAGS@\
|
||||
-DMANPAGE_PATH="\"$(mandir)/\""\
|
||||
-I$(top_srcdir)/include/\
|
||||
-I$(top_srcdir)/config/\
|
||||
-I$(top_builddir)/\
|
||||
-Werror=missing-prototypes
|
||||
|
||||
rofi_SOURCES=\
|
||||
source/rofi.c\
|
||||
source/rofi.c\
|
||||
source/view.c\
|
||||
source/mode.c\
|
||||
source/keyb.c\
|
||||
config/config.c\
|
||||
config/config.c\
|
||||
source/helper.c\
|
||||
source/widget.c\
|
||||
source/textbox.c\
|
||||
source/textbox.c\
|
||||
source/timings.c\
|
||||
source/history.c\
|
||||
source/scrollbar.c\
|
||||
source/history.c\
|
||||
source/scrollbar.c\
|
||||
source/i3-support.c\
|
||||
source/xrmoptions.c\
|
||||
source/xrmoptions.c\
|
||||
source/x11-helper.c\
|
||||
source/x11-event-source.c\
|
||||
source/dialogs/run.c\
|
||||
source/dialogs/ssh.c\
|
||||
source/dialogs/drun.c\
|
||||
source/dialogs/dmenu.c\
|
||||
source/dialogs/combi.c\
|
||||
source/dialogs/window.c\
|
||||
source/dialogs/script.c\
|
||||
include/rofi.h\
|
||||
source/dialogs/run.c\
|
||||
source/dialogs/ssh.c\
|
||||
source/dialogs/drun.c\
|
||||
source/dialogs/dmenu.c\
|
||||
source/dialogs/combi.c\
|
||||
source/dialogs/window.c\
|
||||
source/dialogs/script.c\
|
||||
include/xcb.h\
|
||||
include/xcb-internal.h\
|
||||
include/rofi.h\
|
||||
include/mode.h\
|
||||
include/mode-private.h\
|
||||
include/settings.h\
|
||||
|
@ -62,35 +46,61 @@ rofi_SOURCES=\
|
|||
include/view-internal.h\
|
||||
include/helper.h\
|
||||
include/timings.h\
|
||||
include/history.h\
|
||||
include/history.h\
|
||||
include/widget.h\
|
||||
include/textbox.h\
|
||||
include/scrollbar.h\
|
||||
include/xrmoptions.h\
|
||||
include/i3-support.h\
|
||||
include/textbox.h\
|
||||
include/scrollbar.h\
|
||||
include/xrmoptions.h\
|
||||
include/i3-support.h\
|
||||
include/x11-helper.h\
|
||||
include/x11-event-source.h\
|
||||
include/dialogs/ssh.h\
|
||||
include/dialogs/run.h\
|
||||
include/dialogs/drun.h\
|
||||
include/dialogs/dmenu.h\
|
||||
include/dialogs/combi.h\
|
||||
include/dialogs/script.h\
|
||||
include/dialogs/window.h\
|
||||
include/dialogs/dialogs.h
|
||||
include/dialogs/ssh.h\
|
||||
include/dialogs/run.h\
|
||||
include/dialogs/drun.h\
|
||||
include/dialogs/dmenu.h\
|
||||
include/dialogs/combi.h\
|
||||
include/dialogs/script.h\
|
||||
include/dialogs/window.h\
|
||||
include/dialogs/dialogs.h\
|
||||
include/xkb.h\
|
||||
include/xkb-internal.h
|
||||
|
||||
rofi_CFLAGS=\
|
||||
$(AM_CFLAGS)\
|
||||
$(glib_CFLAGS)\
|
||||
$(GW_XCB_CFLAGS)\
|
||||
$(x11_CFLAGS)\
|
||||
$(xinerama_CFLAGS)\
|
||||
$(pango_CFLAGS)\
|
||||
$(libsn_CFLAGS)\
|
||||
$(cairo_CFLAGS)\
|
||||
-DMANPAGE_PATH="\"$(mandir)/\""\
|
||||
-I$(top_srcdir)/include/\
|
||||
-I$(top_srcdir)/config/\
|
||||
-I$(top_builddir)/\
|
||||
-Werror=missing-prototypes
|
||||
|
||||
rofi_LDADD=\
|
||||
$(glib_LIBS)\
|
||||
$(GW_XCB_LIBS)\
|
||||
$(x11_LIBS)\
|
||||
$(xinerama_LIBS)\
|
||||
$(libsn_LIBS)\
|
||||
$(pango_LIBS)\
|
||||
$(cairo_LIBS)\
|
||||
$(LIBS)
|
||||
|
||||
##
|
||||
# Manpage
|
||||
##
|
||||
man1_MANS=\
|
||||
doc/rofi.1\
|
||||
dist_man1_MANS=\
|
||||
doc/rofi.1\
|
||||
doc/rofi-sensible-terminal.1
|
||||
|
||||
##
|
||||
# Readme.md
|
||||
##
|
||||
markdown_SC_FILES=\
|
||||
README.md
|
||||
README.md
|
||||
|
||||
# want the html to show up in release.
|
||||
md_verbose = $(md_verbose_@AM_V@)
|
||||
|
@ -98,7 +108,7 @@ md_verbose_ = $(md_verbose_@AM_DEFAULT_V@)
|
|||
md_verbose_0 = @echo " MD" $@;
|
||||
|
||||
markdown_FILES=\
|
||||
README.html
|
||||
README.html
|
||||
|
||||
README.html: README.md
|
||||
$(md_verbose) markdown $< > $@
|
||||
|
@ -107,19 +117,18 @@ README.html: README.md
|
|||
##
|
||||
# config directory
|
||||
##
|
||||
${top_builddir}/config/config.c: ${top_srcdir}/config/config.def.c
|
||||
cp ${top_srcdir}/config/config.def.c $@
|
||||
$(top_builddir)/config/config.c: $(top_srcdir)/config/config.def.c
|
||||
cp $(top_srcdir)/config/config.def.c $@
|
||||
|
||||
##
|
||||
# Extra DIST
|
||||
##
|
||||
EXTRA_DIST=\
|
||||
$(man1_MANS)\
|
||||
$(markdown_FILES)\
|
||||
$(markdown_SC_FILES)\
|
||||
Examples/i3_switch_workspaces.sh\
|
||||
${top_srcdir}/config/config.def.c\
|
||||
INSTALL.md\
|
||||
$(markdown_FILES)\
|
||||
$(markdown_SC_FILES)\
|
||||
Examples/i3_switch_workspaces.sh\
|
||||
$(top_srcdir)/config/config.def.c\
|
||||
INSTALL.md\
|
||||
AUTHORS\
|
||||
doc/rofi.doxy.in\
|
||||
Changelog
|
||||
|
@ -129,64 +138,114 @@ EXTRA_DIST=\
|
|||
##
|
||||
|
||||
|
||||
update-manpage: ${top_srcdir}/doc/rofi-manpage.markdown
|
||||
ronn --roff --pipe $^ > ${top_srcdir}/doc/rofi.1
|
||||
update-manpage: $(top_srcdir)/doc/rofi-manpage.markdown
|
||||
ronn --roff --pipe $^ > $(top_srcdir)/doc/rofi.1
|
||||
|
||||
##
|
||||
# Rofi test program
|
||||
##
|
||||
noinst_PROGRAMS=rofi_test textbox_test helper_test
|
||||
check_PROGRAMS=rofi_test textbox_test helper_test
|
||||
|
||||
rofi_test_CFLAGS=\
|
||||
$(AM_CFLAGS)\
|
||||
$(glib_CFLAGS)\
|
||||
$(libsn_CFLAGS)\
|
||||
-I$(top_srcdir)/include/\
|
||||
-I$(top_srcdir)/config/\
|
||||
-I$(top_builddir)/
|
||||
|
||||
rofi_test_LDADD=\
|
||||
$(glib_LIBS)
|
||||
|
||||
|
||||
rofi_test_SOURCES=\
|
||||
source/history.c\
|
||||
config/config.c\
|
||||
include/rofi.h\
|
||||
source/history.c\
|
||||
config/config.c\
|
||||
include/rofi.h\
|
||||
include/mode.h\
|
||||
include/mode-private.h\
|
||||
include/settings.h\
|
||||
include/history.h\
|
||||
include/history.h\
|
||||
test/history-test.c
|
||||
|
||||
textbox_test_CFLAGS=\
|
||||
$(AM_CFLAGS)\
|
||||
$(glib_CFLAGS)\
|
||||
$(pango_CFLAGS)\
|
||||
$(x11_CFLAGS)\
|
||||
$(xinerama_CFLAGS)\
|
||||
$(GW_XCB_CFLAGS)\
|
||||
$(cairo_CFLAGS)\
|
||||
$(libsn_CFLAGS)\
|
||||
-I$(top_srcdir)/include/\
|
||||
-I$(top_srcdir)/config/\
|
||||
-I$(top_builddir)/
|
||||
|
||||
textbox_test_LDADD=\
|
||||
$(glib_LIBS)\
|
||||
$(pango_LIBS)\
|
||||
$(x11_LIBS)\
|
||||
$(xinerama_LIBS)\
|
||||
$(GW_XCB_LIBS)\
|
||||
$(cairo_LIBS)\
|
||||
$(libsn_LIBS)
|
||||
|
||||
textbox_test_SOURCES=\
|
||||
source/widget.c\
|
||||
source/textbox.c\
|
||||
config/config.c\
|
||||
source/keyb.c\
|
||||
source/x11-helper.c\
|
||||
source/xrmoptions.c\
|
||||
source/helper.c\
|
||||
source/textbox.c\
|
||||
config/config.c\
|
||||
include/keyb.h\
|
||||
include/rofi.h\
|
||||
include/rofi.h\
|
||||
include/mode.h\
|
||||
include/mode-private.h\
|
||||
include/settings.h\
|
||||
include/widget.h\
|
||||
include/textbox.h\
|
||||
include/textbox.h\
|
||||
include/widget.h\
|
||||
include/x11-helper.h\
|
||||
include/xrmoptions.h\
|
||||
include/helper.h\
|
||||
test/textbox-test.c
|
||||
|
||||
helper_test_SOURCES=\
|
||||
config/config.c\
|
||||
include/rofi.h\
|
||||
config/config.c\
|
||||
include/rofi.h\
|
||||
include/mode.h\
|
||||
include/mode-private.h\
|
||||
source/helper.c\
|
||||
include/helper.h\
|
||||
source/helper.c\
|
||||
include/helper.h\
|
||||
include/xrmoptions.h\
|
||||
source/xrmoptions.c\
|
||||
test/helper-test.c
|
||||
source/x11-helper.c\
|
||||
test/helper-test.c
|
||||
|
||||
.PHONY: test
|
||||
test: ${bin_PROGRAMS} ${noinst_PROGRAMS}
|
||||
./rofi_test
|
||||
./helper_test
|
||||
helper_test_CFLAGS=\
|
||||
$(AM_CFLAGS)\
|
||||
$(glib_CFLAGS)\
|
||||
$(pango_CFLAGS)\
|
||||
$(x11_CFLAGS)\
|
||||
$(xinerama_CFLAGS)\
|
||||
$(GW_XCB_CFLAGS)\
|
||||
$(cairo_CFLAGS)\
|
||||
$(libsn_CFLAGS)\
|
||||
-I$(top_srcdir)/include/\
|
||||
-I$(top_srcdir)/config/\
|
||||
-I$(top_builddir)/
|
||||
|
||||
helper_test_LDADD=\
|
||||
$(glib_LIBS)\
|
||||
$(pango_LIBS)\
|
||||
$(x11_LIBS)\
|
||||
$(GW_XCB_LIBS)\
|
||||
$(xinerama_LIBS)\
|
||||
$(libsn_LIBS)\
|
||||
$(cairo_LIBS)
|
||||
|
||||
TESTS=\
|
||||
rofi_test\
|
||||
helper_test
|
||||
|
||||
.PHONY: test-x
|
||||
test-x: ${bin_PROGRAMS}
|
||||
test-x: $(bin_PROGRAMS) textbox_test
|
||||
echo "Test 1"
|
||||
$(top_srcdir)/test/run_test.sh 123 $(top_builddir)/textbox_test $(top_builddir)
|
||||
echo "Test 2"
|
||||
|
@ -230,28 +289,28 @@ test-x: ${bin_PROGRAMS}
|
|||
echo "Test issue 333"
|
||||
$(top_srcdir)/test/run_test.sh 221 $(top_srcdir)/test/run_issue333_test.sh $(top_builddir)
|
||||
|
||||
test-x1: ${bin_PROGRAMS}
|
||||
test-x1: $(bin_PROGRAMS)
|
||||
echo "Test dmenu-normal-window"
|
||||
$(top_srcdir)/test/run_test.sh 219 $(top_srcdir)/test/run_dmenu_normal_window_test.sh $(top_builddir)
|
||||
echo "Test window"
|
||||
$(top_srcdir)/test/run_test.sh 220 $(top_srcdir)/test/run_window_test.sh $(top_builddir) $(top_srcdir)
|
||||
$(top_srcdir)/test/run_test.sh 220 $(top_srcdir)/test/run_window_test.sh $(top_builddir) $(top_srcdir)
|
||||
echo "End tests"
|
||||
|
||||
|
||||
.PHONY: indent
|
||||
indent: ${rofi_SOURCES} ${top_srcdir}/config/config.def.c ${helper_test_SOURCES} ${textbox_test_SOURCES} ${rofi_test_SOURCES}
|
||||
uncrustify -c ${top_srcdir}/data/uncrustify.cfg --replace $^
|
||||
indent: $(rofi_SOURCES) $(top_srcdir)/config/config.def.c $(helper_test_SOURCES) $(textbox_test_SOURCES) $(rofi_test_SOURCES)
|
||||
uncrustify -c $(top_srcdir)/data/uncrustify.cfg --replace $^
|
||||
|
||||
.PHONY: cppcheck
|
||||
|
||||
cppcheck: ${rofi_SOURCES}
|
||||
cppcheck --std=c99 --platform=unix64 --enable=all -Uerror_dialog -I ${top_srcdir}/include/ $^
|
||||
cppcheck: $(rofi_SOURCES)
|
||||
cppcheck --std=c99 --platform=unix64 --enable=all -Uerror_dialog --inconclusive -I $(top_srcdir)/include/ $^
|
||||
|
||||
.PHONY: ohcount
|
||||
|
||||
ohcount: ${rofi_SOURCES}
|
||||
ohcount -i ${top_srcdir}/source/ ${top_srcdir}/include/
|
||||
ohcount: $(rofi_SOURCES)
|
||||
ohcount -i $(top_srcdir)/source/ $(top_srcdir)/include/
|
||||
|
||||
doxy: doc/rofi.doxy ${rofi_SOURCES}
|
||||
doxygen ${top_builddir}/doc/rofi.doxy
|
||||
doxy: doc/rofi.doxy $(rofi_SOURCES)
|
||||
doxygen $(top_builddir)/doc/rofi.doxy
|
||||
|
||||
|
|
25
configure.ac
25
configure.ac
|
@ -30,13 +30,28 @@ dnl System extensions
|
|||
dnl ---------------------------------------------------------------------
|
||||
AC_USE_SYSTEM_EXTENSIONS
|
||||
|
||||
dnl ---------------------------------------------------------------------
|
||||
dnl Static libraries programs
|
||||
dnl ---------------------------------------------------------------------
|
||||
AC_PROG_RANLIB
|
||||
AM_PROG_AR
|
||||
|
||||
dnl ---------------------------------------------------------------------
|
||||
dnl Base CFLAGS
|
||||
dnl ---------------------------------------------------------------------
|
||||
AM_CFLAGS="-Wall -Wextra -Wparentheses -Winline -pedantic -Wunreachable-code"
|
||||
|
||||
dnl ---------------------------------------------------------------------
|
||||
dnl Enable source code coverage reporting for GCC
|
||||
dnl ---------------------------------------------------------------------
|
||||
|
||||
AC_ARG_ENABLE(gcov,
|
||||
[ --enable-gcov Enable source code coverage testing using gcov],
|
||||
[CFLAGS="$CFLAGS -coverage"])
|
||||
[AM_CFLAGS="${AM_CFLAGS} -coverage"])
|
||||
|
||||
AC_ARG_ENABLE(asan,
|
||||
[ --enable-asan asan],
|
||||
[AM_CFLAGS="${AM_CFLAGS} -fsanitize=address -fno-omit-frame-pointer -g3"])
|
||||
dnl ---------------------------------------------------------------------
|
||||
dnl Disable window mode
|
||||
dnl ---------------------------------------------------------------------
|
||||
|
@ -72,17 +87,17 @@ dnl ---------------------------------------------------------------------
|
|||
dnl X11, Glib, Xinerama, Pango, Cairo, libstartup notification
|
||||
dnl ---------------------------------------------------------------------
|
||||
PKG_CHECK_MODULES([glib], [glib-2.0 >= 2.40])
|
||||
PKG_CHECK_MODULES([x11], [x11])
|
||||
PKG_CHECK_MODULES([xinerama], [xinerama])
|
||||
GW_CHECK_XCB([xcb-aux xcb-xkb xkbcommon xkbcommon-x11 xcb-ewmh xcb-xinerama xcb-icccm])
|
||||
PKG_CHECK_MODULES([x11], [x11 x11-xcb])
|
||||
PKG_CHECK_MODULES([pango], [pango pangocairo])
|
||||
PKG_CHECK_MODULES([cairo], [cairo cairo-xlib])
|
||||
PKG_CHECK_MODULES([cairo], [cairo cairo-xcb])
|
||||
PKG_CHECK_MODULES([libsn], [libstartup-notification-1.0])
|
||||
|
||||
|
||||
dnl ---------------------------------------------------------------------
|
||||
dnl Add extra compiler flags
|
||||
dnl ---------------------------------------------------------------------
|
||||
AC_SUBST([EXTRA_CFLAGS], ["-Wall -Wextra -Wparentheses -Winline -pedantic"])
|
||||
AC_SUBST([AM_CFLAGS])
|
||||
|
||||
AC_CONFIG_FILES([Makefile doc/rofi.doxy])
|
||||
AC_OUTPUT
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
[ -bgalt *color* ]
|
||||
[ -hlfg *color* ]
|
||||
[ -hlbg *color* ]
|
||||
[ -key-**mode** *combo* ]
|
||||
[ -terminal *terminal* ]
|
||||
[ -location *position* ]
|
||||
[ -fixed-num-lines ]
|
||||
|
@ -73,8 +72,7 @@ filter, tokenized search and more.
|
|||
|
||||
## USAGE
|
||||
|
||||
**rofi** can be used in three ways, single-shot; executes once and directly exits when done, as a
|
||||
daemon listening to specific key-combination or emulating dmenu.
|
||||
**rofi** can be used in two ways, single-shot (runs a mode then exits) or emulating dmenu.
|
||||
|
||||
### Single-shot mode
|
||||
|
||||
|
@ -83,15 +81,6 @@ To show the run dialog:
|
|||
|
||||
rofi -show run
|
||||
|
||||
### Daemon mode
|
||||
|
||||
To launch **rofi** in daemon mode don't specify any mode, instead keys can be bound
|
||||
to launch a certain mode. To show run-mode by pressing `F2` start **rofi** like this:
|
||||
|
||||
rofi -key-run F2
|
||||
|
||||
Keybindings can also be specified in the `Xresources` file.
|
||||
|
||||
### Emulating dmenu
|
||||
|
||||
**rofi** can emulate `dmenu` (a dynamic menu for X) when launched with the `-dmenu` flag.
|
||||
|
@ -155,14 +144,6 @@ This does not validate all passed values (e.g. colors).
|
|||
|
||||
Dump the current color schme in Xresources format to the command-line.
|
||||
|
||||
`-key-{mode}` **KEY**
|
||||
|
||||
Set the key combination to display a {mode} in daemon mode.
|
||||
|
||||
rofi -key-run F12
|
||||
rofi -key-ssh control+shift+s
|
||||
rofi -key-window SuperL+Tab
|
||||
|
||||
`-threads` *num*
|
||||
|
||||
Specify the number of threads **rofi** should use:
|
||||
|
@ -213,10 +194,6 @@ Example: Have a mode 'Workspaces' using the `i3_switch_workspace.sh` script:
|
|||
|
||||
Start in case sensitive mode.
|
||||
|
||||
`-quiet`
|
||||
|
||||
Do not print any message when starting in daemon mode.
|
||||
|
||||
`-fuzzy`
|
||||
|
||||
Enable experimental fuzzy matching.
|
||||
|
@ -649,7 +626,7 @@ Make **rofi** reacts like a normal application window. Useful for scripts like C
|
|||
|
||||
Dump the filtered list to stdout and quit.
|
||||
This can be used to get the list as **rofi** would filter it.
|
||||
Use together with `-filter` command.
|
||||
Use together with `-filter` command.
|
||||
|
||||
`-input` *file*
|
||||
|
||||
|
@ -702,21 +679,6 @@ This way it can be used as a drop-in replacement for dmenu. just copy or symlink
|
|||
|
||||
ln -s /usr/bin/rofi /usr/bin/dmenu
|
||||
|
||||
## SIGNALS
|
||||
|
||||
`HUP`
|
||||
|
||||
If in daemon mode, reload the configuration from Xresources. (commandline arguments still -override
|
||||
Xresources). This will also reload configured key-bindings.
|
||||
|
||||
`INT`
|
||||
|
||||
If in daemon mode, quits **rofi**.
|
||||
|
||||
`USR1`
|
||||
|
||||
If in daemon mode, dumps the current configuration to stdout. Similar to `-xresources-dump`
|
||||
|
||||
## THEMING
|
||||
|
||||
With **rofi** 0.15.4 we have a new way of specifying colors, the old settings still apply (for now).
|
||||
|
@ -829,7 +791,7 @@ Shows a list of SSH targets based on your ssh config file, and allows to quickly
|
|||
|
||||
### Script
|
||||
|
||||
Allows custom scripted Modi to be added.
|
||||
Allows custom scripted Modi to be added.
|
||||
|
||||
## FAQ
|
||||
|
||||
|
|
|
@ -226,10 +226,6 @@ rofi.kb-custom-19: Alt+Shift+9
|
|||
rofi.kb-screenshot: Alt+Shift+S
|
||||
! Keybinding
|
||||
rofi.kb-toggle-sort: Alt+grave
|
||||
! Keybinding
|
||||
rofi.key-combi: Alt-F3
|
||||
! Keybinding
|
||||
rofi.key-drun:
|
||||
! The display name of this browser
|
||||
rofi.display-ssh:
|
||||
! The display name of this browser
|
||||
|
|
|
@ -137,7 +137,7 @@ void remove_pid_file ( int fd );
|
|||
*
|
||||
* This functions exits the program with 1 when it finds an invalid configuration.
|
||||
*/
|
||||
void config_sanity_check ( Display *display );
|
||||
int config_sanity_check ( void );
|
||||
|
||||
/**
|
||||
* @param arg string to parse.
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
* Hopefully at some point, I3 gets fixed and this is not needed.
|
||||
* This function takes the path to the i3 IPC socket, and the XID of the window.
|
||||
*/
|
||||
void i3_support_focus_window ( Window id );
|
||||
void i3_support_focus_window ( xcb_window_t id );
|
||||
|
||||
/**
|
||||
* @param display The display to read the i3 property from.
|
||||
|
@ -28,7 +28,7 @@ void i3_support_focus_window ( Window id );
|
|||
* @returns TRUE when i3 is running, FALSE when not.
|
||||
*/
|
||||
|
||||
int i3_support_initialize ( Display *display );
|
||||
int i3_support_initialize ( xcb_stuff *xcb );
|
||||
|
||||
/**
|
||||
* Cleanup.
|
||||
|
|
|
@ -82,7 +82,7 @@ typedef enum _KeyBindingAction
|
|||
* Parse the keybindings.
|
||||
* This should be called after the setting system is initialized.
|
||||
*/
|
||||
void parse_keys_abe ( void );
|
||||
gboolean parse_keys_abe ( void );
|
||||
|
||||
/**
|
||||
* Setup the keybindings
|
||||
|
@ -99,7 +99,7 @@ void cleanup_abe ( void );
|
|||
* Check if this key has been triggered.
|
||||
* @returns TRUE if key combo matches, FALSE otherwise.
|
||||
*/
|
||||
int abe_test_action ( KeyBindingAction action, unsigned int mask, KeySym key );
|
||||
int abe_test_action ( KeyBindingAction action, unsigned int mask, xkb_keysym_t key );
|
||||
|
||||
/*@}*/
|
||||
#endif // ROFI_KEYB_H
|
||||
|
|
|
@ -37,14 +37,9 @@ typedef int ( *_mode_is_not_ascii )( const Mode *sw, unsigned int index );
|
|||
struct _Mode
|
||||
{
|
||||
/** Name (max 31 char long) */
|
||||
char name[32];
|
||||
char cfg_name_key[128];
|
||||
char *display_name;
|
||||
/** Keybindings (keysym and modmask) */
|
||||
char * keycfg;
|
||||
char * keystr;
|
||||
KeySym keysym;
|
||||
unsigned int modmask;
|
||||
char name[32];
|
||||
char cfg_name_key[128];
|
||||
char *display_name;
|
||||
|
||||
/**
|
||||
* A switcher normally consists of the following parts:
|
||||
|
|
|
@ -140,17 +140,6 @@ int mode_token_match ( const Mode *mode, char **tokens, int not_ascii, int case_
|
|||
*/
|
||||
const char * mode_get_name ( const Mode *mode );
|
||||
|
||||
/**
|
||||
* @param mode The mode to query
|
||||
* @param key The KeySym to match
|
||||
* @param state The Modmask to match
|
||||
*
|
||||
* Match keybinding of mode.
|
||||
*
|
||||
* return TRUE when matching, FALSE otherwise
|
||||
*/
|
||||
int mode_check_keybinding ( const Mode *mode, KeySym key, unsigned int modstate );
|
||||
|
||||
/**
|
||||
* @param mode The mode to query
|
||||
*
|
||||
|
@ -158,39 +147,6 @@ int mode_check_keybinding ( const Mode *mode, KeySym key, unsigned int modstate
|
|||
*/
|
||||
void mode_free ( Mode **mode );
|
||||
|
||||
/**
|
||||
* @param mode The mode to query
|
||||
*
|
||||
* Setup the keybinding for this mode.
|
||||
*/
|
||||
void mode_setup_keybinding ( Mode *mode );
|
||||
|
||||
/**
|
||||
* @param mode The mode to query
|
||||
* @param display The X Server display handle.
|
||||
*
|
||||
* Grab the key on the display.
|
||||
* This first parses the key string and if successful asks X11 for a grab.
|
||||
*
|
||||
* return FALSE when key could not be grabbed.
|
||||
*/
|
||||
int mode_grab_key ( Mode *mode, Display *display );
|
||||
|
||||
/**
|
||||
* @param mode The mode to query
|
||||
* @param display The X Server display handle.
|
||||
*
|
||||
* Releases previously grabbed key.
|
||||
*/
|
||||
void mode_ungrab_key ( Mode *mode, Display *display );
|
||||
|
||||
/**
|
||||
* @param mode The mode to query
|
||||
*
|
||||
* Print the current keybing for this mode to stdout.
|
||||
*/
|
||||
void mode_print_keybindings ( const Mode *mode );
|
||||
|
||||
/**
|
||||
* @param mode The mode to query
|
||||
*
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef ROFI_MAIN_H
|
||||
#define ROFI_MAIN_H
|
||||
#include <X11/X.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <xcb/xcb.h>
|
||||
#include <xkbcommon/xkbcommon.h>
|
||||
#include <glib.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -14,6 +14,7 @@
|
|||
* @defgroup Main Main
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Pointer to xdg cache directory.
|
||||
*/
|
||||
|
@ -35,17 +36,6 @@ unsigned int rofi_get_num_enabled_modi ( void );
|
|||
*/
|
||||
const Mode * rofi_get_mode ( unsigned int index );
|
||||
|
||||
/**
|
||||
* @param key the Key to match
|
||||
* @param modstate the modifier state to match
|
||||
*
|
||||
* Match key and modifier state against modi.
|
||||
*
|
||||
* @return the index of the switcher that matches the key combination
|
||||
* specified by key and modstate. Returns -1 if none was found
|
||||
*/
|
||||
int locate_switcher ( KeySym key, unsigned int modstate );
|
||||
|
||||
void rofi_set_return_code ( int code );
|
||||
/** Reset terminal */
|
||||
#define color_reset "\033[0m"
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
#ifndef ROFI_TEXTBOX_H
|
||||
#define ROFI_TEXTBOX_H
|
||||
|
||||
#include <X11/Xutil.h>
|
||||
#include <xkbcommon/xkbcommon.h>
|
||||
#include <pango/pango.h>
|
||||
#include <pango/pango-fontmap.h>
|
||||
#include <pango/pangocairo.h>
|
||||
#include <cairo.h>
|
||||
#include "widget.h"
|
||||
#include "x11-helper.h"
|
||||
|
||||
/**
|
||||
* @defgroup Textbox Textbox
|
||||
|
@ -15,11 +16,6 @@
|
|||
* @{
|
||||
*/
|
||||
|
||||
typedef struct
|
||||
{
|
||||
double red, green, blue, alpha;
|
||||
} Color;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
Widget widget;
|
||||
|
@ -113,7 +109,7 @@ void textbox_draw ( textbox *tb, cairo_t *draw );
|
|||
*
|
||||
* @returns if the key was handled (1), unhandled(0) or handled and return was pressed (-1)
|
||||
*/
|
||||
int textbox_keypress ( textbox *tb, XEvent *ev, char *pad, int pad_len, KeySym key, Status stat );
|
||||
int textbox_keypress ( textbox *tb, char *pad, int pad_len, unsigned int modstate, xkb_keysym_t key );
|
||||
|
||||
/**
|
||||
* @param tb Handle to the textbox
|
||||
|
@ -145,7 +141,7 @@ void textbox_insert ( textbox *tb, int pos, char *str, int slen );
|
|||
* before any of the textbox_ functions is called.
|
||||
* Clean with textbox_cleanup()
|
||||
*/
|
||||
void textbox_setup ( Display *display );
|
||||
void textbox_setup ( void );
|
||||
|
||||
/**
|
||||
* Cleanup the allocated colors and fonts by textbox_setup().
|
||||
|
|
|
@ -14,63 +14,65 @@
|
|||
|
||||
struct RofiViewState
|
||||
{
|
||||
Mode *sw;
|
||||
unsigned int menu_lines;
|
||||
unsigned int max_elements;
|
||||
unsigned int max_rows;
|
||||
unsigned int columns;
|
||||
Mode *sw;
|
||||
unsigned int menu_lines;
|
||||
unsigned int max_elements;
|
||||
unsigned int max_rows;
|
||||
unsigned int columns;
|
||||
|
||||
// window width,height
|
||||
unsigned int w, h;
|
||||
int x, y;
|
||||
unsigned int element_width;
|
||||
int top_offset;
|
||||
unsigned int w, h;
|
||||
int x, y;
|
||||
unsigned int element_width;
|
||||
int top_offset;
|
||||
|
||||
// Update/Refilter list.
|
||||
int update;
|
||||
int refilter;
|
||||
int rchanged;
|
||||
int cur_page;
|
||||
int update;
|
||||
int refilter;
|
||||
int rchanged;
|
||||
int cur_page;
|
||||
|
||||
// Entries
|
||||
textbox *text;
|
||||
textbox *prompt_tb;
|
||||
textbox *message_tb;
|
||||
textbox *case_indicator;
|
||||
textbox **boxes;
|
||||
scrollbar *scrollbar;
|
||||
int *distance;
|
||||
unsigned int *line_map;
|
||||
textbox *text;
|
||||
textbox *prompt_tb;
|
||||
textbox *message_tb;
|
||||
textbox *case_indicator;
|
||||
textbox **boxes;
|
||||
scrollbar *scrollbar;
|
||||
int *distance;
|
||||
unsigned int *line_map;
|
||||
|
||||
unsigned int num_lines;
|
||||
unsigned int num_lines;
|
||||
|
||||
// Selected element.
|
||||
unsigned int selected;
|
||||
unsigned int filtered_lines;
|
||||
unsigned int selected;
|
||||
unsigned int filtered_lines;
|
||||
// Last offset in paginating.
|
||||
unsigned int last_offset;
|
||||
unsigned int last_offset;
|
||||
|
||||
KeySym prev_key;
|
||||
Time last_button_press;
|
||||
xkb_keysym_t prev_key;
|
||||
xcb_timestamp_t last_button_press;
|
||||
|
||||
int quit;
|
||||
int skip_absorb;
|
||||
int quit;
|
||||
int skip_absorb;
|
||||
// Return state
|
||||
unsigned int selected_line;
|
||||
MenuReturn retv;
|
||||
int *lines_not_ascii;
|
||||
int line_height;
|
||||
unsigned int border;
|
||||
workarea mon;
|
||||
unsigned int selected_line;
|
||||
MenuReturn retv;
|
||||
int *lines_not_ascii;
|
||||
int line_height;
|
||||
unsigned int border;
|
||||
workarea mon;
|
||||
|
||||
// Sidebar view
|
||||
unsigned int num_modi;
|
||||
textbox **modi;
|
||||
unsigned int num_modi;
|
||||
textbox **modi;
|
||||
|
||||
MenuFlags menu_flags;
|
||||
MenuFlags menu_flags;
|
||||
|
||||
xcb_window_t window;
|
||||
// Handlers.
|
||||
void ( *x11_event_loop )( struct RofiViewState *state, XEvent *ev );
|
||||
void ( *finalize )( struct RofiViewState *state );
|
||||
void ( *x11_event_loop )( struct RofiViewState *state, xcb_generic_event_t *ev, xkb_stuff *xkb );
|
||||
void ( *finalize )( struct RofiViewState *state );
|
||||
};
|
||||
/** @} */
|
||||
#endif
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
#ifndef ROFI_VIEW_H
|
||||
#define ROFI_VIEW_H
|
||||
|
||||
#include "xkb.h"
|
||||
|
||||
/**
|
||||
* @defgroup View View
|
||||
*
|
||||
|
@ -47,7 +49,7 @@ void rofi_view_finalize ( RofiViewState *state );
|
|||
|
||||
MenuReturn rofi_view_get_return_value ( const RofiViewState *state );
|
||||
unsigned int rofi_view_get_next_position ( const RofiViewState *state );
|
||||
void rofi_view_itterrate ( RofiViewState *state, XEvent *event );
|
||||
void rofi_view_itterrate ( RofiViewState *state, xcb_generic_event_t *event, xkb_stuff *xkb );
|
||||
unsigned int rofi_view_get_completed ( const RofiViewState *state );
|
||||
const char * rofi_view_get_user_input ( const RofiViewState *state );
|
||||
|
||||
|
@ -88,7 +90,7 @@ void rofi_view_update ( RofiViewState *state );
|
|||
*
|
||||
* Enables fake transparancy on this view.
|
||||
*/
|
||||
void rofi_view_setup_fake_transparency ( Display *display, RofiViewState *state );
|
||||
void rofi_view_setup_fake_transparency ( RofiViewState *state );
|
||||
|
||||
/**
|
||||
* @param state The handle to the view
|
||||
|
@ -128,7 +130,7 @@ void rofi_view_set_active ( RofiViewState *state );
|
|||
*
|
||||
* The error message to show.
|
||||
*/
|
||||
void rofi_view_error_dialog ( const char *msg, int markup );
|
||||
int rofi_view_error_dialog ( const char *msg, int markup );
|
||||
|
||||
/**
|
||||
* Queue a redraw.
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
#ifndef ROFI_X11_EVENT_SOURCE_H
|
||||
#define ROFI_X11_EVENT_SOURCE_H
|
||||
|
||||
GSource * x11_event_source_new ( Display *display );
|
||||
void x11_event_source_set_callback ( GSource *source, GSourceFunc callback );
|
||||
#endif // ROFI_X11_EVENT_SOURCE_H
|
|
@ -1,6 +1,10 @@
|
|||
#ifndef X11_ROFI_HELPER_H
|
||||
#define X11_ROFI_HELPER_H
|
||||
#include <glib.h>
|
||||
#include <cairo.h>
|
||||
#include <xcb/xcb.h>
|
||||
|
||||
#include "xkb.h"
|
||||
|
||||
/**
|
||||
* @defgroup X11Helper X11Helper
|
||||
|
@ -8,13 +12,9 @@
|
|||
* @{
|
||||
*/
|
||||
|
||||
int window_get_prop ( Display *display, Window w, Atom prop,
|
||||
Atom *type, int *items,
|
||||
void *buffer, unsigned int bytes ) __attribute__ ( ( nonnull ( 4, 5 ) ) );
|
||||
|
||||
/**
|
||||
* @param display Connection to the X server.
|
||||
* @param w The Window to read property from.
|
||||
* @param w The xcb_window_t to read property from.
|
||||
* @param atom The property identifier
|
||||
*
|
||||
* Get text property defined by atom from window.
|
||||
|
@ -22,100 +22,60 @@ int window_get_prop ( Display *display, Window w, Atom prop,
|
|||
*
|
||||
* @returns a newly allocated string with the result or NULL
|
||||
*/
|
||||
char* window_get_text_prop ( Display *display, Window w, Atom atom );
|
||||
char* window_get_text_prop ( xcb_window_t w, xcb_atom_t atom );
|
||||
|
||||
int window_get_atom_prop ( Display *display, Window w, Atom atom, Atom *list, int count );
|
||||
void window_set_atom_prop ( Display *display, Window w, Atom prop, Atom *atoms, int count );
|
||||
int window_get_cardinal_prop ( Display *display, Window w, Atom atom, unsigned long *list,
|
||||
int count );
|
||||
void window_set_atom_prop ( xcb_window_t w, xcb_atom_t prop, xcb_atom_t *atoms, int count );
|
||||
|
||||
/**
|
||||
* Window info.
|
||||
* xcb_window_t info.
|
||||
*/
|
||||
#define ATOM_ENUM( x ) x
|
||||
#define ATOM_CHAR( x ) # x
|
||||
|
||||
// usable space on a monitor
|
||||
#define EWMH_ATOMS( X ) \
|
||||
X ( _NET_CLIENT_LIST_STACKING ), \
|
||||
X ( _NET_NUMBER_OF_DESKTOPS ), \
|
||||
X ( _NET_CURRENT_DESKTOP ), \
|
||||
X ( _NET_ACTIVE_WINDOW ), \
|
||||
X ( _NET_CLIENT_LIST ), \
|
||||
X ( _NET_WM_NAME ), \
|
||||
X ( _NET_WM_STATE ), \
|
||||
X ( _NET_WM_STATE_SKIP_TASKBAR ), \
|
||||
X ( _NET_WM_STATE_SKIP_PAGER ), \
|
||||
X ( _NET_WM_STATE_ABOVE ), \
|
||||
X ( _NET_WM_STATE_DEMANDS_ATTENTION ), \
|
||||
X ( _NET_WM_STATE_WITHDRAWN ), \
|
||||
X ( _NET_WM_WINDOW_TYPE ), \
|
||||
X ( _NET_WM_WINDOW_TYPE_DOCK ), \
|
||||
X ( _NET_WM_WINDOW_TYPE_DESKTOP ), \
|
||||
X ( _NET_WM_WINDOW_TYPE_NORMAL ), \
|
||||
X ( _NET_WM_STATE_FULLSCREEN ), \
|
||||
X ( _NET_WM_DESKTOP ), \
|
||||
X ( _NET_DESKTOP_VIEWPORT ), \
|
||||
X ( CLIPBOARD ), \
|
||||
X ( UTF8_STRING ), \
|
||||
X ( _NET_WM_WINDOW_OPACITY )
|
||||
#define EWMH_ATOMS( X ) \
|
||||
X ( _NET_WM_WINDOW_OPACITY ), \
|
||||
X ( I3_SOCKET_PATH ), \
|
||||
X ( WM_WINDOW_ROLE )
|
||||
|
||||
enum { EWMH_ATOMS ( ATOM_ENUM ), NUM_NETATOMS };
|
||||
|
||||
extern const char *netatom_names[];
|
||||
extern Atom netatoms[NUM_NETATOMS];
|
||||
extern xcb_atom_t netatoms[NUM_NETATOMS];
|
||||
typedef struct
|
||||
{
|
||||
int x, y, w, h;
|
||||
int l, r, t, b;
|
||||
} workarea;
|
||||
|
||||
void monitor_active ( Display *display, workarea *mon );
|
||||
|
||||
int window_send_message ( Display *display, Window target, Window subject,
|
||||
Atom atom, unsigned long protocol,
|
||||
unsigned long mask, Time time );
|
||||
void monitor_active ( workarea *mon );
|
||||
|
||||
// find the dimensions of the monitor displaying point x,y
|
||||
void monitor_dimensions ( Display *display, Screen *screen, int x, int y, workarea *mon );
|
||||
void monitor_dimensions ( int x, int y, workarea *mon );
|
||||
// Find the dimensions of the monitor specified by user.
|
||||
int monitor_get_dimension ( Display *display, Screen *screen, int monitor, workarea *mon );
|
||||
int monitor_get_smallest_size ( Display *display );
|
||||
int monitor_get_dimension ( int monitor, workarea *mon );
|
||||
int monitor_get_smallest_size ( void );
|
||||
|
||||
/**
|
||||
* @param display The display.
|
||||
*
|
||||
* Release keyboard.
|
||||
*/
|
||||
void release_keyboard ( Display *display );
|
||||
void release_keyboard ( void );
|
||||
|
||||
/**
|
||||
* @param display The display.
|
||||
* @param w Window we want to grab keyboard on.
|
||||
* @param w xcb_window_t we want to grab keyboard on.
|
||||
*
|
||||
* Grab keyboard and mouse.
|
||||
*
|
||||
* @return 1 when keyboard is grabbed, 0 not.
|
||||
*/
|
||||
int take_keyboard ( Display *display, Window w );
|
||||
int take_keyboard ( xcb_window_t w );
|
||||
|
||||
/**
|
||||
* @param display Connection to the X server.
|
||||
* @param modmask Modifier mask.
|
||||
* @param key Key.
|
||||
* @param mask The mask to canonilize
|
||||
*
|
||||
* Grab key on display.
|
||||
* @return The canonilized mask
|
||||
*/
|
||||
void x11_grab_key ( Display *display, unsigned int modmask, KeySym key );
|
||||
|
||||
/**
|
||||
* @param display Connection to the X server.
|
||||
* @param modmask Modifier mask.
|
||||
* @param key Key.
|
||||
*
|
||||
* Ungrab key on display.
|
||||
*/
|
||||
void x11_ungrab_key ( Display *display, unsigned int modmask, KeySym key );
|
||||
unsigned int x11_canonalize_mask ( unsigned int mask );
|
||||
|
||||
/**
|
||||
* @param combo String representing the key combo
|
||||
|
@ -124,7 +84,7 @@ void x11_ungrab_key ( Display *display, unsigned int modmask, KeySym key );
|
|||
*
|
||||
* Parse key from user input string.
|
||||
*/
|
||||
void x11_parse_key ( char *combo, unsigned int *mod, KeySym *key );
|
||||
gboolean x11_parse_key ( char *combo, unsigned int *mod, xkb_keysym_t *key );
|
||||
|
||||
/**
|
||||
* @param display The connection to the X server.
|
||||
|
@ -133,7 +93,7 @@ void x11_parse_key ( char *combo, unsigned int *mod, KeySym *key );
|
|||
*
|
||||
* Set the opacity of the window and sub-windows.
|
||||
*/
|
||||
void x11_set_window_opacity ( Display *display, Window box, unsigned int opacity );
|
||||
void x11_set_window_opacity ( xcb_window_t box, unsigned int opacity );
|
||||
|
||||
/**
|
||||
* Setup several items required.
|
||||
|
@ -141,15 +101,23 @@ void x11_set_window_opacity ( Display *display, Window box, unsigned int opacity
|
|||
* * Numlock detection
|
||||
* * Cache
|
||||
*/
|
||||
void x11_setup ( Display *display );
|
||||
void x11_setup ( xkb_stuff *xkb );
|
||||
|
||||
extern xcb_depth_t *depth;
|
||||
extern xcb_visualtype_t *visual;
|
||||
extern xcb_colormap_t map;
|
||||
extern xcb_depth_t *root_depth;
|
||||
extern xcb_visualtype_t *root_visual;
|
||||
/**
|
||||
* @param display Connection to the X server.
|
||||
*
|
||||
* This function tries to create a 32bit TrueColor colormap.
|
||||
* If this fails, it falls back to the default for the connected display.
|
||||
*/
|
||||
void create_visual_and_colormap ( Display *display );
|
||||
void x11_create_visual_and_colormap ( void );
|
||||
|
||||
typedef struct
|
||||
{
|
||||
double red, green, blue, alpha;
|
||||
} Color;
|
||||
|
||||
/**
|
||||
* @param display Connection to the X server.
|
||||
|
@ -157,15 +125,12 @@ void create_visual_and_colormap ( Display *display );
|
|||
*
|
||||
* Allocate a pixel value for an X named color
|
||||
*/
|
||||
unsigned int color_get ( Display *display, const char *const name, const char * const defn );
|
||||
Color color_get ( const char *const name );
|
||||
|
||||
void color_background ( Display *display, cairo_t *d );
|
||||
void color_border ( Display *display, cairo_t *d );
|
||||
void color_separator ( Display *display, cairo_t *d );
|
||||
void color_cache_reset ( void );
|
||||
void color_background ( cairo_t *d );
|
||||
void color_border ( cairo_t *d );
|
||||
void color_separator ( cairo_t *d );
|
||||
|
||||
cairo_format_t get_format ( void );
|
||||
|
||||
void x11_helper_set_cairo_rgba ( cairo_t *d, unsigned int pixel );
|
||||
void x11_helper_set_cairo_rgba ( cairo_t *d, Color col );
|
||||
/*@}*/
|
||||
#endif
|
||||
|
|
24
include/xcb-internal.h
Normal file
24
include/xcb-internal.h
Normal file
|
@ -0,0 +1,24 @@
|
|||
#ifndef ROFI_XCB_INTERNAL_H
|
||||
#define ROFI_XCB_INTERNAL_H
|
||||
|
||||
#define SN_API_NOT_YET_FROZEN
|
||||
#include <libsn/sn.h>
|
||||
|
||||
#include <xcb/xcb.h>
|
||||
#include <xcb/xcb_ewmh.h>
|
||||
/**
|
||||
* Structure to keep xcb stuff around.
|
||||
*/
|
||||
|
||||
struct _xcb_stuff
|
||||
{
|
||||
xcb_connection_t *connection;
|
||||
xcb_ewmh_connection_t ewmh;
|
||||
xcb_screen_t *screen;
|
||||
int screen_nbr;
|
||||
SnDisplay *sndisplay;
|
||||
SnLauncheeContext *sncontext;
|
||||
gboolean has_xinerama;
|
||||
};
|
||||
|
||||
#endif
|
10
include/xcb.h
Normal file
10
include/xcb.h
Normal file
|
@ -0,0 +1,10 @@
|
|||
#ifndef ROFI_XCB_H
|
||||
#define ROFI_XCB_H
|
||||
|
||||
typedef struct _xcb_stuff xcb_stuff;
|
||||
|
||||
extern xcb_stuff *xcb;
|
||||
|
||||
xcb_window_t xcb_stuff_get_root_window ( xcb_stuff *xcb );
|
||||
void xcb_stuff_wipe ( xcb_stuff *xcb );
|
||||
#endif
|
22
include/xkb-internal.h
Normal file
22
include/xkb-internal.h
Normal file
|
@ -0,0 +1,22 @@
|
|||
#ifndef ROFI_XKB_INTERNAL_H
|
||||
#define ROFI_XKB_INTERNAL_H
|
||||
|
||||
#include <xkbcommon/xkbcommon.h>
|
||||
#include <xkbcommon/xkbcommon-compose.h>
|
||||
|
||||
struct xkb_stuff
|
||||
{
|
||||
xcb_connection_t *xcb_connection;
|
||||
struct xkb_context *context;
|
||||
uint8_t first_event;
|
||||
int32_t device_id;
|
||||
struct xkb_keymap *keymap;
|
||||
struct xkb_state *state;
|
||||
struct
|
||||
{
|
||||
struct xkb_compose_table *table;
|
||||
struct xkb_compose_state * state;
|
||||
} compose;
|
||||
};
|
||||
|
||||
#endif
|
5
include/xkb.h
Normal file
5
include/xkb.h
Normal file
|
@ -0,0 +1,5 @@
|
|||
#ifndef ROFI_XKB_H
|
||||
#define ROFI_XKB_H
|
||||
|
||||
typedef struct xkb_stuff xkb_stuff;
|
||||
#endif
|
|
@ -1,5 +1,6 @@
|
|||
#ifndef ROFI_XRMOPTIONS_H
|
||||
#define ROFI_XRMOPTIONS_H
|
||||
#include "xcb.h"
|
||||
// Big thanks to Sean Pringle for this code.
|
||||
|
||||
/**
|
||||
|
@ -52,7 +53,7 @@ typedef enum
|
|||
*
|
||||
* @ingroup CONFXServer
|
||||
*/
|
||||
void config_parse_xresource_options ( Display *display );
|
||||
void config_parse_xresource_options ( xcb_stuff *xcb );
|
||||
|
||||
/**
|
||||
* @ingroup CONFFile
|
||||
|
@ -79,7 +80,7 @@ void config_parse_cmd_options_dynamic ( void );
|
|||
*
|
||||
* @ingroup CONFXServer
|
||||
*/
|
||||
void config_parse_xresource_options_dynamic ( Display *display );
|
||||
void config_parse_xresource_options_dynamic ( xcb_stuff *xcb );
|
||||
|
||||
/**
|
||||
* @ingroup CONFFile
|
||||
|
|
1
libgwater
Submodule
1
libgwater
Submodule
|
@ -0,0 +1 @@
|
|||
Subproject commit 75581cadfe6206c35b4229a8848f4faf5c745d54
|
20
libgwater-xcb-nolibtool.mk
Normal file
20
libgwater-xcb-nolibtool.mk
Normal file
|
@ -0,0 +1,20 @@
|
|||
noinst_LIBRARIES += \
|
||||
libgwater/libgwater-xcb.a
|
||||
|
||||
libgwater_libgwater_xcb_a_SOURCES = \
|
||||
libgwater/xcb/libgwater-xcb.c \
|
||||
libgwater/xcb/libgwater-xcb.h
|
||||
|
||||
libgwater_libgwater_xcb_a_CFLAGS = \
|
||||
$(AM_CFLAGS) \
|
||||
$(GW_XCB_INTERNAL_CFLAGS)
|
||||
|
||||
|
||||
GW_XCB_CFLAGS = \
|
||||
-I$(srcdir)/libgwater/xcb \
|
||||
$(GW_XCB_INTERNAL_CFLAGS)
|
||||
|
||||
GW_XCB_LIBS = \
|
||||
libgwater/libgwater-xcb.a \
|
||||
$(GW_XCB_INTERNAL_LIBS)
|
||||
|
|
@ -258,9 +258,6 @@ Mode combi_mode =
|
|||
{
|
||||
.name = "combi",
|
||||
.cfg_name_key = "display-combi",
|
||||
.keycfg = NULL,
|
||||
.keystr = NULL,
|
||||
.modmask = AnyModifier,
|
||||
._init = combi_mode_init,
|
||||
._get_num_entries = combi_mode_get_num_entries,
|
||||
._result = combi_mode_result,
|
||||
|
|
|
@ -44,9 +44,6 @@
|
|||
// We limit at 1000000 rows for now.
|
||||
#define DMENU_MAX_ROWS 1000000
|
||||
|
||||
// TODO HACK TO BE REMOVED
|
||||
extern Display *display;
|
||||
|
||||
struct range_pair
|
||||
{
|
||||
unsigned int start;
|
||||
|
@ -344,9 +341,6 @@ Mode dmenu_mode =
|
|||
{
|
||||
.name = "dmenu",
|
||||
.cfg_name_key = "display-combi",
|
||||
.keycfg = NULL,
|
||||
.keystr = NULL,
|
||||
.modmask = AnyModifier,
|
||||
._init = dmenu_mode_init,
|
||||
._get_num_entries = dmenu_mode_get_num_entries,
|
||||
._result = NULL,
|
||||
|
@ -359,10 +353,26 @@ Mode dmenu_mode =
|
|||
.free = NULL
|
||||
};
|
||||
|
||||
static void dmenu_finish ( RofiViewState *state, int retv )
|
||||
{
|
||||
if ( retv == FALSE ) {
|
||||
rofi_set_return_code ( EXIT_FAILURE );
|
||||
}
|
||||
else if ( retv >= 10 ) {
|
||||
rofi_set_return_code ( retv );
|
||||
}
|
||||
else{
|
||||
rofi_set_return_code ( EXIT_SUCCESS );
|
||||
}
|
||||
rofi_view_set_active ( NULL );
|
||||
rofi_view_free ( state );
|
||||
mode_destroy ( &dmenu_mode );
|
||||
}
|
||||
|
||||
static void dmenu_finalize ( RofiViewState *state )
|
||||
{
|
||||
int retv = FALSE;
|
||||
DmenuModePrivateData *pd = (DmenuModePrivateData *) (Mode *) ( rofi_view_get_mode ( state ) )->private_data;
|
||||
DmenuModePrivateData *pd = (DmenuModePrivateData *) rofi_view_get_mode ( state )->private_data;
|
||||
unsigned int cmd_list_length = pd->cmd_list_length;
|
||||
char **cmd_list = pd->cmd_list;
|
||||
|
||||
|
@ -373,7 +383,6 @@ static void dmenu_finalize ( RofiViewState *state )
|
|||
|
||||
int restart = 0;
|
||||
// Special behavior.
|
||||
// TODO clean this up!
|
||||
if ( pd->only_selected ) {
|
||||
/**
|
||||
* Select item mode.
|
||||
|
@ -391,22 +400,8 @@ static void dmenu_finalize ( RofiViewState *state )
|
|||
if ( ( mretv & MENU_QUICK_SWITCH ) ) {
|
||||
retv = 10 + ( mretv & MENU_LOWER_MASK );
|
||||
}
|
||||
rofi_view_free ( state );
|
||||
g_free ( input );
|
||||
mode_destroy ( &dmenu_mode );
|
||||
if ( retv == FALSE ) {
|
||||
rofi_set_return_code ( EXIT_FAILURE );
|
||||
}
|
||||
else if ( retv >= 10 ) {
|
||||
rofi_set_return_code ( retv );
|
||||
}
|
||||
else{
|
||||
rofi_set_return_code ( EXIT_SUCCESS );
|
||||
}
|
||||
rofi_view_free ( state );
|
||||
mode_destroy ( &dmenu_mode );
|
||||
rofi_view_set_active ( NULL );
|
||||
// g_main_loop_quit(NULL);
|
||||
dmenu_finish ( state, retv );
|
||||
return;
|
||||
}
|
||||
pd->selected_line = next_pos - 1;
|
||||
|
@ -414,6 +409,9 @@ static void dmenu_finalize ( RofiViewState *state )
|
|||
// Restart
|
||||
rofi_view_restart ( state );
|
||||
rofi_view_set_selected_line ( state, pd->selected_line );
|
||||
if ( !restart ) {
|
||||
dmenu_finish ( state, retv );
|
||||
}
|
||||
return;
|
||||
}
|
||||
// We normally do not want to restart the loop.
|
||||
|
@ -474,18 +472,7 @@ static void dmenu_finalize ( RofiViewState *state )
|
|||
rofi_view_set_selected_line ( state, pd->selected_line );
|
||||
}
|
||||
else {
|
||||
if ( retv == FALSE ) {
|
||||
rofi_set_return_code ( EXIT_FAILURE );
|
||||
}
|
||||
else if ( retv >= 10 ) {
|
||||
rofi_set_return_code ( retv );
|
||||
}
|
||||
else{
|
||||
rofi_set_return_code ( EXIT_SUCCESS );
|
||||
}
|
||||
rofi_view_free ( state );
|
||||
mode_destroy ( &dmenu_mode );
|
||||
rofi_view_set_active ( NULL );
|
||||
dmenu_finish ( state, retv );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -27,7 +27,6 @@
|
|||
#include <config.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <X11/X.h>
|
||||
|
||||
#include <unistd.h>
|
||||
#include <limits.h>
|
||||
|
@ -431,9 +430,6 @@ Mode drun_mode =
|
|||
{
|
||||
.name = "drun",
|
||||
.cfg_name_key = "display-drun",
|
||||
.keycfg = NULL,
|
||||
.keystr = NULL,
|
||||
.modmask = AnyModifier,
|
||||
._init = drun_mode_init,
|
||||
._get_num_entries = drun_mode_get_num_entries,
|
||||
._result = drun_mode_result,
|
||||
|
|
|
@ -32,7 +32,6 @@
|
|||
#include <config.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <X11/X.h>
|
||||
|
||||
#include <unistd.h>
|
||||
#include <limits.h>
|
||||
|
@ -432,9 +431,6 @@ Mode run_mode =
|
|||
{
|
||||
.name = "run",
|
||||
.cfg_name_key = "display-run",
|
||||
.keycfg = NULL,
|
||||
.keystr = NULL,
|
||||
.modmask = AnyModifier,
|
||||
._init = run_mode_init,
|
||||
._get_num_entries = run_mode_get_num_entries,
|
||||
._result = run_mode_result,
|
||||
|
|
|
@ -195,8 +195,6 @@ Mode *script_switcher_parse_setup ( const char *str )
|
|||
g_free ( parse );
|
||||
if ( index == 2 ) {
|
||||
sw->free = script_switcher_free;
|
||||
sw->keysym = None;
|
||||
sw->modmask = AnyModifier;
|
||||
sw->_init = script_mode_init;
|
||||
sw->_get_num_entries = script_mode_get_num_entries;
|
||||
sw->_result = script_mode_result;
|
||||
|
|
|
@ -493,9 +493,6 @@ Mode ssh_mode =
|
|||
{
|
||||
.name = "ssh",
|
||||
.cfg_name_key = "display-ssh",
|
||||
.keycfg = NULL,
|
||||
.keystr = NULL,
|
||||
.modmask = AnyModifier,
|
||||
._init = ssh_mode_init,
|
||||
._get_num_entries = ssh_mode_get_num_entries,
|
||||
._result = ssh_mode_result,
|
||||
|
|
|
@ -34,9 +34,14 @@
|
|||
#include <strings.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <X11/X.h>
|
||||
#include <X11/Xatom.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <xcb/xcb.h>
|
||||
#include <xcb/xcb_ewmh.h>
|
||||
#include <xcb/xcb_icccm.h>
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#include "xcb-internal.h"
|
||||
#include "xcb.h"
|
||||
|
||||
#include "rofi.h"
|
||||
#include "settings.h"
|
||||
|
@ -48,35 +53,36 @@
|
|||
|
||||
#define WINLIST 32
|
||||
|
||||
#define CLIENTTITLE 100
|
||||
#define CLIENTCLASS 50
|
||||
#define CLIENTSTATE 10
|
||||
#define CLIENTWINDOWTYPE 10
|
||||
#define CLIENTROLE 50
|
||||
|
||||
// a manageable window
|
||||
typedef struct
|
||||
{
|
||||
Window window, trans;
|
||||
XWindowAttributes xattr;
|
||||
char *title;
|
||||
char *class;
|
||||
char *name;
|
||||
char *role;
|
||||
int states;
|
||||
Atom state[CLIENTSTATE];
|
||||
int window_types;
|
||||
Atom window_type[CLIENTWINDOWTYPE];
|
||||
workarea monitor;
|
||||
int active;
|
||||
int demands;
|
||||
long hint_flags;
|
||||
xcb_window_t window;
|
||||
xcb_get_window_attributes_reply_t xattr;
|
||||
char *title;
|
||||
char *class;
|
||||
char *name;
|
||||
char *role;
|
||||
int states;
|
||||
xcb_atom_t state[CLIENTSTATE];
|
||||
int window_types;
|
||||
xcb_atom_t window_type[CLIENTWINDOWTYPE];
|
||||
int active;
|
||||
int demands;
|
||||
long hint_flags;
|
||||
} client;
|
||||
// TODO
|
||||
extern Display *display;
|
||||
|
||||
// window lists
|
||||
typedef struct
|
||||
{
|
||||
Window *array;
|
||||
client **data;
|
||||
int len;
|
||||
xcb_window_t *array;
|
||||
client **data;
|
||||
int len;
|
||||
} winlist;
|
||||
|
||||
winlist *cache_client = NULL;
|
||||
|
@ -90,7 +96,7 @@ static winlist* winlist_new ()
|
|||
{
|
||||
winlist *l = g_malloc ( sizeof ( winlist ) );
|
||||
l->len = 0;
|
||||
l->array = g_malloc_n ( WINLIST + 1, sizeof ( Window ) );
|
||||
l->array = g_malloc_n ( WINLIST + 1, sizeof ( xcb_window_t ) );
|
||||
l->data = g_malloc_n ( WINLIST + 1, sizeof ( client* ) );
|
||||
return l;
|
||||
}
|
||||
|
@ -104,10 +110,10 @@ static winlist* winlist_new ()
|
|||
*
|
||||
* @returns 0 if failed, 1 is successful.
|
||||
*/
|
||||
static int winlist_append ( winlist *l, Window w, client *d )
|
||||
static int winlist_append ( winlist *l, xcb_window_t w, client *d )
|
||||
{
|
||||
if ( l->len > 0 && !( l->len % WINLIST ) ) {
|
||||
l->array = g_realloc ( l->array, sizeof ( Window ) * ( l->len + WINLIST + 1 ) );
|
||||
l->array = g_realloc ( l->array, sizeof ( xcb_window_t ) * ( l->len + WINLIST + 1 ) );
|
||||
l->data = g_realloc ( l->data, sizeof ( client* ) * ( l->len + WINLIST + 1 ) );
|
||||
}
|
||||
// Make clang-check happy.
|
||||
|
@ -158,7 +164,7 @@ static void winlist_free ( winlist *l )
|
|||
*
|
||||
* @returns -1 if failed, index is successful.
|
||||
*/
|
||||
static int winlist_find ( winlist *l, Window w )
|
||||
static int winlist_find ( winlist *l, xcb_window_t w )
|
||||
{
|
||||
// iterate backwards. Theory is: windows most often accessed will be
|
||||
// nearer the end. Testing with kcachegrind seems to support this...
|
||||
|
@ -200,17 +206,17 @@ static void x11_cache_free ( void )
|
|||
*
|
||||
* @returns a XWindowAttributes
|
||||
*/
|
||||
static XWindowAttributes* window_get_attributes ( Display *display, Window w )
|
||||
static xcb_get_window_attributes_reply_t * window_get_attributes ( xcb_window_t w )
|
||||
{
|
||||
XWindowAttributes *cattr = g_malloc ( sizeof ( XWindowAttributes ) );
|
||||
|
||||
if ( XGetWindowAttributes ( display, w, cattr ) ) {
|
||||
return cattr;
|
||||
xcb_get_window_attributes_cookie_t c = xcb_get_window_attributes ( xcb->connection, w );
|
||||
xcb_get_window_attributes_reply_t *r = xcb_get_window_attributes_reply ( xcb->connection, c, NULL );
|
||||
if ( r ) {
|
||||
return r;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
// _NET_WM_STATE_*
|
||||
static int client_has_state ( client *c, Atom state )
|
||||
static int client_has_state ( client *c, xcb_atom_t state )
|
||||
{
|
||||
for ( int i = 0; i < c->states; i++ ) {
|
||||
if ( c->state[i] == state ) {
|
||||
|
@ -220,7 +226,7 @@ static int client_has_state ( client *c, Atom state )
|
|||
|
||||
return 0;
|
||||
}
|
||||
static int client_has_window_type ( client *c, Atom type )
|
||||
static int client_has_window_type ( client *c, xcb_atom_t type )
|
||||
{
|
||||
for ( int i = 0; i < c->window_types; i++ ) {
|
||||
if ( c->window_type[i] == type ) {
|
||||
|
@ -231,9 +237,9 @@ static int client_has_window_type ( client *c, Atom type )
|
|||
return 0;
|
||||
}
|
||||
|
||||
static client* window_client ( Display *display, Window win )
|
||||
static client* window_client ( xcb_window_t win )
|
||||
{
|
||||
if ( win == None ) {
|
||||
if ( win == XCB_WINDOW_NONE ) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -244,56 +250,51 @@ static client* window_client ( Display *display, Window win )
|
|||
}
|
||||
|
||||
// if this fails, we're up that creek
|
||||
XWindowAttributes *attr = window_get_attributes ( display, win );
|
||||
xcb_get_window_attributes_reply_t *attr = window_get_attributes ( win );
|
||||
|
||||
if ( !attr ) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
client *c = g_malloc0 ( sizeof ( client ) );
|
||||
c->window = win;
|
||||
|
||||
// copy xattr so we don't have to care when stuff is freed
|
||||
memmove ( &c->xattr, attr, sizeof ( XWindowAttributes ) );
|
||||
XGetTransientForHint ( display, win, &c->trans );
|
||||
memmove ( &c->xattr, attr, sizeof ( xcb_get_window_attributes_reply_t ) );
|
||||
|
||||
c->states = window_get_atom_prop ( display, win, netatoms[_NET_WM_STATE], c->state, CLIENTSTATE );
|
||||
|
||||
c->window_types = window_get_atom_prop ( display, win, netatoms[_NET_WM_WINDOW_TYPE], c->window_type, CLIENTWINDOWTYPE );
|
||||
char *name;
|
||||
|
||||
if ( ( name = window_get_text_prop ( display, c->window, netatoms[_NET_WM_NAME] ) ) && name ) {
|
||||
c->title = name;
|
||||
name = NULL;
|
||||
xcb_get_property_cookie_t cky = xcb_ewmh_get_wm_state ( &xcb->ewmh, win );
|
||||
xcb_ewmh_get_atoms_reply_t states;
|
||||
if ( xcb_ewmh_get_wm_state_reply ( &xcb->ewmh, cky, &states, NULL ) ) {
|
||||
c->states = MIN ( CLIENTSTATE, states.atoms_len );
|
||||
memcpy ( c->state, states.atoms, MIN ( CLIENTSTATE, states.atoms_len ) );
|
||||
xcb_ewmh_get_atoms_reply_wipe ( &states );
|
||||
}
|
||||
else if ( XFetchName ( display, c->window, &name ) ) {
|
||||
c->title = g_strdup ( name );
|
||||
XFree ( name );
|
||||
cky = xcb_ewmh_get_wm_window_type ( &xcb->ewmh, win );
|
||||
if ( xcb_ewmh_get_wm_window_type_reply ( &xcb->ewmh, cky, &states, NULL ) ) {
|
||||
c->window_types = MIN ( CLIENTWINDOWTYPE, states.atoms_len );
|
||||
memcpy ( c->window_type, states.atoms, MIN ( CLIENTWINDOWTYPE, states.atoms_len ) );
|
||||
xcb_ewmh_get_atoms_reply_wipe ( &states );
|
||||
}
|
||||
|
||||
name = window_get_text_prop ( display, c->window, XInternAtom ( display, "WM_WINDOW_ROLE", False ) );
|
||||
|
||||
if ( name != NULL ) {
|
||||
c->role = g_strdup ( name );
|
||||
XFree ( name );
|
||||
c->title = window_get_text_prop ( c->window, xcb->ewmh._NET_WM_NAME );
|
||||
if ( c->title == NULL ) {
|
||||
c->title = window_get_text_prop ( c->window, XCB_ATOM_WM_NAME );
|
||||
}
|
||||
|
||||
XClassHint chint;
|
||||
c->role = window_get_text_prop ( c->window, netatoms[WM_WINDOW_ROLE] );
|
||||
|
||||
if ( XGetClassHint ( display, c->window, &chint ) ) {
|
||||
c->class = g_strdup ( chint.res_class );
|
||||
c->name = g_strdup ( chint.res_name );
|
||||
XFree ( chint.res_class );
|
||||
XFree ( chint.res_name );
|
||||
cky = xcb_icccm_get_wm_class ( xcb->connection, c->window );
|
||||
xcb_icccm_get_wm_class_reply_t wcr;
|
||||
if ( xcb_icccm_get_wm_class_reply ( xcb->connection, cky, &wcr, NULL ) ) {
|
||||
c->class = g_strdup ( wcr.class_name );
|
||||
xcb_icccm_get_wm_class_reply_wipe ( &wcr );
|
||||
}
|
||||
|
||||
XWMHints *wh;
|
||||
if ( ( wh = XGetWMHints ( display, c->window ) ) != NULL ) {
|
||||
c->hint_flags = wh->flags;
|
||||
XFree ( wh );
|
||||
xcb_get_property_cookie_t cc = xcb_icccm_get_wm_hints ( xcb->connection, c->window );
|
||||
xcb_icccm_wm_hints_t r;
|
||||
if ( xcb_icccm_get_wm_hints_reply ( xcb->connection, cc, &r, NULL ) ) {
|
||||
c->hint_flags = r.flags;
|
||||
}
|
||||
|
||||
monitor_dimensions ( display, c->xattr.screen, c->xattr.x, c->xattr.y, &c->monitor );
|
||||
winlist_append ( cache_client, c->window, c );
|
||||
g_free ( attr );
|
||||
return c;
|
||||
|
@ -363,68 +364,67 @@ static unsigned int window_mode_get_num_entries ( const Mode *sw )
|
|||
}
|
||||
static void _window_mode_load_data ( Mode *sw, unsigned int cd )
|
||||
{
|
||||
ModeModePrivateData *pd = (ModeModePrivateData *) mode_get_private_data ( sw );
|
||||
Screen *screen = DefaultScreenOfDisplay ( display );
|
||||
Window root = RootWindow ( display, XScreenNumberOfScreen ( screen ) );
|
||||
ModeModePrivateData *pd = (ModeModePrivateData *) mode_get_private_data ( sw );
|
||||
// find window list
|
||||
Atom type;
|
||||
int nwins = 0;
|
||||
Window wins[100];
|
||||
int count = 0;
|
||||
Window curr_win_id = 0;
|
||||
xcb_window_t wins[100];
|
||||
xcb_window_t curr_win_id;
|
||||
// Create cache
|
||||
|
||||
x11_cache_create ();
|
||||
// Check for i3
|
||||
pd->config_i3_mode = i3_support_initialize ( display );
|
||||
|
||||
// Get the active window so we can highlight this.
|
||||
if ( !( window_get_prop ( display, root, netatoms[_NET_ACTIVE_WINDOW], &type, &count, &curr_win_id, sizeof ( Window ) )
|
||||
&& type == XA_WINDOW && count > 0 ) ) {
|
||||
pd->config_i3_mode = i3_support_initialize ( xcb );
|
||||
xcb_get_property_cookie_t c = xcb_ewmh_get_active_window ( &( xcb->ewmh ), xcb->screen_nbr );
|
||||
if ( !xcb_ewmh_get_active_window_reply ( &xcb->ewmh, c, &curr_win_id, NULL ) ) {
|
||||
curr_win_id = 0;
|
||||
}
|
||||
|
||||
// Get the current desktop.
|
||||
unsigned long current_desktop = 0;
|
||||
if ( !window_get_cardinal_prop ( display, root, netatoms[_NET_CURRENT_DESKTOP], ¤t_desktop, 1 ) ) {
|
||||
unsigned int current_desktop = 0;
|
||||
c = xcb_ewmh_get_current_desktop ( &xcb->ewmh, xcb->screen_nbr );
|
||||
if ( !xcb_ewmh_get_current_desktop_reply ( &xcb->ewmh, c, ¤t_desktop, NULL ) ) {
|
||||
current_desktop = 0;
|
||||
}
|
||||
|
||||
unsigned int nw = 100 * sizeof ( Window );
|
||||
// First try Stacking order.. If this fails.
|
||||
if ( !( window_get_prop ( display, root, netatoms[_NET_CLIENT_LIST_STACKING], &type, &nwins, wins, nw )
|
||||
&& type == XA_WINDOW ) ) {
|
||||
// Try to get order by age.
|
||||
if ( !( window_get_prop ( display, root, netatoms[_NET_CLIENT_LIST], &type, &nwins, wins, nw )
|
||||
&& type == XA_WINDOW ) ) {
|
||||
nwins = 0;
|
||||
c = xcb_ewmh_get_client_list_stacking ( &xcb->ewmh, 0 );
|
||||
xcb_ewmh_get_windows_reply_t clients;
|
||||
if ( xcb_ewmh_get_client_list_stacking_reply ( &xcb->ewmh, c, &clients, NULL ) ) {
|
||||
nwins = MIN ( 100, clients.windows_len );
|
||||
memcpy ( wins, clients.windows, nwins * sizeof ( xcb_window_t ) );
|
||||
xcb_ewmh_get_windows_reply_wipe ( &clients );
|
||||
}
|
||||
else {
|
||||
c = xcb_ewmh_get_client_list ( &xcb->ewmh, xcb->screen_nbr );
|
||||
if ( xcb_ewmh_get_client_list_reply ( &xcb->ewmh, c, &clients, NULL ) ) {
|
||||
nwins = MIN ( 100, clients.windows_len );
|
||||
memcpy ( wins, clients.windows, nwins * sizeof ( xcb_window_t ) );
|
||||
xcb_ewmh_get_windows_reply_wipe ( &clients );
|
||||
}
|
||||
}
|
||||
if ( nwins > 0 ) {
|
||||
char pattern[50];
|
||||
int i;
|
||||
unsigned int classfield = 0;
|
||||
unsigned long desktops = 0;
|
||||
char pattern[50];
|
||||
int i;
|
||||
unsigned int classfield = 0;
|
||||
unsigned int desktops = 0;
|
||||
// windows we actually display. May be slightly different to _NET_CLIENT_LIST_STACKING
|
||||
// if we happen to have a window destroyed while we're working...
|
||||
pd->ids = winlist_new ();
|
||||
|
||||
// calc widths of fields
|
||||
for ( i = nwins - 1; i > -1; i-- ) {
|
||||
client *c;
|
||||
|
||||
if ( ( c = window_client ( display, wins[i] ) )
|
||||
client *c = window_client ( wins[i] );
|
||||
if ( ( c != NULL )
|
||||
&& !c->xattr.override_redirect
|
||||
&& !client_has_window_type ( c, netatoms[_NET_WM_WINDOW_TYPE_DOCK] )
|
||||
&& !client_has_window_type ( c, netatoms[_NET_WM_WINDOW_TYPE_DESKTOP] )
|
||||
&& !client_has_state ( c, netatoms[_NET_WM_STATE_SKIP_PAGER] )
|
||||
&& !client_has_state ( c, netatoms[_NET_WM_STATE_SKIP_TASKBAR] ) ) {
|
||||
classfield = MAX ( classfield, ( c->class != NULL ) ? strlen ( c->class ) : 0 );
|
||||
&& !client_has_window_type ( c, xcb->ewmh._NET_WM_WINDOW_TYPE_DOCK )
|
||||
&& !client_has_window_type ( c, xcb->ewmh._NET_WM_WINDOW_TYPE_DESKTOP )
|
||||
&& !client_has_state ( c, xcb->ewmh._NET_WM_STATE_SKIP_PAGER )
|
||||
&& !client_has_state ( c, xcb->ewmh._NET_WM_STATE_SKIP_TASKBAR ) ) {
|
||||
classfield = MAX ( classfield, strlen ( c->class ) );
|
||||
|
||||
if ( client_has_state ( c, netatoms[_NET_WM_STATE_DEMANDS_ATTENTION] ) ) {
|
||||
if ( client_has_state ( c, xcb->ewmh._NET_WM_STATE_DEMANDS_ATTENTION ) ) {
|
||||
c->demands = TRUE;
|
||||
}
|
||||
if ( ( c->hint_flags & XUrgencyHint ) == XUrgencyHint ) {
|
||||
if ( ( c->hint_flags & XCB_ICCCM_WM_HINT_X_URGENCY ) != 0 ) {
|
||||
c->demands = TRUE;
|
||||
}
|
||||
|
||||
|
@ -436,9 +436,11 @@ static void _window_mode_load_data ( Mode *sw, unsigned int cd )
|
|||
}
|
||||
|
||||
// Create pattern for printing the line.
|
||||
if ( !window_get_cardinal_prop ( display, root, netatoms[_NET_NUMBER_OF_DESKTOPS], &desktops, 1 ) ) {
|
||||
xcb_get_property_cookie_t c = xcb_ewmh_get_number_of_desktops ( &xcb->ewmh, xcb->screen_nbr );
|
||||
if ( !xcb_ewmh_get_number_of_desktops_reply ( &xcb->ewmh, c, &desktops, NULL ) ) {
|
||||
desktops = 1;
|
||||
}
|
||||
|
||||
if ( pd->config_i3_mode ) {
|
||||
snprintf ( pattern, 50, "%%-%ds %%s", MAX ( 5, classfield ) );
|
||||
}
|
||||
|
@ -450,27 +452,39 @@ static void _window_mode_load_data ( Mode *sw, unsigned int cd )
|
|||
|
||||
// build the actual list
|
||||
for ( i = 0; i < ( pd->ids->len ); i++ ) {
|
||||
Window w = pd->ids->array[i];
|
||||
client *c;
|
||||
xcb_window_t w = pd->ids->array[i];
|
||||
client *c;
|
||||
|
||||
if ( ( c = window_client ( display, w ) ) ) {
|
||||
if ( ( c = window_client ( w ) ) ) {
|
||||
// final line format
|
||||
unsigned long wmdesktop;
|
||||
char desktop[5];
|
||||
char desktop[5];
|
||||
desktop[0] = 0;
|
||||
size_t len =
|
||||
size_t len =
|
||||
( ( c->title != NULL ) ? strlen ( c->title ) : 0 ) + ( c->class ? strlen ( c->class ) : 0 ) + classfield + 50;
|
||||
char *line = g_malloc ( len );
|
||||
char *line = g_malloc ( len );
|
||||
if ( !pd->config_i3_mode ) {
|
||||
unsigned int wmdesktop = 0;
|
||||
// find client's desktop.
|
||||
if ( !window_get_cardinal_prop ( display, c->window, netatoms[_NET_WM_DESKTOP], &wmdesktop, 1 ) ) {
|
||||
xcb_get_property_cookie_t cookie;
|
||||
xcb_get_property_reply_t *r;
|
||||
|
||||
cookie =
|
||||
xcb_get_property ( xcb->connection, 0, c->window, xcb->ewmh._NET_WM_DESKTOP, XCB_GET_PROPERTY, 0,
|
||||
sizeof ( unsigned int ) );
|
||||
r = xcb_get_property_reply ( xcb->connection, cookie, NULL );
|
||||
if ( r && r->type == XCB_ATOM_INTEGER ) {
|
||||
wmdesktop = *( (int *) xcb_get_property_value ( r ) );
|
||||
}
|
||||
if ( r && r->type != XCB_ATOM_INTEGER ) {
|
||||
// Assume the client is on all desktops.
|
||||
wmdesktop = 0xFFFFFFFF;
|
||||
}
|
||||
else if ( cd && wmdesktop != current_desktop ) {
|
||||
g_free ( line );
|
||||
free ( r );
|
||||
continue;
|
||||
}
|
||||
free ( r );
|
||||
|
||||
if ( wmdesktop < 0xFFFFFFFF ) {
|
||||
snprintf ( desktop, 5, "%d", (int) wmdesktop );
|
||||
|
@ -525,17 +539,10 @@ static ModeMode window_mode_result ( Mode *sw, int mretv, G_GNUC_UNUSED char **i
|
|||
i3_support_focus_window ( rmpd->ids->array[selected_line] );
|
||||
}
|
||||
else{
|
||||
Screen *screen = DefaultScreenOfDisplay ( display );
|
||||
Window root = RootWindow ( display, XScreenNumberOfScreen ( screen ) );
|
||||
// Change to the desktop of the selected window/client.
|
||||
// TODO: get rid of strtol
|
||||
window_send_message ( display, root, root, netatoms[_NET_CURRENT_DESKTOP], strtol ( rmpd->cmd_list[selected_line], NULL, 10 ),
|
||||
SubstructureNotifyMask | SubstructureRedirectMask, 0 );
|
||||
XSync ( display, False );
|
||||
|
||||
window_send_message ( display, root, rmpd->ids->array[selected_line], netatoms[_NET_ACTIVE_WINDOW], 2, // 2 = pager
|
||||
SubstructureNotifyMask | SubstructureRedirectMask, 0 );
|
||||
XFlush ( display );
|
||||
xcb_ewmh_request_change_active_window ( &xcb->ewmh, xcb->screen_nbr, rmpd->ids->array[selected_line],
|
||||
XCB_EWMH_CLIENT_SOURCE_TYPE_OTHER,
|
||||
XCB_CURRENT_TIME, XCB_WINDOW_NONE );
|
||||
xcb_flush ( xcb->connection );
|
||||
}
|
||||
}
|
||||
return retv;
|
||||
|
@ -558,10 +565,10 @@ static void window_mode_destroy ( Mode *sw )
|
|||
static char *_get_display_value ( const Mode *sw, unsigned int selected_line, int *state, int get_entry )
|
||||
{
|
||||
ModeModePrivateData *rmpd = mode_get_private_data ( sw );
|
||||
if ( window_client ( display, rmpd->ids->array[selected_line] )->demands ) {
|
||||
if ( window_client ( rmpd->ids->array[selected_line] )->demands ) {
|
||||
*state |= URGENT;
|
||||
}
|
||||
if ( window_client ( display, rmpd->ids->array[selected_line] )->active ) {
|
||||
if ( window_client ( rmpd->ids->array[selected_line] )->active ) {
|
||||
*state |= ACTIVE;
|
||||
}
|
||||
return get_entry ? g_strdup ( rmpd->cmd_list[selected_line] ) : NULL;
|
||||
|
@ -584,9 +591,6 @@ static int window_is_not_ascii ( const Mode *sw, unsigned int index )
|
|||
if ( c->title && !g_str_is_ascii ( c->title ) ) {
|
||||
return TRUE;
|
||||
}
|
||||
if ( c->name && !g_str_is_ascii ( c->name ) ) {
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -595,9 +599,6 @@ Mode window_mode =
|
|||
{
|
||||
.name = "window",
|
||||
.cfg_name_key = "display-window",
|
||||
.keycfg = NULL,
|
||||
.keystr = NULL,
|
||||
.modmask = AnyModifier,
|
||||
._init = window_mode_init,
|
||||
._get_num_entries = window_mode_get_num_entries,
|
||||
._result = window_mode_result,
|
||||
|
@ -613,9 +614,6 @@ Mode window_mode_cd =
|
|||
{
|
||||
.name = "windowcd",
|
||||
.cfg_name_key = "display-windowcd",
|
||||
.keycfg = NULL,
|
||||
.keystr = NULL,
|
||||
.modmask = AnyModifier,
|
||||
._init = window_mode_init_cd,
|
||||
._get_num_entries = window_mode_get_num_entries,
|
||||
._result = window_mode_result,
|
||||
|
|
|
@ -39,14 +39,20 @@
|
|||
#include <sys/stat.h>
|
||||
#include <pwd.h>
|
||||
#include <ctype.h>
|
||||
#include <xcb/xcb.h>
|
||||
#include <pango/pango.h>
|
||||
#include <pango/pango-fontmap.h>
|
||||
#include <pango/pangocairo.h>
|
||||
#include "helper.h"
|
||||
#include "settings.h"
|
||||
#include "x11-helper.h"
|
||||
#include "rofi.h"
|
||||
#include "view.h"
|
||||
|
||||
static int stored_argc = 0;
|
||||
static char **stored_argv = NULL;
|
||||
extern xcb_connection_t *xcb_connection;
|
||||
extern xcb_screen_t *xcb_screen;
|
||||
static int stored_argc = 0;
|
||||
static char **stored_argv = NULL;
|
||||
|
||||
void cmd_set_arguments ( int argc, char **argv )
|
||||
{
|
||||
|
@ -508,15 +514,8 @@ void remove_pid_file ( int fd )
|
|||
*
|
||||
* This functions exits the program with 1 when it finds an invalid configuration.
|
||||
*/
|
||||
void config_sanity_check ( Display *display )
|
||||
int config_sanity_check ( void )
|
||||
{
|
||||
if ( config.threads == 0 ) {
|
||||
config.threads = 1;
|
||||
long procs = sysconf ( _SC_NPROCESSORS_CONF );
|
||||
if ( procs > 0 ) {
|
||||
config.threads = MIN ( procs, 128l );
|
||||
}
|
||||
}
|
||||
// If alternative row is not set, copy the normal background color.
|
||||
// Do this at the beginning as we might use it in the error dialog.
|
||||
if ( config.menu_bg_alt == NULL ) {
|
||||
|
@ -548,14 +547,6 @@ void config_sanity_check ( Display *display )
|
|||
config.location = WL_CENTER;
|
||||
found_error = 1;
|
||||
}
|
||||
if ( 0 ) {
|
||||
if ( !( config.line_margin <= 50 ) ) {
|
||||
g_string_append_printf ( msg, "\t<b>config.line_margin</b>=%d is invalid. Value should be between %d and %d.\n",
|
||||
config.line_margin, 0, 50 );
|
||||
config.line_margin = 2;
|
||||
found_error = 1;
|
||||
}
|
||||
}
|
||||
if ( config.fullscreen && config.monitor != -1 ) {
|
||||
g_string_append_printf ( msg,
|
||||
"\t<b>config.monitor</b>=%d is invalid. Value should be unset (-1) when fullscreen mode is enabled.\n",
|
||||
|
@ -566,10 +557,10 @@ void config_sanity_check ( Display *display )
|
|||
|
||||
// Check size
|
||||
{
|
||||
int ssize = monitor_get_smallest_size ( display );
|
||||
int ssize = monitor_get_smallest_size ( );
|
||||
if ( config.monitor >= 0 ) {
|
||||
workarea mon;
|
||||
if ( monitor_get_dimension ( display, DefaultScreenOfDisplay ( display ), config.monitor, &mon ) ) {
|
||||
if ( monitor_get_dimension ( config.monitor, &mon ) ) {
|
||||
ssize = MIN ( mon.w, mon.h );
|
||||
}
|
||||
else{
|
||||
|
@ -588,13 +579,27 @@ void config_sanity_check ( Display *display )
|
|||
}
|
||||
}
|
||||
|
||||
if ( config.menu_font ) {
|
||||
PangoFontDescription *pfd = pango_font_description_from_string ( config.menu_font );
|
||||
const char *fam = pango_font_description_get_family ( pfd );
|
||||
int size = pango_font_description_get_size ( pfd );
|
||||
if ( fam == NULL || size == 0 ) {
|
||||
g_string_append_printf ( msg, "Pango failed to parse font: '%s'\n", config.menu_font );
|
||||
g_string_append_printf ( msg, "Got font family: <b>%s</b> at size <b>%d</b>\n", fam ? fam : "{unknown}", size );
|
||||
config.menu_font = NULL;
|
||||
found_error = TRUE;
|
||||
}
|
||||
pango_font_description_free ( pfd );
|
||||
}
|
||||
|
||||
if ( found_error ) {
|
||||
g_string_append ( msg, "Please update your configuration." );
|
||||
show_error_message ( msg->str, TRUE );
|
||||
exit ( EXIT_FAILURE );
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
g_string_free ( msg, TRUE );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
char *rofi_expand_path ( const char *input )
|
||||
|
|
|
@ -33,11 +33,10 @@
|
|||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <time.h>
|
||||
#include <X11/X.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <xcb/xcb.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/un.h>
|
||||
|
||||
#include "xcb.h"
|
||||
#include "rofi.h"
|
||||
#include "x11-helper.h"
|
||||
#include "i3-support.h"
|
||||
|
@ -47,8 +46,7 @@
|
|||
#include <i3/ipc.h>
|
||||
// Path to HAVE_I3_IPC_H socket.
|
||||
char *i3_socket_path = NULL;
|
||||
|
||||
void i3_support_focus_window ( Window id )
|
||||
void i3_support_focus_window ( xcb_window_t id )
|
||||
{
|
||||
i3_ipc_header_t head;
|
||||
int s;
|
||||
|
@ -77,7 +75,7 @@ void i3_support_focus_window ( Window id )
|
|||
}
|
||||
|
||||
// Formulate command
|
||||
snprintf ( command, upm, "[id=\"%lu\"] focus", id );
|
||||
snprintf ( command, upm, "[id=\"%u\"] focus", id );
|
||||
// Prepare header.
|
||||
memcpy ( head.magic, I3_IPC_MAGIC, 6 );
|
||||
head.size = strlen ( command );
|
||||
|
@ -113,21 +111,13 @@ void i3_support_focus_window ( Window id )
|
|||
close ( s );
|
||||
}
|
||||
|
||||
int i3_support_initialize ( Display *display )
|
||||
int i3_support_initialize ( xcb_stuff *xcb )
|
||||
{
|
||||
// If we where initialized, clean this first.
|
||||
i3_support_free_internals ();
|
||||
// Get atom for I3_SOCKET_PATH
|
||||
Atom i3_sp_atom = XInternAtom ( display, "I3_SOCKET_PATH", False );
|
||||
|
||||
if ( i3_sp_atom != None ) {
|
||||
// Get the default screen.
|
||||
Screen *screen = DefaultScreenOfDisplay ( display );
|
||||
// Find the root window (each X has one.).
|
||||
Window root = RootWindow ( display, XScreenNumberOfScreen ( screen ) );
|
||||
// Get the i3 path property.
|
||||
i3_socket_path = window_get_text_prop ( display, root, i3_sp_atom );
|
||||
}
|
||||
// Get atom for I3_SOCKET_PATH
|
||||
i3_socket_path = window_get_text_prop ( xcb_stuff_get_root_window ( xcb ), netatoms[I3_SOCKET_PATH] );
|
||||
// If we find it, go into i3 mode.
|
||||
return ( i3_socket_path != NULL ) ? TRUE : FALSE;
|
||||
}
|
||||
|
@ -140,7 +130,7 @@ void i3_support_free_internals ( void )
|
|||
|
||||
#else
|
||||
|
||||
void i3_support_focus_window ( Window id )
|
||||
void i3_support_focus_window ( G_GNUC_UNUSED xcb_window_t id )
|
||||
{
|
||||
fprintf ( stderr, "Trying to control i3, when i3 support is not enabled.\n" );
|
||||
abort ();
|
||||
|
@ -149,7 +139,7 @@ void i3_support_free_internals ( void )
|
|||
{
|
||||
}
|
||||
|
||||
int i3_support_initialize ( Display *display )
|
||||
int i3_support_initialize ( G_GNUC_UNUSED xcb_stuff *xcb )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
|
126
source/keyb.c
126
source/keyb.c
|
@ -1,14 +1,13 @@
|
|||
#include <config.h>
|
||||
#include <string.h>
|
||||
#include "rofi.h"
|
||||
#include <X11/keysym.h>
|
||||
#include "x11-helper.h"
|
||||
#include "xrmoptions.h"
|
||||
|
||||
typedef struct _KeyBinding
|
||||
{
|
||||
unsigned int modmask;
|
||||
KeySym keysym;
|
||||
xkb_keysym_t keysym;
|
||||
} KeyBinding;
|
||||
|
||||
typedef struct _ActionBindingEntry
|
||||
|
@ -26,66 +25,65 @@ typedef struct _DefaultBinding
|
|||
char *keybinding;
|
||||
} DefaultBinding;
|
||||
|
||||
ActionBindingEntry abe[NUM_ABE];
|
||||
extern unsigned int CombinedMask;
|
||||
ActionBindingEntry abe[NUM_ABE];
|
||||
|
||||
/**
|
||||
* LIST OF DEFAULT SETTINGS
|
||||
*/
|
||||
DefaultBinding bindings[NUM_ABE] =
|
||||
{
|
||||
{ .id = PASTE_PRIMARY, .name = "kb-primary-paste", .keybinding = "Control+Shift+v,Shift+Insert", },
|
||||
{ .id = PASTE_SECONDARY, .name = "kb-secondary-paste", .keybinding = "Control+v,Insert", },
|
||||
{ .id = CLEAR_LINE, .name = "kb-clear-line", .keybinding = "Control+u", },
|
||||
{ .id = MOVE_FRONT, .name = "kb-move-front", .keybinding = "Control+a", },
|
||||
{ .id = MOVE_END, .name = "kb-move-end", .keybinding = "Control+e", },
|
||||
{ .id = MOVE_WORD_BACK, .name = "kb-move-word-back", .keybinding = "Alt+b", },
|
||||
{ .id = MOVE_WORD_FORWARD, .name = "kb-move-word-forward", .keybinding = "Alt+f", },
|
||||
{ .id = MOVE_CHAR_BACK, .name = "kb-move-char-back", .keybinding = "Left,Control+b" },
|
||||
{ .id = MOVE_CHAR_FORWARD, .name = "kb-move-char-forward", .keybinding = "Right,Control+f" },
|
||||
{ .id = REMOVE_WORD_BACK, .name = "kb-remove-word-back", .keybinding = "Control+Alt+h", },
|
||||
{ .id = REMOVE_WORD_FORWARD, .name = "kb-remove-word-forward", .keybinding = "Control+Alt+d", },
|
||||
{ .id = REMOVE_CHAR_FORWARD, .name = "kb-remove-char-forward", .keybinding = "Delete,Control+d", },
|
||||
{ .id = REMOVE_CHAR_BACK, .name = "kb-remove-char-back", .keybinding = "BackSpace,Control+h", },
|
||||
{ .id = ACCEPT_ENTRY, .name = "kb-accept-entry", .keybinding = "Control+j,Control+m,Return,KP_Enter", },
|
||||
{ .id = ACCEPT_CUSTOM, .name = "kb-accept-custom", .keybinding = "Control+Return", },
|
||||
{ .id = ACCEPT_ENTRY_CONTINUE, .name = "kb-accept-entry-continue", .keybinding = "Shift+Return", },
|
||||
{ .id = MODE_NEXT, .name = "kb-mode-next", .keybinding = "Shift+Right,Control+Tab" },
|
||||
{ .id = MODE_PREVIOUS, .name = "kb-mode-previous", .keybinding = "Shift+Left,Control+Shift+Tab" },
|
||||
{ .id = TOGGLE_CASE_SENSITIVITY, .name = "kb-toggle-case-sensitivity", .keybinding = "grave,dead_grave" },
|
||||
{ .id = DELETE_ENTRY, .name = "kb-delete-entry", .keybinding = "Shift+Delete" },
|
||||
{ .id = ROW_LEFT, .name = "kb-row-left", .keybinding = "Control+Page_Up" },
|
||||
{ .id = ROW_RIGHT, .name = "kb-row-right", .keybinding = "Control+Page_Down" },
|
||||
{ .id = PASTE_PRIMARY, .name = "kb-primary-paste", .keybinding = "Control+Shift+v,Shift+Insert", },
|
||||
{ .id = PASTE_SECONDARY, .name = "kb-secondary-paste", .keybinding = "Control+v,Insert", },
|
||||
{ .id = CLEAR_LINE, .name = "kb-clear-line", .keybinding = "Control+u", },
|
||||
{ .id = MOVE_FRONT, .name = "kb-move-front", .keybinding = "Control+a", },
|
||||
{ .id = MOVE_END, .name = "kb-move-end", .keybinding = "Control+e", },
|
||||
{ .id = MOVE_WORD_BACK, .name = "kb-move-word-back", .keybinding = "Alt+b", },
|
||||
{ .id = MOVE_WORD_FORWARD, .name = "kb-move-word-forward", .keybinding = "Alt+f", },
|
||||
{ .id = MOVE_CHAR_BACK, .name = "kb-move-char-back", .keybinding = "Left,Control+b" },
|
||||
{ .id = MOVE_CHAR_FORWARD, .name = "kb-move-char-forward", .keybinding = "Right,Control+f" },
|
||||
{ .id = REMOVE_WORD_BACK, .name = "kb-remove-word-back", .keybinding = "Control+Alt+h", },
|
||||
{ .id = REMOVE_WORD_FORWARD, .name = "kb-remove-word-forward", .keybinding = "Control+Alt+d", },
|
||||
{ .id = REMOVE_CHAR_FORWARD, .name = "kb-remove-char-forward", .keybinding = "Delete,Control+d", },
|
||||
{ .id = REMOVE_CHAR_BACK, .name = "kb-remove-char-back", .keybinding = "BackSpace,Control+h", },
|
||||
{ .id = ACCEPT_ENTRY, .name = "kb-accept-entry", .keybinding = "Control+j,Control+m,Return,KP_Enter", },
|
||||
{ .id = ACCEPT_CUSTOM, .name = "kb-accept-custom", .keybinding = "Control+Return", },
|
||||
{ .id = ACCEPT_ENTRY_CONTINUE, .name = "kb-accept-entry-continue", .keybinding = "Shift+Return", },
|
||||
{ .id = MODE_NEXT, .name = "kb-mode-next", .keybinding = "Shift+Right,Control+Tab" },
|
||||
{ .id = MODE_PREVIOUS, .name = "kb-mode-previous", .keybinding = "Shift+Left,Control+Shift+Tab" },
|
||||
{ .id = TOGGLE_CASE_SENSITIVITY, .name = "kb-toggle-case-sensitivity", .keybinding = "grave,dead_grave" },
|
||||
{ .id = DELETE_ENTRY, .name = "kb-delete-entry", .keybinding = "Shift+Delete" },
|
||||
{ .id = ROW_LEFT, .name = "kb-row-left", .keybinding = "Control+Page_Up" },
|
||||
{ .id = ROW_RIGHT, .name = "kb-row-right", .keybinding = "Control+Page_Down" },
|
||||
{ .id = ROW_UP, .name = "kb-row-up", .keybinding = "Up,Control+p,Shift+Tab,Shift+ISO_Left_Tab" },
|
||||
{ .id = ROW_DOWN, .name = "kb-row-down", .keybinding = "Down,Control+n" },
|
||||
{ .id = ROW_TAB, .name = "kb-row-tab", .keybinding = "Tab" },
|
||||
{ .id = PAGE_PREV, .name = "kb-page-prev", .keybinding = "Page_Up" },
|
||||
{ .id = PAGE_NEXT, .name = "kb-page-next", .keybinding = "Page_Down" },
|
||||
{ .id = ROW_FIRST, .name = "kb-row-first", .keybinding = "Home,KP_Home" },
|
||||
{ .id = ROW_LAST, .name = "kb-row-last", .keybinding = "End,KP_End" },
|
||||
{ .id = ROW_SELECT, .name = "kb-row-select", .keybinding = "Control+space" },
|
||||
{ .id = CANCEL, .name = "kb-cancel", .keybinding = "Escape,Control+bracketleft" },
|
||||
{ .id = CUSTOM_1, .name = "kb-custom-1", .keybinding = "Alt+1" },
|
||||
{ .id = CUSTOM_2, .name = "kb-custom-2", .keybinding = "Alt+2" },
|
||||
{ .id = CUSTOM_3, .name = "kb-custom-3", .keybinding = "Alt+3" },
|
||||
{ .id = CUSTOM_4, .name = "kb-custom-4", .keybinding = "Alt+4" },
|
||||
{ .id = CUSTOM_5, .name = "kb-custom-5", .keybinding = "Alt+5" },
|
||||
{ .id = CUSTOM_6, .name = "kb-custom-6", .keybinding = "Alt+6" },
|
||||
{ .id = CUSTOM_7, .name = "kb-custom-7", .keybinding = "Alt+7" },
|
||||
{ .id = CUSTOM_8, .name = "kb-custom-8", .keybinding = "Alt+8" },
|
||||
{ .id = CUSTOM_9, .name = "kb-custom-9", .keybinding = "Alt+9" },
|
||||
{ .id = CUSTOM_10, .name = "kb-custom-10", .keybinding = "Alt+0" },
|
||||
{ .id = CUSTOM_11, .name = "kb-custom-11", .keybinding = "Alt+Shift+1" },
|
||||
{ .id = CUSTOM_12, .name = "kb-custom-12", .keybinding = "Alt+Shift+2" },
|
||||
{ .id = CUSTOM_13, .name = "kb-custom-13", .keybinding = "Alt+Shift+3" },
|
||||
{ .id = CUSTOM_14, .name = "kb-custom-14", .keybinding = "Alt+Shift+4" },
|
||||
{ .id = CUSTOM_15, .name = "kb-custom-15", .keybinding = "Alt+Shift+5" },
|
||||
{ .id = CUSTOM_16, .name = "kb-custom-16", .keybinding = "Alt+Shift+6" },
|
||||
{ .id = CUSTOM_18, .name = "kb-custom-18", .keybinding = "Alt+Shift+8" },
|
||||
{ .id = CUSTOM_17, .name = "kb-custom-17", .keybinding = "Alt+Shift+7" },
|
||||
{ .id = CUSTOM_19, .name = "kb-custom-19", .keybinding = "Alt+Shift+9" },
|
||||
{ .id = SCREENSHOT, .name = "kb-screenshot", .keybinding = "Alt+Shift+S" },
|
||||
{ .id = TOGGLE_SORT, .name = "kb-toggle-sort", .keybinding = "Alt+grave" },
|
||||
{ .id = ROW_DOWN, .name = "kb-row-down", .keybinding = "Down,Control+n" },
|
||||
{ .id = ROW_TAB, .name = "kb-row-tab", .keybinding = "Tab" },
|
||||
{ .id = PAGE_PREV, .name = "kb-page-prev", .keybinding = "Page_Up" },
|
||||
{ .id = PAGE_NEXT, .name = "kb-page-next", .keybinding = "Page_Down" },
|
||||
{ .id = ROW_FIRST, .name = "kb-row-first", .keybinding = "Home,KP_Home" },
|
||||
{ .id = ROW_LAST, .name = "kb-row-last", .keybinding = "End,KP_End" },
|
||||
{ .id = ROW_SELECT, .name = "kb-row-select", .keybinding = "Control+space" },
|
||||
{ .id = CANCEL, .name = "kb-cancel", .keybinding = "Escape,Control+bracketleft" },
|
||||
{ .id = CUSTOM_1, .name = "kb-custom-1", .keybinding = "Alt+1" },
|
||||
{ .id = CUSTOM_2, .name = "kb-custom-2", .keybinding = "Alt+2" },
|
||||
{ .id = CUSTOM_3, .name = "kb-custom-3", .keybinding = "Alt+3" },
|
||||
{ .id = CUSTOM_4, .name = "kb-custom-4", .keybinding = "Alt+4" },
|
||||
{ .id = CUSTOM_5, .name = "kb-custom-5", .keybinding = "Alt+5" },
|
||||
{ .id = CUSTOM_6, .name = "kb-custom-6", .keybinding = "Alt+6" },
|
||||
{ .id = CUSTOM_7, .name = "kb-custom-7", .keybinding = "Alt+7" },
|
||||
{ .id = CUSTOM_8, .name = "kb-custom-8", .keybinding = "Alt+8" },
|
||||
{ .id = CUSTOM_9, .name = "kb-custom-9", .keybinding = "Alt+9" },
|
||||
{ .id = CUSTOM_10, .name = "kb-custom-10", .keybinding = "Alt+0" },
|
||||
{ .id = CUSTOM_11, .name = "kb-custom-11", .keybinding = "Alt+Shift+1" },
|
||||
{ .id = CUSTOM_12, .name = "kb-custom-12", .keybinding = "Alt+Shift+2" },
|
||||
{ .id = CUSTOM_13, .name = "kb-custom-13", .keybinding = "Alt+Shift+3" },
|
||||
{ .id = CUSTOM_14, .name = "kb-custom-14", .keybinding = "Alt+Shift+4" },
|
||||
{ .id = CUSTOM_15, .name = "kb-custom-15", .keybinding = "Alt+Shift+5" },
|
||||
{ .id = CUSTOM_16, .name = "kb-custom-16", .keybinding = "Alt+Shift+6" },
|
||||
{ .id = CUSTOM_18, .name = "kb-custom-18", .keybinding = "Alt+Shift+8" },
|
||||
{ .id = CUSTOM_17, .name = "kb-custom-17", .keybinding = "Alt+Shift+7" },
|
||||
{ .id = CUSTOM_19, .name = "kb-custom-19", .keybinding = "Alt+Shift+9" },
|
||||
{ .id = SCREENSHOT, .name = "kb-screenshot", .keybinding = "Alt+Shift+S" },
|
||||
{ .id = TOGGLE_SORT, .name = "kb-toggle-sort", .keybinding = "Alt+grave" },
|
||||
};
|
||||
|
||||
void setup_abe ( void )
|
||||
|
@ -102,7 +100,7 @@ void setup_abe ( void )
|
|||
}
|
||||
}
|
||||
|
||||
void parse_keys_abe ( void )
|
||||
gboolean parse_keys_abe ( void )
|
||||
{
|
||||
for ( int iter = 0; iter < NUM_ABE; iter++ ) {
|
||||
char *keystr = g_strdup ( abe[iter].keystr );
|
||||
|
@ -116,12 +114,16 @@ void parse_keys_abe ( void )
|
|||
for ( char *entry = strtok_r ( keystr, ",", &sp ); entry != NULL; entry = strtok_r ( NULL, ",", &sp ) ) {
|
||||
abe[iter].kb = g_realloc ( abe[iter].kb, ( abe[iter].num_bindings + 1 ) * sizeof ( KeyBinding ) );
|
||||
KeyBinding *kb = &( abe[iter].kb[abe[iter].num_bindings] );
|
||||
x11_parse_key ( entry, &( kb->modmask ), &( kb->keysym ) );
|
||||
if ( !x11_parse_key ( entry, &( kb->modmask ), &( kb->keysym ) ) ) {
|
||||
g_free ( keystr );
|
||||
return FALSE;
|
||||
}
|
||||
abe[iter].num_bindings++;
|
||||
}
|
||||
|
||||
g_free ( keystr );
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void cleanup_abe ( void )
|
||||
|
@ -133,18 +135,14 @@ void cleanup_abe ( void )
|
|||
}
|
||||
}
|
||||
|
||||
int abe_test_action ( KeyBindingAction action, unsigned int mask, KeySym key )
|
||||
int abe_test_action ( KeyBindingAction action, unsigned int mask, xkb_keysym_t key )
|
||||
{
|
||||
ActionBindingEntry *akb = &( abe[action] );
|
||||
|
||||
for ( int iter = 0; iter < akb->num_bindings; iter++ ) {
|
||||
const KeyBinding * const kb = &( akb->kb[iter] );
|
||||
if ( kb->keysym == key ) {
|
||||
// Bits 13 and 14 of the modifiers together are the group number, and
|
||||
// should be ignored when looking up key bindings
|
||||
if ( ( mask & ( CombinedMask ) ) == kb->modmask ) {
|
||||
return TRUE;
|
||||
}
|
||||
if ( ( kb->keysym == key ) && ( kb->modmask == mask ) ) {
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -84,73 +84,16 @@ const char *mode_get_name ( const Mode *mode )
|
|||
return mode->name;
|
||||
}
|
||||
|
||||
void mode_setup_keybinding ( Mode *mode )
|
||||
{
|
||||
g_assert ( mode != NULL );
|
||||
mode->keycfg = g_strdup_printf ( "key-%s", mode->name );
|
||||
config_parser_add_option ( xrm_String, mode->keycfg, (void * *) &( mode->keystr ), "Keybinding" );
|
||||
}
|
||||
|
||||
int mode_check_keybinding ( const Mode *mode, KeySym key, unsigned int modstate )
|
||||
{
|
||||
g_assert ( mode != NULL );
|
||||
if ( mode->keystr != NULL ) {
|
||||
if ( mode->modmask == modstate && mode->keysym == key ) {
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void mode_free ( Mode **mode )
|
||||
{
|
||||
g_assert ( mode != NULL );
|
||||
g_assert ( ( *mode ) != NULL );
|
||||
if ( ( *mode )->keycfg != NULL ) {
|
||||
g_free ( ( *mode )->keycfg );
|
||||
( *mode )->keycfg = NULL;
|
||||
}
|
||||
if ( ( *mode )->free != NULL ) {
|
||||
( *mode )->free ( *mode );
|
||||
}
|
||||
( *mode ) = NULL;
|
||||
}
|
||||
|
||||
int mode_grab_key ( Mode *mode, Display *display )
|
||||
{
|
||||
g_assert ( mode != NULL );
|
||||
g_assert ( display != NULL );
|
||||
if ( mode->keystr != NULL ) {
|
||||
x11_parse_key ( mode->keystr, &( mode->modmask ), &( mode->keysym ) );
|
||||
if ( mode->keysym != NoSymbol ) {
|
||||
x11_grab_key ( display, mode->modmask, mode->keysym );
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
void mode_ungrab_key ( Mode *mode, Display *display )
|
||||
{
|
||||
g_assert ( mode != NULL );
|
||||
g_assert ( display != NULL );
|
||||
if ( mode->keystr != NULL ) {
|
||||
if ( mode->keysym != NoSymbol ) {
|
||||
x11_ungrab_key ( display, mode->modmask, mode->keysym );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void mode_print_keybindings ( const Mode *mode )
|
||||
{
|
||||
g_assert ( mode != NULL );
|
||||
if ( mode->keystr != NULL ) {
|
||||
fprintf ( stdout, "\t* "color_bold "%s"color_reset " on %s\n", mode->name, mode->keystr );
|
||||
}
|
||||
else {
|
||||
fprintf ( stdout, "\t* "color_bold "%s"color_reset " on <unspecified>\n", mode->name );
|
||||
}
|
||||
}
|
||||
|
||||
void *mode_get_private_data ( const Mode *mode )
|
||||
{
|
||||
g_assert ( mode != NULL );
|
||||
|
|
517
source/rofi.c
517
source/rofi.c
|
@ -34,19 +34,22 @@
|
|||
#include <errno.h>
|
||||
#include <time.h>
|
||||
#include <locale.h>
|
||||
#include <X11/X.h>
|
||||
#include <X11/Xatom.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <X11/Xproto.h>
|
||||
#include <X11/keysym.h>
|
||||
#include <X11/XKBlib.h>
|
||||
#include <xcb/xcb.h>
|
||||
#include <xcb/xcb_aux.h>
|
||||
#include <xcb/xcb_ewmh.h>
|
||||
#include <xcb/xinerama.h>
|
||||
#include <xcb/xkb.h>
|
||||
#include <xkbcommon/xkbcommon.h>
|
||||
#include <xkbcommon/xkbcommon-compose.h>
|
||||
#include <xkbcommon/xkbcommon-x11.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <glib-unix.h>
|
||||
|
||||
#define SN_API_NOT_YET_FROZEN
|
||||
#include <libsn/sn.h>
|
||||
#include <libgwater-xcb.h>
|
||||
|
||||
#include "xcb-internal.h"
|
||||
#include "xkb-internal.h"
|
||||
|
||||
#include "settings.h"
|
||||
#include "mode.h"
|
||||
|
@ -54,39 +57,42 @@
|
|||
#include "helper.h"
|
||||
#include "textbox.h"
|
||||
#include "x11-helper.h"
|
||||
#include "x11-event-source.h"
|
||||
#include "xrmoptions.h"
|
||||
#include "dialogs/dialogs.h"
|
||||
|
||||
#include "view.h"
|
||||
#include "view-internal.h"
|
||||
|
||||
gboolean daemon_mode = FALSE;
|
||||
// Pidfile.
|
||||
char *pidfile = NULL;
|
||||
const char *cache_dir = NULL;
|
||||
SnDisplay *sndisplay = NULL;
|
||||
SnLauncheeContext *sncontext = NULL;
|
||||
Display *display = NULL;
|
||||
char *display_str = NULL;
|
||||
char *config_path = NULL;
|
||||
char *pidfile = NULL;
|
||||
const char *cache_dir = NULL;
|
||||
struct xkb_stuff xkb = {
|
||||
.xcb_connection = NULL,
|
||||
.context = NULL,
|
||||
.keymap = NULL,
|
||||
.state = NULL,
|
||||
.compose = {
|
||||
.table = NULL,
|
||||
.state = NULL
|
||||
}
|
||||
};
|
||||
char *config_path = NULL;
|
||||
// Array of modi.
|
||||
Mode **modi = NULL;
|
||||
unsigned int num_modi = 0;
|
||||
Mode **modi = NULL;
|
||||
unsigned int num_modi = 0;
|
||||
// Current selected switcher.
|
||||
unsigned int curr_switcher = 0;
|
||||
unsigned int curr_switcher = 0;
|
||||
|
||||
GMainLoop *main_loop = NULL;
|
||||
GSource *main_loop_source = NULL;
|
||||
gboolean quiet = FALSE;
|
||||
GMainLoop *main_loop = NULL;
|
||||
GWaterXcbSource *main_loop_source = NULL;
|
||||
gboolean quiet = FALSE;
|
||||
|
||||
static int dmenu_mode = FALSE;
|
||||
static int dmenu_mode = FALSE;
|
||||
|
||||
int return_code = EXIT_SUCCESS;
|
||||
int return_code = EXIT_SUCCESS;
|
||||
|
||||
void process_result ( RofiViewState *state );
|
||||
void process_result_error ( RofiViewState *state );
|
||||
gboolean main_loop_x11_event_handler ( G_GNUC_UNUSED gpointer data );
|
||||
|
||||
void rofi_set_return_code ( int code )
|
||||
{
|
||||
|
@ -120,19 +126,6 @@ static int switcher_get ( const char *name )
|
|||
return -1;
|
||||
}
|
||||
|
||||
extern unsigned int NumlockMask;
|
||||
int locate_switcher ( KeySym key, unsigned int modstate )
|
||||
{
|
||||
// ignore annoying modifiers
|
||||
unsigned int modstate_filtered = modstate & ~( LockMask | NumlockMask );
|
||||
for ( unsigned int i = 0; i < num_modi; i++ ) {
|
||||
if ( mode_check_keybinding ( modi[i], key, modstate_filtered ) ) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Do needed steps to start showing the gui
|
||||
*/
|
||||
|
@ -142,8 +135,8 @@ static int setup ()
|
|||
int pfd = create_pid_file ( pidfile );
|
||||
if ( pfd >= 0 ) {
|
||||
// Request truecolor visual.
|
||||
create_visual_and_colormap ( display );
|
||||
textbox_setup ( display );
|
||||
x11_create_visual_and_colormap ( );
|
||||
textbox_setup ();
|
||||
}
|
||||
return pfd;
|
||||
}
|
||||
|
@ -157,7 +150,7 @@ static void teardown ( int pfd )
|
|||
textbox_cleanup ( );
|
||||
|
||||
// Release the window.
|
||||
release_keyboard ( display );
|
||||
release_keyboard ( );
|
||||
|
||||
// Cleanup view
|
||||
rofi_view_cleanup ();
|
||||
|
@ -187,7 +180,12 @@ static void __run_switcher_internal ( ModeMode mode, char *input )
|
|||
char *prompt = g_strdup_printf ( "%s:", mode_get_name ( modi[mode] ) );
|
||||
curr_switcher = mode;
|
||||
RofiViewState * state = rofi_view_create ( modi[mode], input, prompt, NULL, MENU_NORMAL, process_result );
|
||||
rofi_view_set_active ( state );
|
||||
if ( state ) {
|
||||
rofi_view_set_active ( state );
|
||||
}
|
||||
else {
|
||||
g_main_loop_quit ( main_loop );
|
||||
}
|
||||
g_free ( prompt );
|
||||
}
|
||||
static void run_switcher ( ModeMode mode )
|
||||
|
@ -247,7 +245,6 @@ void process_result ( RofiViewState *state )
|
|||
*/
|
||||
__run_switcher_internal ( mode, input );
|
||||
g_free ( input );
|
||||
main_loop_x11_event_handler ( NULL );
|
||||
return;
|
||||
}
|
||||
// Cleanup
|
||||
|
@ -269,33 +266,9 @@ int show_error_message ( const char *msg, int markup )
|
|||
{
|
||||
int pfd = setup ();
|
||||
if ( pfd < 0 ) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
rofi_view_error_dialog ( msg, markup );
|
||||
//teardown ( pfd );
|
||||
// TODO this looks incorrect.
|
||||
// g_main_loop_quit ( main_loop );
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function that listens for global key-presses.
|
||||
* This is only used when in daemon mode.
|
||||
*/
|
||||
static void handle_keypress ( XEvent *ev )
|
||||
{
|
||||
int index;
|
||||
KeySym key = XkbKeycodeToKeysym ( display, ev->xkey.keycode, 0, 0 );
|
||||
index = locate_switcher ( key, ev->xkey.state );
|
||||
if ( index >= 0 ) {
|
||||
run_switcher ( index );
|
||||
}
|
||||
else {
|
||||
fprintf ( stderr,
|
||||
"Warning: Unhandled keypress in global keyhandler, keycode = %u mask = %u\n",
|
||||
ev->xkey.keycode,
|
||||
ev->xkey.state );
|
||||
return FALSE;
|
||||
}
|
||||
return rofi_view_error_dialog ( msg, markup );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -333,23 +306,6 @@ static void help ( G_GNUC_UNUSED int argc, char **argv )
|
|||
printf ( "Bugreports: "PACKAGE_BUGREPORT "\n" );
|
||||
}
|
||||
|
||||
static void release_global_keybindings ()
|
||||
{
|
||||
for ( unsigned int i = 0; i < num_modi; i++ ) {
|
||||
mode_ungrab_key ( modi[i], display );
|
||||
}
|
||||
}
|
||||
static int grab_global_keybindings ()
|
||||
{
|
||||
int key_bound = FALSE;
|
||||
for ( unsigned int i = 0; i < num_modi; i++ ) {
|
||||
if ( mode_grab_key ( modi[i], display ) ) {
|
||||
key_bound = TRUE;
|
||||
}
|
||||
}
|
||||
return key_bound;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function bound by 'atexit'.
|
||||
* Cleanup globally allocated memory.
|
||||
|
@ -359,31 +315,13 @@ static void cleanup ()
|
|||
rofi_view_workers_finalize ();
|
||||
if ( main_loop != NULL ) {
|
||||
if ( main_loop_source ) {
|
||||
g_source_destroy ( main_loop_source );
|
||||
g_water_xcb_source_unref ( main_loop_source );
|
||||
}
|
||||
g_main_loop_unref ( main_loop );
|
||||
main_loop = NULL;
|
||||
}
|
||||
if ( daemon_mode ) {
|
||||
release_global_keybindings ();
|
||||
if ( !quiet ) {
|
||||
fprintf ( stdout, "Quit from daemon mode.\n" );
|
||||
}
|
||||
}
|
||||
// Cleanup
|
||||
if ( display != NULL ) {
|
||||
if ( sncontext != NULL ) {
|
||||
sn_launchee_context_unref ( sncontext );
|
||||
sncontext = NULL;
|
||||
}
|
||||
if ( sndisplay != NULL ) {
|
||||
sn_display_unref ( sndisplay );
|
||||
sndisplay = NULL;
|
||||
}
|
||||
XCloseDisplay ( display );
|
||||
display = NULL;
|
||||
}
|
||||
|
||||
xcb_stuff_wipe ( xcb );
|
||||
// Cleaning up memory allocated by the Xresources file.
|
||||
config_xresource_free ();
|
||||
for ( unsigned int i = 0; i < num_modi; i++ ) {
|
||||
|
@ -454,7 +392,6 @@ static int add_mode ( const char * token )
|
|||
else{
|
||||
// Report error, don't continue.
|
||||
fprintf ( stderr, "Invalid script switcher: %s\n", token );
|
||||
token = NULL;
|
||||
}
|
||||
}
|
||||
return ( index == num_modi ) ? -1 : (int) index;
|
||||
|
@ -472,9 +409,6 @@ static void setup_modi ( void )
|
|||
g_free ( switcher_str );
|
||||
// We cannot do this in main loop, as we create pointer to string,
|
||||
// and re-alloc moves that pointer.
|
||||
for ( unsigned int i = 0; i < num_modi; i++ ) {
|
||||
mode_setup_keybinding ( modi[i] );
|
||||
}
|
||||
mode_set_config ( &ssh_mode );
|
||||
mode_set_config ( &run_mode );
|
||||
mode_set_config ( &drun_mode );
|
||||
|
@ -491,127 +425,75 @@ static void setup_modi ( void )
|
|||
* Load configuration.
|
||||
* Following priority: (current), X, commandline arguments
|
||||
*/
|
||||
static inline void load_configuration ( Display *display )
|
||||
static inline void load_configuration ( )
|
||||
{
|
||||
// Load in config from X resources.
|
||||
config_parse_xresource_options ( display );
|
||||
config_parse_xresource_options ( xcb );
|
||||
config_parse_xresource_options_file ( config_path );
|
||||
|
||||
// Parse command line for settings.
|
||||
config_parse_cmd_options ( );
|
||||
}
|
||||
static inline void load_configuration_dynamic ( Display *display )
|
||||
static inline void load_configuration_dynamic ( )
|
||||
{
|
||||
// Load in config from X resources.
|
||||
config_parse_xresource_options_dynamic ( display );
|
||||
config_parse_xresource_options_dynamic ( xcb );
|
||||
config_parse_xresource_options_dynamic_file ( config_path );
|
||||
config_parse_cmd_options_dynamic ( );
|
||||
}
|
||||
|
||||
static void print_global_keybindings ()
|
||||
{
|
||||
if ( quiet ) {
|
||||
fprintf ( stdout, "listening to the following keys:\n" );
|
||||
}
|
||||
for ( unsigned int i = 0; i < num_modi; i++ ) {
|
||||
mode_print_keybindings ( modi[i] );
|
||||
}
|
||||
}
|
||||
|
||||
static void reload_configuration ()
|
||||
{
|
||||
if ( find_arg ( "-no-config" ) < 0 ) {
|
||||
TICK ();
|
||||
// Reset the color cache
|
||||
color_cache_reset ();
|
||||
// We need to open a new connection to X11, otherwise we get old
|
||||
// configuration
|
||||
Display *temp_display = XOpenDisplay ( display_str );
|
||||
if ( temp_display ) {
|
||||
load_configuration ( temp_display );
|
||||
load_configuration_dynamic ( temp_display );
|
||||
|
||||
// Sanity check
|
||||
config_sanity_check ( temp_display );
|
||||
parse_keys_abe ();
|
||||
XCloseDisplay ( temp_display );
|
||||
}
|
||||
else {
|
||||
fprintf ( stderr, "Failed to get a new connection to the X11 server. No point in continuing.\n" );
|
||||
abort ();
|
||||
}
|
||||
TICK_N ( "Load config" );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Process X11 events in the main-loop (gui-thread) of the application.
|
||||
*/
|
||||
gboolean main_loop_x11_event_handler ( G_GNUC_UNUSED gpointer data )
|
||||
static gboolean main_loop_x11_event_handler ( xcb_generic_event_t *ev, G_GNUC_UNUSED gpointer data )
|
||||
{
|
||||
RofiViewState *state = rofi_view_get_active ();
|
||||
if ( state != NULL ) {
|
||||
while ( XPending ( display ) ) {
|
||||
XEvent ev;
|
||||
// Read event, we know this won't block as we checked with XPending.
|
||||
XNextEvent ( display, &ev );
|
||||
if ( sndisplay != NULL ) {
|
||||
sn_display_process_event ( sndisplay, &ev );
|
||||
}
|
||||
rofi_view_itterrate ( state, &ev );
|
||||
if ( ev == NULL ) {
|
||||
int status = xcb_connection_has_error ( xcb->connection );
|
||||
fprintf ( stderr, "The XCB connection to X server had a fatal error: %d\n", status );
|
||||
g_main_loop_quit ( main_loop );
|
||||
return G_SOURCE_REMOVE;
|
||||
}
|
||||
uint8_t type = ev->response_type & ~0x80;
|
||||
if ( type == xkb.first_event ) {
|
||||
switch ( ev->pad0 )
|
||||
{
|
||||
case XCB_XKB_MAP_NOTIFY:
|
||||
xkb_state_unref ( xkb.state );
|
||||
xkb_keymap_unref ( xkb.keymap );
|
||||
xkb.keymap = xkb_x11_keymap_new_from_device ( xkb.context, xcb->connection, xkb.device_id, 0 );
|
||||
xkb.state = xkb_x11_state_new_from_device ( xkb.keymap, xcb->connection, xkb.device_id );
|
||||
break;
|
||||
case XCB_XKB_STATE_NOTIFY:
|
||||
{
|
||||
xcb_xkb_state_notify_event_t *ksne = (xcb_xkb_state_notify_event_t *) ev;
|
||||
xkb_state_update_mask ( xkb.state,
|
||||
ksne->baseMods,
|
||||
ksne->latchedMods,
|
||||
ksne->lockedMods,
|
||||
ksne->baseGroup,
|
||||
ksne->latchedGroup,
|
||||
ksne->lockedGroup );
|
||||
break;
|
||||
}
|
||||
}
|
||||
return G_SOURCE_CONTINUE;
|
||||
}
|
||||
RofiViewState *state = rofi_view_get_active ();
|
||||
if ( xcb->sndisplay != NULL ) {
|
||||
sn_xcb_display_process_event ( xcb->sndisplay, ev );
|
||||
}
|
||||
if ( state != NULL ) {
|
||||
rofi_view_itterrate ( state, ev, &xkb );
|
||||
if ( rofi_view_get_completed ( state ) ) {
|
||||
// This menu is done.
|
||||
rofi_view_finalize ( state );
|
||||
// cleanup
|
||||
if ( rofi_view_get_active () == NULL ) {
|
||||
teardown ( pfd );
|
||||
if ( !daemon_mode ) {
|
||||
g_main_loop_quit ( main_loop );
|
||||
}
|
||||
g_main_loop_quit ( main_loop );
|
||||
}
|
||||
}
|
||||
return G_SOURCE_CONTINUE;
|
||||
}
|
||||
// X11 produced an event. Consume them.
|
||||
while ( XPending ( display ) ) {
|
||||
XEvent ev;
|
||||
// Read event, we know this won't block as we checked with XPending.
|
||||
XNextEvent ( display, &ev );
|
||||
if ( sndisplay != NULL ) {
|
||||
sn_display_process_event ( sndisplay, &ev );
|
||||
}
|
||||
// If we get an event that does not belong to a window:
|
||||
// Ignore it.
|
||||
if ( ev.xany.window == None ) {
|
||||
continue;
|
||||
}
|
||||
// If keypress, handle it.
|
||||
if ( ev.type == KeyPress ) {
|
||||
handle_keypress ( &ev );
|
||||
}
|
||||
}
|
||||
return G_SOURCE_CONTINUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process signals in the main-loop (gui-thread) of the application.
|
||||
*
|
||||
* returns TRUE when mainloop should be stopped.
|
||||
*/
|
||||
static gboolean main_loop_signal_handler_hup ( G_GNUC_UNUSED gpointer data )
|
||||
{
|
||||
if ( !quiet ) {
|
||||
fprintf ( stdout, "Reload configuration\n" );
|
||||
}
|
||||
// Release the keybindings.
|
||||
release_global_keybindings ();
|
||||
// Reload config
|
||||
reload_configuration ();
|
||||
// Grab the possibly new keybindings.
|
||||
grab_global_keybindings ();
|
||||
// We need to flush, otherwise the first key presses are not caught.
|
||||
XFlush ( display );
|
||||
return G_SOURCE_CONTINUE;
|
||||
}
|
||||
|
||||
|
@ -622,42 +504,41 @@ static gboolean main_loop_signal_handler_int ( G_GNUC_UNUSED gpointer data )
|
|||
return G_SOURCE_CONTINUE;
|
||||
}
|
||||
|
||||
static gboolean main_loop_signal_handler_usr1 ( G_GNUC_UNUSED gpointer data )
|
||||
{
|
||||
config_parse_xresource_dump ();
|
||||
return G_SOURCE_CONTINUE;
|
||||
}
|
||||
|
||||
static int error_trap_depth = 0;
|
||||
static void error_trap_push ( G_GNUC_UNUSED SnDisplay *display, G_GNUC_UNUSED Display *xdisplay )
|
||||
static void error_trap_push ( G_GNUC_UNUSED SnDisplay *display, G_GNUC_UNUSED xcb_connection_t *xdisplay )
|
||||
{
|
||||
++error_trap_depth;
|
||||
}
|
||||
|
||||
static void error_trap_pop ( G_GNUC_UNUSED SnDisplay *display, Display *xdisplay )
|
||||
static void error_trap_pop ( G_GNUC_UNUSED SnDisplay *display, xcb_connection_t *xdisplay )
|
||||
{
|
||||
if ( error_trap_depth == 0 ) {
|
||||
fprintf ( stderr, "Error trap underflow!\n" );
|
||||
exit ( EXIT_FAILURE );
|
||||
}
|
||||
|
||||
XSync ( xdisplay, False ); /* get all errors out of the queue */
|
||||
xcb_flush ( xdisplay );
|
||||
--error_trap_depth;
|
||||
}
|
||||
|
||||
static gboolean delayed_start ( G_GNUC_UNUSED gpointer data )
|
||||
{
|
||||
// Force some X Events to be handled.. seems the only way to get a reliable startup.
|
||||
rofi_view_queue_redraw ();
|
||||
main_loop_x11_event_handler ( NULL );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gboolean startup ( G_GNUC_UNUSED gpointer data )
|
||||
{
|
||||
TICK_N ( "Startup" );
|
||||
// flags to run immediately and exit
|
||||
char *sname = NULL;
|
||||
char *msg = NULL;
|
||||
//
|
||||
// Sanity check
|
||||
if ( config_sanity_check ( ) ) {
|
||||
return G_SOURCE_REMOVE;
|
||||
}
|
||||
TICK_N ( "Config sanity check" );
|
||||
// Parse the keybindings.
|
||||
if ( !parse_keys_abe () ) {
|
||||
// Error dialog
|
||||
return G_SOURCE_REMOVE;
|
||||
}
|
||||
TICK_N ( "Parse ABE" );
|
||||
// Dmenu mode.
|
||||
if ( dmenu_mode == TRUE ) {
|
||||
// force off sidebar mode:
|
||||
|
@ -674,7 +555,9 @@ static gboolean startup ( G_GNUC_UNUSED gpointer data )
|
|||
if ( find_arg ( "-markup" ) >= 0 ) {
|
||||
markup = TRUE;
|
||||
}
|
||||
show_error_message ( msg, markup );
|
||||
if ( !show_error_message ( msg, markup ) ) {
|
||||
g_main_loop_quit ( main_loop );
|
||||
}
|
||||
}
|
||||
else if ( find_arg_str ( "-show", &sname ) == TRUE ) {
|
||||
int index = switcher_get ( sname );
|
||||
|
@ -691,7 +574,6 @@ static gboolean startup ( G_GNUC_UNUSED gpointer data )
|
|||
}
|
||||
if ( index >= 0 ) {
|
||||
run_switcher ( index );
|
||||
g_idle_add ( delayed_start, GINT_TO_POINTER ( index ) );
|
||||
}
|
||||
else {
|
||||
fprintf ( stderr, "The %s switcher has not been enabled\n", sname );
|
||||
|
@ -699,31 +581,9 @@ static gboolean startup ( G_GNUC_UNUSED gpointer data )
|
|||
}
|
||||
}
|
||||
else{
|
||||
// Daemon mode, Listen to key presses..
|
||||
if ( !grab_global_keybindings () ) {
|
||||
fprintf ( stderr, "Rofi was launched in daemon mode, but no key-binding was specified.\n" );
|
||||
fprintf ( stderr, "Please check the manpage on how to specify a key-binding.\n" );
|
||||
fprintf ( stderr, "The following modi are enabled and keys can be specified:\n" );
|
||||
for ( unsigned int i = 0; i < num_modi; i++ ) {
|
||||
const char *name = mode_get_name ( modi[i] );
|
||||
fprintf ( stderr, "\t* "color_bold "%s"color_reset ": -key-%s <key>\n", name, name );
|
||||
}
|
||||
// Cleanup
|
||||
return G_SOURCE_REMOVE;
|
||||
}
|
||||
if ( !quiet ) {
|
||||
fprintf ( stdout, "Rofi is launched in daemon mode.\n" );
|
||||
print_global_keybindings ();
|
||||
}
|
||||
|
||||
// done starting deamon.
|
||||
|
||||
if ( sncontext != NULL ) {
|
||||
sn_launchee_context_complete ( sncontext );
|
||||
}
|
||||
daemon_mode = TRUE;
|
||||
XSelectInput ( display, DefaultRootWindow ( display ), KeyPressMask );
|
||||
XFlush ( display );
|
||||
// Daemon mode
|
||||
fprintf ( stderr, "Rofi daemon mode is now removed.\n" );
|
||||
fprintf ( stderr, "Please use your window manager binding functionality or xbindkeys to replace it.\n" );
|
||||
}
|
||||
|
||||
return G_SOURCE_REMOVE;
|
||||
|
@ -785,7 +645,7 @@ int main ( int argc, char *argv[] )
|
|||
|
||||
TICK ();
|
||||
// Get DISPLAY, first env, then argument.
|
||||
display_str = getenv ( "DISPLAY" );
|
||||
char *display_str = getenv ( "DISPLAY" );
|
||||
find_arg_str ( "-display", &display_str );
|
||||
|
||||
if ( setlocale ( LC_ALL, "" ) == NULL ) {
|
||||
|
@ -793,28 +653,133 @@ int main ( int argc, char *argv[] )
|
|||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
if ( !XSupportsLocale () ) {
|
||||
fprintf ( stderr, "X11 does not support locales\n" );
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
if ( XSetLocaleModifiers ( "@im=none" ) == NULL ) {
|
||||
fprintf ( stderr, "Failed to set locale modifier.\n" );
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
if ( !( display = XOpenDisplay ( display_str ) ) ) {
|
||||
fprintf ( stderr, "cannot open display!\n" );
|
||||
xcb->connection = xcb_connect ( display_str, &xcb->screen_nbr );
|
||||
if ( xcb_connection_has_error ( xcb->connection ) ) {
|
||||
fprintf ( stderr, "Failed to open display: %s", display_str );
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
TICK_N ( "Open Display" );
|
||||
|
||||
xcb->screen = xcb_aux_get_screen ( xcb->connection, xcb->screen_nbr );
|
||||
|
||||
xcb_intern_atom_cookie_t *ac = xcb_ewmh_init_atoms ( xcb->connection, &xcb->ewmh );
|
||||
xcb_generic_error_t *errors = NULL;
|
||||
xcb_ewmh_init_atoms_replies ( &xcb->ewmh, ac, &errors );
|
||||
if ( errors ) {
|
||||
fprintf ( stderr, "Failed to create EWMH atoms\n" );
|
||||
free ( errors );
|
||||
}
|
||||
|
||||
if ( xkb_x11_setup_xkb_extension ( xcb->connection, XKB_X11_MIN_MAJOR_XKB_VERSION, XKB_X11_MIN_MINOR_XKB_VERSION,
|
||||
XKB_X11_SETUP_XKB_EXTENSION_NO_FLAGS, NULL, NULL, &xkb.first_event, NULL ) < 0 ) {
|
||||
fprintf ( stderr, "cannot setup XKB extension!\n" );
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
xkb.context = xkb_context_new ( XKB_CONTEXT_NO_FLAGS );
|
||||
if ( xkb.context == NULL ) {
|
||||
fprintf ( stderr, "cannot create XKB context!\n" );
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
xkb.xcb_connection = xcb->connection;
|
||||
|
||||
xkb.device_id = xkb_x11_get_core_keyboard_device_id ( xcb->connection );
|
||||
|
||||
enum
|
||||
{
|
||||
required_events =
|
||||
( XCB_XKB_EVENT_TYPE_NEW_KEYBOARD_NOTIFY |
|
||||
XCB_XKB_EVENT_TYPE_MAP_NOTIFY |
|
||||
XCB_XKB_EVENT_TYPE_STATE_NOTIFY ),
|
||||
|
||||
required_nkn_details =
|
||||
( XCB_XKB_NKN_DETAIL_KEYCODES ),
|
||||
|
||||
required_map_parts =
|
||||
( XCB_XKB_MAP_PART_KEY_TYPES |
|
||||
XCB_XKB_MAP_PART_KEY_SYMS |
|
||||
XCB_XKB_MAP_PART_MODIFIER_MAP |
|
||||
XCB_XKB_MAP_PART_EXPLICIT_COMPONENTS |
|
||||
XCB_XKB_MAP_PART_KEY_ACTIONS |
|
||||
XCB_XKB_MAP_PART_VIRTUAL_MODS |
|
||||
XCB_XKB_MAP_PART_VIRTUAL_MOD_MAP ),
|
||||
|
||||
required_state_details =
|
||||
( XCB_XKB_STATE_PART_MODIFIER_BASE |
|
||||
XCB_XKB_STATE_PART_MODIFIER_LATCH |
|
||||
XCB_XKB_STATE_PART_MODIFIER_LOCK |
|
||||
XCB_XKB_STATE_PART_GROUP_BASE |
|
||||
XCB_XKB_STATE_PART_GROUP_LATCH |
|
||||
XCB_XKB_STATE_PART_GROUP_LOCK ),
|
||||
};
|
||||
|
||||
static const xcb_xkb_select_events_details_t details = {
|
||||
.affectNewKeyboard = required_nkn_details,
|
||||
.newKeyboardDetails = required_nkn_details,
|
||||
.affectState = required_state_details,
|
||||
.stateDetails = required_state_details,
|
||||
};
|
||||
xcb_xkb_select_events ( xcb->connection, xkb.device_id, required_events, /* affectWhich */
|
||||
0, /* clear */
|
||||
required_events, /* selectAll */
|
||||
required_map_parts, /* affectMap */
|
||||
required_map_parts, /* map */
|
||||
&details );
|
||||
|
||||
xkb.keymap = xkb_x11_keymap_new_from_device ( xkb.context, xcb->connection, xkb.device_id, XKB_KEYMAP_COMPILE_NO_FLAGS );
|
||||
if ( xkb.keymap == NULL ) {
|
||||
fprintf ( stderr, "Failed to get Keymap for current keyboard device.\n" );
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
xkb.state = xkb_x11_state_new_from_device ( xkb.keymap, xcb->connection, xkb.device_id );
|
||||
if ( xkb.state == NULL ) {
|
||||
fprintf ( stderr, "Failed to get state object for current keyboard device.\n" );
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
xkb.compose.table = xkb_compose_table_new_from_locale ( xkb.context, setlocale ( LC_CTYPE, NULL ), 0 );
|
||||
if ( xkb.compose.table != NULL ) {
|
||||
xkb.compose.state = xkb_compose_state_new ( xkb.compose.table, 0 );
|
||||
}
|
||||
else {
|
||||
fprintf ( stderr, "Failed to get keyboard compose table. Trying to limp on.\n" );
|
||||
}
|
||||
|
||||
if ( xcb_connection_has_error ( xcb->connection ) ) {
|
||||
fprintf ( stderr, "Connection has error\n" );
|
||||
exit ( EXIT_FAILURE );
|
||||
}
|
||||
x11_setup ( &xkb );
|
||||
if ( xcb_connection_has_error ( xcb->connection ) ) {
|
||||
fprintf ( stderr, "Connection has error\n" );
|
||||
exit ( EXIT_FAILURE );
|
||||
}
|
||||
|
||||
const xcb_query_extension_reply_t *er = xcb_get_extension_data ( xcb->connection, &xcb_xinerama_id );
|
||||
if ( er ) {
|
||||
if ( er->present ) {
|
||||
xcb_xinerama_is_active_cookie_t is_active_req = xcb_xinerama_is_active ( xcb->connection );
|
||||
xcb_xinerama_is_active_reply_t *is_active = xcb_xinerama_is_active_reply ( xcb->connection, is_active_req, NULL );
|
||||
xcb->has_xinerama = is_active->state;
|
||||
free ( is_active );
|
||||
}
|
||||
}
|
||||
main_loop = g_main_loop_new ( NULL, FALSE );
|
||||
|
||||
TICK_N ( "Setup mainloop" );
|
||||
// startup not.
|
||||
sndisplay = sn_display_new ( display, error_trap_push, error_trap_pop );
|
||||
xcb->sndisplay = sn_xcb_display_new ( xcb->connection, error_trap_push, error_trap_pop );
|
||||
if ( xcb_connection_has_error ( xcb->connection ) ) {
|
||||
fprintf ( stderr, "Connection has error\n" );
|
||||
exit ( EXIT_FAILURE );
|
||||
}
|
||||
|
||||
if ( sndisplay != NULL ) {
|
||||
sncontext = sn_launchee_context_new_from_environment ( sndisplay, DefaultScreen ( display ) );
|
||||
if ( xcb->sndisplay != NULL ) {
|
||||
xcb->sncontext = sn_launchee_context_new_from_environment ( xcb->sndisplay, xcb->screen_nbr );
|
||||
}
|
||||
if ( xcb_connection_has_error ( xcb->connection ) ) {
|
||||
fprintf ( stderr, "Connection has error\n" );
|
||||
exit ( EXIT_FAILURE );
|
||||
}
|
||||
TICK_N ( "Startup Notification" );
|
||||
|
||||
|
@ -826,7 +791,7 @@ int main ( int argc, char *argv[] )
|
|||
TICK_N ( "Setup abe" );
|
||||
|
||||
if ( find_arg ( "-no-config" ) < 0 ) {
|
||||
load_configuration ( display );
|
||||
load_configuration ( );
|
||||
}
|
||||
if ( !dmenu_mode ) {
|
||||
// setup_modi
|
||||
|
@ -838,17 +803,8 @@ int main ( int argc, char *argv[] )
|
|||
}
|
||||
if ( find_arg ( "-no-config" ) < 0 ) {
|
||||
// Reload for dynamic part.
|
||||
load_configuration_dynamic ( display );
|
||||
load_configuration_dynamic ( );
|
||||
}
|
||||
|
||||
x11_setup ( display );
|
||||
main_loop_source = x11_event_source_new ( display );
|
||||
x11_event_source_set_callback ( main_loop_source, main_loop_x11_event_handler );
|
||||
|
||||
TICK_N ( "X11 Setup " );
|
||||
// Sanity check
|
||||
config_sanity_check ( display );
|
||||
TICK_N ( "Config sanity check" );
|
||||
// Dump.
|
||||
// catch help request
|
||||
if ( find_arg ( "-h" ) >= 0 || find_arg ( "-help" ) >= 0 || find_arg ( "--help" ) >= 0 ) {
|
||||
|
@ -863,19 +819,16 @@ int main ( int argc, char *argv[] )
|
|||
config_parse_xresources_theme_dump ();
|
||||
exit ( EXIT_SUCCESS );
|
||||
}
|
||||
// Parse the keybindings.
|
||||
parse_keys_abe ();
|
||||
TICK_N ( "Parse ABE" );
|
||||
|
||||
main_loop_source = g_water_xcb_source_new_for_connection ( NULL, xcb->connection, main_loop_x11_event_handler, NULL, NULL );
|
||||
|
||||
TICK_N ( "X11 Setup " );
|
||||
|
||||
rofi_view_workers_initialize ();
|
||||
|
||||
// Setup signal handling sources.
|
||||
// SIGHup signal.
|
||||
g_unix_signal_add ( SIGHUP, main_loop_signal_handler_hup, NULL );
|
||||
// SIGINT
|
||||
g_unix_signal_add ( SIGINT, main_loop_signal_handler_int, NULL );
|
||||
// SIGUSR1
|
||||
g_unix_signal_add ( SIGUSR1, main_loop_signal_handler_usr1, NULL );
|
||||
|
||||
g_idle_add ( startup, NULL );
|
||||
|
||||
|
|
|
@ -23,20 +23,12 @@
|
|||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <X11/X.h>
|
||||
#include <X11/Xatom.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xmd.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <X11/Xproto.h>
|
||||
#include <X11/Xft/Xft.h>
|
||||
#include <xkbcommon/xkbcommon.h>
|
||||
#include <glib.h>
|
||||
#include "scrollbar.h"
|
||||
#include "x11-helper.h"
|
||||
#include "settings.h"
|
||||
|
||||
extern Display *display;
|
||||
|
||||
scrollbar *scrollbar_create ( short x, short y, short w, short h )
|
||||
{
|
||||
scrollbar *sb = g_malloc0 ( sizeof ( scrollbar ) );
|
||||
|
@ -97,7 +89,7 @@ void scrollbar_draw ( scrollbar *sb, cairo_t *draw )
|
|||
// Cap length;
|
||||
height = MIN ( bh - y + 1, ( height ) );
|
||||
// Redraw base window
|
||||
color_separator ( display, draw );
|
||||
color_separator ( draw );
|
||||
|
||||
cairo_rectangle ( draw, sb->widget.x + config.line_margin, sb->widget.y + y, sb->widget.w - config.line_margin, height );
|
||||
cairo_fill ( draw );
|
||||
|
|
106
source/textbox.c
106
source/textbox.c
|
@ -24,14 +24,7 @@
|
|||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <X11/X.h>
|
||||
#include <X11/Xatom.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xmd.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <X11/Xproto.h>
|
||||
#include <X11/keysym.h>
|
||||
#include <X11/XKBlib.h>
|
||||
#include <xcb/xcb.h>
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
#include <glib.h>
|
||||
|
@ -89,7 +82,7 @@ textbox* textbox_create ( TextboxFlags flags, short x, short y, short w, short h
|
|||
|
||||
tb->changed = FALSE;
|
||||
|
||||
tb->main_surface = cairo_image_surface_create ( get_format (), tb->widget.w, tb->widget.h );
|
||||
tb->main_surface = cairo_image_surface_create ( CAIRO_FORMAT_ARGB32, tb->widget.w, tb->widget.h );
|
||||
tb->main_draw = cairo_create ( tb->main_surface );
|
||||
tb->layout = pango_layout_new ( p_context );
|
||||
textbox_font ( tb, tbft );
|
||||
|
@ -270,7 +263,7 @@ static void texbox_update ( textbox *tb )
|
|||
tb->main_draw = NULL;
|
||||
tb->main_surface = NULL;
|
||||
}
|
||||
tb->main_surface = cairo_image_surface_create ( get_format (), tb->widget.w, tb->widget.h );
|
||||
tb->main_surface = cairo_image_surface_create ( CAIRO_FORMAT_ARGB32, tb->widget.w, tb->widget.h );
|
||||
tb->main_draw = cairo_create ( tb->main_surface );
|
||||
cairo_set_operator ( tb->main_draw, CAIRO_OPERATOR_SOURCE );
|
||||
|
||||
|
@ -532,80 +525,80 @@ static void textbox_cursor_del_word ( textbox *tb )
|
|||
// 0 = unhandled
|
||||
// 1 = handled
|
||||
// -1 = handled and return pressed (finished)
|
||||
int textbox_keypress ( textbox *tb, XEvent *ev, char *pad, int pad_len, KeySym key, Status stat )
|
||||
int textbox_keypress ( textbox *tb, char *pad, int pad_len, unsigned int modstate, xkb_keysym_t key )
|
||||
{
|
||||
if ( !( tb->flags & TB_EDITABLE ) ) {
|
||||
return 0;
|
||||
}
|
||||
int old_blink = tb->blink;
|
||||
tb->blink = 2;
|
||||
if ( stat == XLookupKeySym || stat == XLookupBoth ) {
|
||||
if ( key != XKB_KEY_NoSymbol ) {
|
||||
// Left or Ctrl-b
|
||||
if ( abe_test_action ( MOVE_CHAR_BACK, ev->xkey.state, key ) ) {
|
||||
if ( abe_test_action ( MOVE_CHAR_BACK, modstate, key ) ) {
|
||||
textbox_cursor_dec ( tb );
|
||||
return 2;
|
||||
}
|
||||
// Right or Ctrl-F
|
||||
else if ( abe_test_action ( MOVE_CHAR_FORWARD, ev->xkey.state, key ) ) {
|
||||
else if ( abe_test_action ( MOVE_CHAR_FORWARD, modstate, key ) ) {
|
||||
textbox_cursor_inc ( tb );
|
||||
return 2;
|
||||
}
|
||||
|
||||
// Ctrl-U: Kill from the beginning to the end of the line.
|
||||
else if ( abe_test_action ( CLEAR_LINE, ev->xkey.state, key ) ) {
|
||||
else if ( abe_test_action ( CLEAR_LINE, modstate, key ) ) {
|
||||
textbox_text ( tb, "" );
|
||||
return 1;
|
||||
}
|
||||
// Ctrl-A
|
||||
else if ( abe_test_action ( MOVE_FRONT, ev->xkey.state, key ) ) {
|
||||
else if ( abe_test_action ( MOVE_FRONT, modstate, key ) ) {
|
||||
textbox_cursor ( tb, 0 );
|
||||
return 2;
|
||||
}
|
||||
// Ctrl-E
|
||||
else if ( abe_test_action ( MOVE_END, ev->xkey.state, key ) ) {
|
||||
else if ( abe_test_action ( MOVE_END, modstate, key ) ) {
|
||||
textbox_cursor_end ( tb );
|
||||
return 2;
|
||||
}
|
||||
// Ctrl-Alt-h
|
||||
else if ( abe_test_action ( REMOVE_WORD_BACK, ev->xkey.state, key ) ) {
|
||||
else if ( abe_test_action ( REMOVE_WORD_BACK, modstate, key ) ) {
|
||||
textbox_cursor_bkspc_word ( tb );
|
||||
return 1;
|
||||
}
|
||||
// Ctrl-Alt-d
|
||||
else if ( abe_test_action ( REMOVE_WORD_FORWARD, ev->xkey.state, key ) ) {
|
||||
else if ( abe_test_action ( REMOVE_WORD_FORWARD, modstate, key ) ) {
|
||||
textbox_cursor_del_word ( tb );
|
||||
return 1;
|
||||
} // Delete or Ctrl-D
|
||||
else if ( abe_test_action ( REMOVE_CHAR_FORWARD, ev->xkey.state, key ) ) {
|
||||
else if ( abe_test_action ( REMOVE_CHAR_FORWARD, modstate, key ) ) {
|
||||
textbox_cursor_del ( tb );
|
||||
return 1;
|
||||
}
|
||||
// Alt-B
|
||||
else if ( abe_test_action ( MOVE_WORD_BACK, ev->xkey.state, key ) ) {
|
||||
else if ( abe_test_action ( MOVE_WORD_BACK, modstate, key ) ) {
|
||||
textbox_cursor_dec_word ( tb );
|
||||
return 2;
|
||||
}
|
||||
// Alt-F
|
||||
else if ( abe_test_action ( MOVE_WORD_FORWARD, ev->xkey.state, key ) ) {
|
||||
else if ( abe_test_action ( MOVE_WORD_FORWARD, modstate, key ) ) {
|
||||
textbox_cursor_inc_word ( tb );
|
||||
return 2;
|
||||
}
|
||||
// BackSpace, Ctrl-h
|
||||
else if ( abe_test_action ( REMOVE_CHAR_BACK, ev->xkey.state, key ) ) {
|
||||
else if ( abe_test_action ( REMOVE_CHAR_BACK, modstate, key ) ) {
|
||||
textbox_cursor_bkspc ( tb );
|
||||
return 1;
|
||||
}
|
||||
else if ( abe_test_action ( ACCEPT_CUSTOM, ev->xkey.state, key ) ) {
|
||||
else if ( abe_test_action ( ACCEPT_CUSTOM, modstate, key ) ) {
|
||||
return -2;
|
||||
}
|
||||
else if ( abe_test_action ( ACCEPT_ENTRY_CONTINUE, ev->xkey.state, key ) ) {
|
||||
else if ( abe_test_action ( ACCEPT_ENTRY_CONTINUE, modstate, key ) ) {
|
||||
return -3;
|
||||
}
|
||||
else if ( abe_test_action ( ACCEPT_ENTRY, ev->xkey.state, key ) ) {
|
||||
else if ( abe_test_action ( ACCEPT_ENTRY, modstate, key ) ) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
if ( pad_len > 0 && ( stat == XLookupBoth || stat == XLookupChars ) ) {
|
||||
if ( pad_len > 0 ) {
|
||||
// Filter When alt/ctrl is pressed do not accept the character.
|
||||
if ( !g_ascii_iscntrl ( *pad ) ) {
|
||||
textbox_insert ( tb, tb->cursor, pad, pad_len );
|
||||
|
@ -620,16 +613,7 @@ int textbox_keypress ( textbox *tb, XEvent *ev, char *pad, int pad_len, KeySym k
|
|||
/***
|
||||
* Font setup.
|
||||
*/
|
||||
static void parse_color ( Display *display, char *bg, Color *col )
|
||||
{
|
||||
unsigned int val = 0;
|
||||
val = color_get ( display, bg, "white" );
|
||||
col->alpha = ( ( val & 0xFF000000 ) >> 24 ) / 255.0;
|
||||
col->red = ( ( val & 0x00FF0000 ) >> 16 ) / 255.0;
|
||||
col->green = ( ( val & 0x0000FF00 ) >> 8 ) / 255.0;
|
||||
col->blue = ( ( val & 0x000000FF ) ) / 255.0;
|
||||
}
|
||||
static void textbox_parse_string ( Display *display, const char *str, RowColor *color )
|
||||
static void textbox_parse_string ( const char *str, RowColor *color )
|
||||
{
|
||||
if ( str == NULL ) {
|
||||
return;
|
||||
|
@ -642,50 +626,50 @@ static void textbox_parse_string ( Display *display, const char *str, RowColor
|
|||
switch ( index )
|
||||
{
|
||||
case 0:
|
||||
parse_color ( display, g_strstrip ( token ), &( color->bg ) );
|
||||
color->bg = color_get ( g_strstrip ( token ) );
|
||||
break;
|
||||
case 1:
|
||||
parse_color ( display, g_strstrip ( token ), &( color->fg ) );
|
||||
color->fg = color_get ( g_strstrip ( token ) );
|
||||
break;
|
||||
case 2:
|
||||
parse_color ( display, g_strstrip ( token ), &( color->bgalt ) );
|
||||
color->bgalt = color_get ( g_strstrip ( token ) );
|
||||
break;
|
||||
case 3:
|
||||
parse_color ( display, g_strstrip ( token ), &( color->hlbg ) );
|
||||
color->hlbg = color_get ( g_strstrip ( token ) );
|
||||
break;
|
||||
case 4:
|
||||
parse_color ( display, g_strstrip ( token ), &( color->hlfg ) );
|
||||
color->hlfg = color_get ( g_strstrip ( token ) );
|
||||
break;
|
||||
}
|
||||
index++;
|
||||
}
|
||||
g_free ( cstr );
|
||||
}
|
||||
void textbox_setup ( Display *display )
|
||||
void textbox_setup ( void )
|
||||
{
|
||||
if ( config.color_enabled ) {
|
||||
textbox_parse_string ( display, config.color_normal, &( colors[NORMAL] ) );
|
||||
textbox_parse_string ( display, config.color_urgent, &( colors[URGENT] ) );
|
||||
textbox_parse_string ( display, config.color_active, &( colors[ACTIVE] ) );
|
||||
textbox_parse_string ( config.color_normal, &( colors[NORMAL] ) );
|
||||
textbox_parse_string ( config.color_urgent, &( colors[URGENT] ) );
|
||||
textbox_parse_string ( config.color_active, &( colors[ACTIVE] ) );
|
||||
}
|
||||
else {
|
||||
parse_color ( display, config.menu_bg, &( colors[NORMAL].bg ) );
|
||||
parse_color ( display, config.menu_fg, &( colors[NORMAL].fg ) );
|
||||
parse_color ( display, config.menu_bg_alt, &( colors[NORMAL].bgalt ) );
|
||||
parse_color ( display, config.menu_hlfg, &( colors[NORMAL].hlfg ) );
|
||||
parse_color ( display, config.menu_hlbg, &( colors[NORMAL].hlbg ) );
|
||||
colors[NORMAL].bg = color_get ( config.menu_bg );
|
||||
colors[NORMAL].fg = color_get ( config.menu_fg );
|
||||
colors[NORMAL].bgalt = color_get ( config.menu_bg_alt );
|
||||
colors[NORMAL].hlfg = color_get ( config.menu_hlfg );
|
||||
colors[NORMAL].hlbg = color_get ( config.menu_hlbg );
|
||||
|
||||
parse_color ( display, config.menu_bg_urgent, &( colors[URGENT].bg ) );
|
||||
parse_color ( display, config.menu_fg_urgent, &( colors[URGENT].fg ) );
|
||||
parse_color ( display, config.menu_bg_alt, &( colors[URGENT].bgalt ) );
|
||||
parse_color ( display, config.menu_hlfg_urgent, &( colors[URGENT].hlfg ) );
|
||||
parse_color ( display, config.menu_hlbg_urgent, &( colors[URGENT].hlbg ) );
|
||||
colors[URGENT].bg = color_get ( config.menu_bg_urgent );
|
||||
colors[URGENT].fg = color_get ( config.menu_fg_urgent );
|
||||
colors[URGENT].bgalt = color_get ( config.menu_bg_alt );
|
||||
colors[URGENT].hlfg = color_get ( config.menu_hlfg_urgent );
|
||||
colors[URGENT].hlbg = color_get ( config.menu_hlbg_urgent );
|
||||
|
||||
parse_color ( display, config.menu_bg_active, &( colors[ACTIVE].bg ) );
|
||||
parse_color ( display, config.menu_fg_active, &( colors[ACTIVE].fg ) );
|
||||
parse_color ( display, config.menu_bg_alt, &( colors[ACTIVE].bgalt ) );
|
||||
parse_color ( display, config.menu_hlfg_active, &( colors[ACTIVE].hlfg ) );
|
||||
parse_color ( display, config.menu_hlbg_active, &( colors[ACTIVE].hlbg ) );
|
||||
colors[ACTIVE].bg = color_get ( config.menu_bg_active );
|
||||
colors[ACTIVE].fg = color_get ( config.menu_fg_active );
|
||||
colors[ACTIVE].bgalt = color_get ( config.menu_bg_alt );
|
||||
colors[ACTIVE].hlfg = color_get ( config.menu_hlfg_active );
|
||||
colors[ACTIVE].hlbg = color_get ( config.menu_hlbg_active );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
900
source/view.c
900
source/view.c
File diff suppressed because it is too large
Load diff
|
@ -1,65 +0,0 @@
|
|||
#include <glib.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include "x11-event-source.h"
|
||||
|
||||
/**
|
||||
* Custom X11 Source implementation.
|
||||
*/
|
||||
typedef struct _X11EventSource
|
||||
{
|
||||
// Source
|
||||
GSource source;
|
||||
// Polling field
|
||||
gpointer fd_x11;
|
||||
Display *display;
|
||||
} X11EventSource;
|
||||
|
||||
static gboolean x11_event_source_prepare ( GSource * base, gint * timeout )
|
||||
{
|
||||
X11EventSource *xs = (X11EventSource *) base;
|
||||
*timeout = -1;
|
||||
return /*XPending ( xs->display ) || */ g_source_query_unix_fd ( base, xs->fd_x11 );
|
||||
}
|
||||
|
||||
static gboolean x11_event_source_check ( GSource * base )
|
||||
{
|
||||
X11EventSource *xs = (X11EventSource *) base;
|
||||
if ( g_source_query_unix_fd ( base, xs->fd_x11 ) ) {
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gboolean x11_event_source_dispatch ( GSource * base, GSourceFunc callback, gpointer data )
|
||||
{
|
||||
X11EventSource *xs = (X11EventSource *) base;
|
||||
if ( callback ) {
|
||||
if ( g_source_query_unix_fd ( base, xs->fd_x11 ) ) {
|
||||
callback ( data );
|
||||
}
|
||||
}
|
||||
return G_SOURCE_CONTINUE;;
|
||||
}
|
||||
|
||||
static GSourceFuncs x11_event_source_funcs = {
|
||||
x11_event_source_prepare,
|
||||
x11_event_source_check,
|
||||
x11_event_source_dispatch,
|
||||
NULL
|
||||
};
|
||||
|
||||
GSource * x11_event_source_new ( Display *display )
|
||||
{
|
||||
int x11_fd = ConnectionNumber ( display );
|
||||
X11EventSource *source = (X11EventSource *) g_source_new ( &x11_event_source_funcs, sizeof ( X11EventSource ) );
|
||||
source->display = display;
|
||||
source->fd_x11 = g_source_add_unix_fd ( (GSource *) source, x11_fd, G_IO_IN | G_IO_ERR );
|
||||
|
||||
// Attach it to main loop.
|
||||
g_source_attach ( (GSource *) source, NULL );
|
||||
return (GSource *) source;
|
||||
}
|
||||
void x11_event_source_set_callback ( GSource *source, GSourceFunc callback )
|
||||
{
|
||||
g_source_set_callback ( source, callback, NULL, NULL );
|
||||
}
|
File diff suppressed because it is too large
Load diff
|
@ -30,7 +30,14 @@
|
|||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <X11/X.h>
|
||||
#include <xcb/xcb.h>
|
||||
#include <xcb/xkb.h>
|
||||
#include <xkbcommon/xkbcommon.h>
|
||||
#include <xkbcommon/xkbcommon-compose.h>
|
||||
#include <xkbcommon/xkbcommon-x11.h>
|
||||
#include <X11/Xresource.h>
|
||||
#include "xcb.h"
|
||||
#include "x11-helper.h"
|
||||
#include "rofi.h"
|
||||
#include "xrmoptions.h"
|
||||
#include "settings.h"
|
||||
|
@ -217,18 +224,16 @@ static void __config_parse_xresource_options ( XrmDatabase xDB )
|
|||
g_free ( name );
|
||||
}
|
||||
}
|
||||
void config_parse_xresource_options ( Display *display )
|
||||
void config_parse_xresource_options ( xcb_stuff *xcb )
|
||||
{
|
||||
char *xRMS;
|
||||
// Map Xresource entries to rofi config options.
|
||||
xRMS = XResourceManagerString ( display );
|
||||
|
||||
if ( xRMS == NULL ) {
|
||||
return;
|
||||
char *name = window_get_text_prop ( xcb_stuff_get_root_window ( xcb ), XCB_ATOM_RESOURCE_MANAGER );
|
||||
if ( name ) {
|
||||
// Map Xresource entries to rofi config options.
|
||||
XrmDatabase xDB = XrmGetStringDatabase ( name );
|
||||
__config_parse_xresource_options ( xDB );
|
||||
XrmDestroyDatabase ( xDB );
|
||||
g_free ( name );
|
||||
}
|
||||
XrmDatabase xDB = XrmGetStringDatabase ( xRMS );
|
||||
__config_parse_xresource_options ( xDB );
|
||||
XrmDestroyDatabase ( xDB );
|
||||
}
|
||||
void config_parse_xresource_options_file ( const char *filename )
|
||||
{
|
||||
|
@ -325,18 +330,15 @@ static void __config_parse_xresource_options_dynamic ( XrmDatabase xDB )
|
|||
}
|
||||
}
|
||||
|
||||
void config_parse_xresource_options_dynamic ( Display *display )
|
||||
void config_parse_xresource_options_dynamic ( xcb_stuff *xcb )
|
||||
{
|
||||
char *xRMS;
|
||||
// Map Xresource entries to rofi config options.
|
||||
xRMS = XResourceManagerString ( display );
|
||||
|
||||
if ( xRMS == NULL ) {
|
||||
return;
|
||||
char *name = window_get_text_prop ( xcb_stuff_get_root_window ( xcb ), XCB_ATOM_RESOURCE_MANAGER );
|
||||
if ( name ) {
|
||||
XrmDatabase xDB = XrmGetStringDatabase ( name );
|
||||
__config_parse_xresource_options_dynamic ( xDB );
|
||||
XrmDestroyDatabase ( xDB );
|
||||
g_free ( name );
|
||||
}
|
||||
XrmDatabase xDB = XrmGetStringDatabase ( xRMS );
|
||||
__config_parse_xresource_options_dynamic ( xDB );
|
||||
XrmDestroyDatabase ( xDB );
|
||||
}
|
||||
void config_parse_xresource_options_dynamic_file ( const char *filename )
|
||||
{
|
||||
|
|
|
@ -4,9 +4,13 @@
|
|||
#include <stdio.h>
|
||||
#include <helper.h>
|
||||
#include <string.h>
|
||||
#include <xcb/xcb_ewmh.h>
|
||||
#include "xcb-internal.h"
|
||||
#include "rofi.h"
|
||||
#include "settings.h"
|
||||
|
||||
static int test = 0;
|
||||
static int test = 0;
|
||||
struct xcb_stuff *xcb;
|
||||
|
||||
#define TASSERT( a ) { \
|
||||
assert ( a ); \
|
||||
|
@ -21,9 +25,10 @@ static int test = 0;
|
|||
} \
|
||||
}
|
||||
|
||||
void rofi_view_error_dialog ( const char *msg, G_GNUC_UNUSED int markup )
|
||||
int rofi_view_error_dialog ( const char *msg, G_GNUC_UNUSED int markup )
|
||||
{
|
||||
fputs ( msg, stderr );
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int show_error_message ( const char *msg, int markup )
|
||||
|
@ -31,15 +36,10 @@ int show_error_message ( const char *msg, int markup )
|
|||
rofi_view_error_dialog ( msg, markup );
|
||||
return 0;
|
||||
}
|
||||
xcb_screen_t *xcb_screen;
|
||||
xcb_ewmh_connection_t xcb_ewmh;
|
||||
int xcb_screen_nbr;
|
||||
#include <x11-helper.h>
|
||||
int monitor_get_smallest_size ( G_GNUC_UNUSED Display *d )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
int monitor_get_dimension ( G_GNUC_UNUSED Display *d, G_GNUC_UNUSED Screen *screen, G_GNUC_UNUSED int monitor, G_GNUC_UNUSED workarea *mon )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main ( int argc, char ** argv )
|
||||
{
|
||||
|
|
|
@ -81,6 +81,8 @@ static void history_test ( void )
|
|||
TASSERT ( length == 25 );
|
||||
|
||||
g_strfreev ( retv );
|
||||
|
||||
unlink ( file );
|
||||
}
|
||||
|
||||
int main ( G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv )
|
||||
|
|
|
@ -6,7 +6,7 @@ function create_fake_x ( )
|
|||
{
|
||||
export DISPLAY=":$1"
|
||||
echo "Starting fake X: ${DISPLAY}"
|
||||
Xvfb ${DISPLAY} &
|
||||
Xvfb -screen 0 1280x1024x24 ${DISPLAY} &
|
||||
XPID=$!
|
||||
sleep 1;
|
||||
timeout -k 30s 30s fluxbox &
|
||||
|
|
|
@ -6,9 +6,7 @@
|
|||
#include <glib.h>
|
||||
#include <history.h>
|
||||
#include <string.h>
|
||||
#include <X11/X.h>
|
||||
#include <X11/Xlib.h>
|
||||
|
||||
#include <xcb/xcb.h>
|
||||
#include <textbox.h>
|
||||
#include <rofi.h>
|
||||
#include <cairo-xlib.h>
|
||||
|
@ -22,85 +20,36 @@ unsigned int normal_window_mode = 0;
|
|||
printf ( "Test %3i passed (%s)\n", ++test, # a ); \
|
||||
}
|
||||
|
||||
Display *display = NULL;
|
||||
Colormap map = None;
|
||||
XVisualInfo vinfo;
|
||||
#include "view.h"
|
||||
void rofi_view_queue_redraw ()
|
||||
{
|
||||
}
|
||||
|
||||
void rofi_view_error_dialog ( const char *msg, G_GNUC_UNUSED int markup )
|
||||
Color color_get ( const char *name )
|
||||
{
|
||||
fputs ( msg, stderr );
|
||||
}
|
||||
|
||||
int rofi_view_error_dialog ( const char *msg, G_GNUC_UNUSED int markup )
|
||||
{
|
||||
fputs ( msg, stderr );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
int abe_test_action ( KeyBindingAction action, unsigned int mask, xkb_keysym_t key )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
int show_error_message ( const char *msg, int markup )
|
||||
{
|
||||
rofi_view_error_dialog ( msg, markup );
|
||||
return 0;
|
||||
}
|
||||
|
||||
static unsigned int color_get ( Display *display, const char *const name )
|
||||
{
|
||||
XColor color;
|
||||
// Special format.
|
||||
if ( strncmp ( name, "argb:", 5 ) == 0 ) {
|
||||
return strtoul ( &name[5], NULL, 16 );
|
||||
}
|
||||
else {
|
||||
return XAllocNamedColor ( display, map, name, &color, &color ) ? color.pixel : None;
|
||||
}
|
||||
}
|
||||
|
||||
static void create_visual_and_colormap ()
|
||||
{
|
||||
map = None;
|
||||
// Try to create TrueColor map
|
||||
if ( XMatchVisualInfo ( display, DefaultScreen ( display ), 32, TrueColor, &vinfo ) ) {
|
||||
// Visual found, lets try to create map.
|
||||
map = XCreateColormap ( display, DefaultRootWindow ( display ), vinfo.visual, AllocNone );
|
||||
}
|
||||
// Failed to create map.
|
||||
if ( map == None ) {
|
||||
// Two fields we use.
|
||||
vinfo.visual = DefaultVisual ( display, DefaultScreen ( display ) );
|
||||
vinfo.depth = DefaultDepth ( display, DefaultScreen ( display ) );
|
||||
map = DefaultColormap ( display, DefaultScreen ( display ) );
|
||||
}
|
||||
}
|
||||
int main ( G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv )
|
||||
{
|
||||
// Get DISPLAY
|
||||
const char *display_str = getenv ( "DISPLAY" );
|
||||
if ( !( display = XOpenDisplay ( display_str ) ) ) {
|
||||
fprintf ( stderr, "cannot open display!\n" );
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
create_visual_and_colormap ();
|
||||
|
||||
setup_abe ();
|
||||
TASSERT ( display != NULL );
|
||||
XSetWindowAttributes attr;
|
||||
attr.colormap = map;
|
||||
attr.border_pixel = color_get ( display, "white" );
|
||||
attr.background_pixel = color_get ( display, "black" );
|
||||
Window mw = XCreateWindow ( display, DefaultRootWindow ( display ),
|
||||
0, 0, 200, 100, config.menu_bw, vinfo.depth, InputOutput,
|
||||
vinfo.visual, CWColormap | CWBorderPixel | CWBackPixel, &attr );
|
||||
TASSERT ( mw != None );
|
||||
|
||||
cairo_surface_t *surface = cairo_xlib_surface_create ( display, mw, vinfo.visual, 200, 100 );
|
||||
// Create a drawable.
|
||||
cairo_t *draw = cairo_create ( surface );
|
||||
cairo_set_operator ( draw, CAIRO_OPERATOR_SOURCE );
|
||||
// Set alternate row to normal row.
|
||||
config.menu_bg_alt = config.menu_bg;
|
||||
textbox_setup ( display );
|
||||
PangoContext *p = pango_cairo_create_context ( draw );
|
||||
cairo_surface_t *surf = cairo_image_surface_create ( CAIRO_FORMAT_ARGB32, 100, 100 );
|
||||
cairo_t *draw = cairo_create ( surf );
|
||||
PangoContext *p = pango_cairo_create_context ( draw );
|
||||
textbox_set_pango_context ( p );
|
||||
// cleanup
|
||||
g_object_unref ( p );
|
||||
|
||||
textbox *box = textbox_create ( TB_EDITABLE | TB_AUTOWIDTH | TB_AUTOHEIGHT, 0, 0, -1, -1,
|
||||
NORMAL, "test" );
|
||||
|
@ -172,7 +121,7 @@ int main ( G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv )
|
|||
TASSERT ( box->cursor == 5 );
|
||||
|
||||
textbox_font ( box, HIGHLIGHT );
|
||||
textbox_draw ( box, draw );
|
||||
//textbox_draw ( box, draw );
|
||||
|
||||
widget_move ( WIDGET ( box ), 12, 13 );
|
||||
TASSERT ( box->widget.x == 12 );
|
||||
|
@ -180,11 +129,4 @@ int main ( G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv )
|
|||
|
||||
textbox_free ( box );
|
||||
textbox_cleanup ( );
|
||||
|
||||
cleanup_abe ();
|
||||
|
||||
cairo_destroy ( draw );
|
||||
cairo_surface_destroy ( surface );
|
||||
XDestroyWindow ( display, mw );
|
||||
XCloseDisplay ( display );
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue