build: update autotools logic and add "wlterm" application
Sorry for the big commit, but I was working on the wlterm application and
then thought I can rework the whole configure-logic again. This mainly
renames all build-defines to BUILD_DEFINE_* and BUILD_HAVE_* and allows
specifying which applications to build via --enable-kmscon/--enable-wlterm
and similar.
wlterm is a new application which is a native wayland client with no
external dependencies. It serves several purposes:
* It uses TSM (not yet implemented, but will come soon) to create a
console independent from kmscon. This shows how TSM can easily be used
to create independent terminal emulators.
* It is a native wayland application (probably the first independent
wayland app so far?) and is used to test how well the wayland API
works. As wayland is still under heavy development, we need more
application-writers who report back whether the wayland-API makes
sense to them and whether it works correctly.
* A proper terminal-emulator for wayland! There is currently no proper
emulator so we really need something that we can work with.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
This commit is contained in:
1 parent
f2081c84ee
commit
f9de068a09
21 files changed
+2841
-127
No files matched your search
+1
-1
@@ -37,4 +37,4 @@ docs/reference/kmscon.????*
|
||||
docs/reference/*.stamp
|
||||
docs/reference/version.xml
|
||||
docs/reference/*/
|
||||
gtk-doc.make
|
||||
wlterm
|
||||
+77
-46
@@ -26,14 +26,12 @@ pkgconfig_DATA =
|
||||
# genshader: Program used to convert shaders into C-source files
|
||||
#
|
||||
|
||||
bin_PROGRAMS = \
|
||||
kmscon
|
||||
bin_PROGRAMS =
|
||||
check_PROGRAMS =
|
||||
noinst_PROGRAMS = \
|
||||
genshader \
|
||||
genunifont
|
||||
noinst_LTLIBRARIES = \
|
||||
libkmscon-core.la
|
||||
noinst_LTLIBRARIES =
|
||||
lib_LTLIBRARIES =
|
||||
|
||||
#
|
||||
@@ -58,11 +56,11 @@ AM_CPPFLAGS = \
|
||||
AM_LDFLAGS = \
|
||||
-Wl,--as-needed
|
||||
|
||||
if DEBUG
|
||||
if BUILD_ENABLE_DEBUG
|
||||
AM_CFLAGS += -g
|
||||
endif
|
||||
|
||||
if OPTIMIZATIONS
|
||||
if BUILD_ENABLE_OPTIMIZATIONS
|
||||
AM_CFLAGS += -O2
|
||||
else
|
||||
AM_CFLAGS += -O0
|
||||
@@ -97,8 +95,11 @@ SHL_HOOK = \
|
||||
# compiled into a separate object to allow using it in several other programs.
|
||||
#
|
||||
|
||||
lib_LTLIBRARIES += \
|
||||
libeloop.la
|
||||
if BUILD_ENABLE_ELOOP
|
||||
lib_LTLIBRARIES += libeloop.la
|
||||
include_HEADERS += src/eloop.h
|
||||
pkgconfig_DATA += libeloop.pc
|
||||
endif
|
||||
|
||||
libeloop_la_SOURCES = \
|
||||
$(SHL_DLIST) \
|
||||
@@ -107,7 +108,7 @@ libeloop_la_SOURCES = \
|
||||
src/eloop.h \
|
||||
src/eloop.c
|
||||
|
||||
if EV_HAVE_DBUS
|
||||
if BUILD_ENABLE_DBUS
|
||||
libeloop_la_SOURCES += \
|
||||
external/dbus-common.h \
|
||||
external/dbus-loop.h \
|
||||
@@ -122,11 +123,6 @@ libeloop_la_LIBADD = \
|
||||
libeloop_la_LDFLAGS = \
|
||||
-version-info 1:0:0
|
||||
|
||||
include_HEADERS += \
|
||||
src/eloop.h
|
||||
|
||||
pkgconfig_DATA += libeloop.pc
|
||||
|
||||
#
|
||||
# libtsm
|
||||
# The Terminal-emulator State Machine is a library that implements the whole VTE
|
||||
@@ -134,8 +130,14 @@ pkgconfig_DATA += libeloop.pc
|
||||
# be used to implement any kind of terminal emulator or debugger.
|
||||
#
|
||||
|
||||
lib_LTLIBRARIES += \
|
||||
libtsm.la
|
||||
if BUILD_ENABLE_TSM
|
||||
lib_LTLIBRARIES += libtsm.la
|
||||
include_HEADERS += \
|
||||
src/tsm_screen.h \
|
||||
src/tsm_unicode.h \
|
||||
src/tsm_vte.h
|
||||
pkgconfig_DATA += libtsm.pc
|
||||
endif
|
||||
|
||||
libtsm_la_SOURCES = \
|
||||
$(SHL_LLOG) \
|
||||
@@ -155,14 +157,6 @@ libtsm_la_CPPFLAGS = \
|
||||
libtsm_la_LDFLAGS = \
|
||||
-version-info 1:0:0
|
||||
|
||||
include_HEADERS += \
|
||||
src/tsm_screen.h \
|
||||
src/tsm_unicode.h \
|
||||
src/tsm_vte.h
|
||||
|
||||
pkgconfig_DATA += \
|
||||
libtsm.pc
|
||||
|
||||
#
|
||||
# libuterm
|
||||
# The uterm library provides helpers to create terminals in user-space. They
|
||||
@@ -171,8 +165,11 @@ pkgconfig_DATA += \
|
||||
# abstractions and an input layer
|
||||
#
|
||||
|
||||
lib_LTLIBRARIES += \
|
||||
libuterm.la
|
||||
if BUILD_ENABLE_UTERM
|
||||
lib_LTLIBRARIES += libuterm.la
|
||||
include_HEADERS += src/uterm.h
|
||||
pkgconfig_DATA += libuterm.pc
|
||||
endif
|
||||
|
||||
libuterm_la_SOURCES = \
|
||||
$(SHL_DLIST) \
|
||||
@@ -210,12 +207,12 @@ libuterm_la_LIBADD = \
|
||||
libuterm_la_LDFLAGS = \
|
||||
-version-info 1:0:0
|
||||
|
||||
if UTERM_HAVE_FBDEV
|
||||
if BUILD_ENABLE_FBDEV
|
||||
libuterm_la_SOURCES += \
|
||||
src/uterm_video_fbdev.c
|
||||
endif
|
||||
|
||||
if UTERM_HAVE_DRM
|
||||
if BUILD_ENABLE_DRM
|
||||
libuterm_la_SOURCES += \
|
||||
src/uterm_video_drm.c
|
||||
libuterm_la_SOURCES += \
|
||||
@@ -226,21 +223,16 @@ nodist_libuterm_la_SOURCES += \
|
||||
src/static_shaders.c
|
||||
endif
|
||||
|
||||
if UTERM_HAVE_DUMB
|
||||
if BUILD_ENABLE_DUMB
|
||||
libuterm_la_SOURCES += \
|
||||
src/uterm_video_dumb.c
|
||||
endif
|
||||
|
||||
if UTERM_HAVE_XKBCOMMON
|
||||
if BUILD_ENABLE_XKBCOMMON
|
||||
libuterm_la_SOURCES += \
|
||||
src/uterm_input_uxkb.c
|
||||
endif
|
||||
|
||||
include_HEADERS += \
|
||||
src/uterm.h
|
||||
|
||||
pkgconfig_DATA += libuterm.pc
|
||||
|
||||
#
|
||||
# Shaders
|
||||
# As there is no need to modify shaders at run-time, we statically compile them
|
||||
@@ -297,6 +289,10 @@ src/text_font_unifont_data.c: $(UNIFONT) genunifont$(EXEEXT)
|
||||
# Only "main.c" is not included here as it contains the main() function.
|
||||
#
|
||||
|
||||
if BUILD_ENABLE_KMSCON
|
||||
noinst_LTLIBRARIES += libkmscon-core.la
|
||||
endif
|
||||
|
||||
libkmscon_core_la_SOURCES = \
|
||||
$(SHL_DLIST) \
|
||||
$(SHL_ARRAY) \
|
||||
@@ -315,39 +311,39 @@ libkmscon_core_la_SOURCES = \
|
||||
src/text_font.c
|
||||
nodist_libkmscon_core_la_SOURCES =
|
||||
|
||||
if KMSCON_HAVE_UNIFONT
|
||||
if BUILD_ENABLE_UNIFONT
|
||||
libkmscon_core_la_SOURCES += \
|
||||
src/text_font_unifont.c
|
||||
nodist_libkmscon_core_la_SOURCES += \
|
||||
src/text_font_unifont_data.c
|
||||
endif
|
||||
|
||||
if KMSCON_HAVE_8X16
|
||||
if BUILD_ENABLE_8X16
|
||||
libkmscon_core_la_SOURCES += \
|
||||
src/text_font_8x16.c
|
||||
endif
|
||||
|
||||
if KMSCON_HAVE_FREETYPE2
|
||||
if BUILD_ENABLE_FREETYPE2
|
||||
libkmscon_core_la_SOURCES += \
|
||||
src/text_font_freetype2.c
|
||||
endif
|
||||
|
||||
if KMSCON_HAVE_PANGO
|
||||
if BUILD_ENABLE_PANGO
|
||||
libkmscon_core_la_SOURCES += \
|
||||
src/text_font_pango.c
|
||||
endif
|
||||
|
||||
if KMSCON_HAVE_BBLIT
|
||||
if BUILD_ENABLE_BBLIT
|
||||
libkmscon_core_la_SOURCES += \
|
||||
src/text_bblit.c
|
||||
endif
|
||||
|
||||
if KMSCON_HAVE_BBULK
|
||||
if BUILD_ENABLE_BBULK
|
||||
libkmscon_core_la_SOURCES += \
|
||||
src/text_bbulk.c
|
||||
endif
|
||||
|
||||
if KMSCON_HAVE_GLES2
|
||||
if BUILD_ENABLE_GLES2
|
||||
libkmscon_core_la_SOURCES += \
|
||||
src/text_gltex.c \
|
||||
src/static_gl.h \
|
||||
@@ -378,6 +374,15 @@ libkmscon_core_la_LIBADD = \
|
||||
# built as part of kmscon.
|
||||
#
|
||||
|
||||
if BUILD_ENABLE_KMSCON
|
||||
bin_PROGRAMS += kmscon
|
||||
check_PROGRAMS += \
|
||||
test_output \
|
||||
test_vt \
|
||||
test_input \
|
||||
test_key
|
||||
endif
|
||||
|
||||
kmscon_SOURCES = \
|
||||
$(SHL_DLIST) \
|
||||
src/main.c
|
||||
@@ -386,17 +391,43 @@ kmscon_LDADD = \
|
||||
libeloop.la \
|
||||
libkmscon-core.la
|
||||
|
||||
check_PROGRAMS += test_output
|
||||
test_output_SOURCES = tests/test_output.c tests/test_include.h
|
||||
test_output_LDADD = libkmscon-core.la
|
||||
|
||||
check_PROGRAMS += test_vt
|
||||
test_vt_SOURCES = tests/test_vt.c
|
||||
test_vt_LDADD = libkmscon-core.la
|
||||
|
||||
check_PROGRAMS += test_input
|
||||
test_input_SOURCES = tests/test_input.c
|
||||
test_input_LDADD = libkmscon-core.la
|
||||
|
||||
check_PROGRAMS += test_key
|
||||
test_key_SOURCES = tests/test_key.c
|
||||
|
||||
#
|
||||
# Wayland Terminal
|
||||
#
|
||||
|
||||
if BUILD_ENABLE_WLTERM
|
||||
bin_PROGRAMS += wlterm
|
||||
endif
|
||||
|
||||
wlterm_SOURCES = \
|
||||
src/wlt_main.h \
|
||||
src/wlt_main.c \
|
||||
src/wlt_toolkit.h \
|
||||
src/wlt_toolkit.c \
|
||||
src/wlt_theme.h \
|
||||
src/wlt_theme.c \
|
||||
src/wlt_terminal.h \
|
||||
src/wlt_terminal.c \
|
||||
src/log.h \
|
||||
src/log.c \
|
||||
src/conf.h \
|
||||
src/conf.c
|
||||
wlterm_CPPFLAGS = \
|
||||
$(AM_CPPFLAGS) \
|
||||
$(WAYLAND_CFLAGS)
|
||||
wlterm_LDADD = \
|
||||
libeloop.la \
|
||||
libtsm.la \
|
||||
-lpthread \
|
||||
$(WAYLAND_LIBS)
|
||||
+180
-42
@@ -73,10 +73,49 @@ PKG_CHECK_MODULES([FREETYPE2], [freetype2 fontconfig],
|
||||
PKG_CHECK_MODULES([PANGO], [pango pangoft2],
|
||||
[have_pango=yes], [have_pango=no])
|
||||
|
||||
PKG_CHECK_MODULES([WAYLAND], [wayland-client wayland-server wayland-cursor],
|
||||
[have_wayland=yes], [have_wayland=no])
|
||||
|
||||
#
|
||||
# Parse arguments
|
||||
# Parse all command line arguments and save the values so we can check them
|
||||
# later when configuring kmscon.
|
||||
# Parse arguments for applications
|
||||
# Parse all command-line arguments that enable or disable build of applications.
|
||||
# This allows us to compute which dependencies we need.
|
||||
#
|
||||
|
||||
AC_MSG_CHECKING([whether to compile eloop])
|
||||
AC_ARG_ENABLE([eloop],
|
||||
[AS_HELP_STRING([--enable-eloop],
|
||||
[build eloop library])])
|
||||
AC_MSG_RESULT([ok])
|
||||
|
||||
AC_MSG_CHECKING([whether to compile TSM])
|
||||
AC_ARG_ENABLE([tsm],
|
||||
[AS_HELP_STRING([--enable-tsm],
|
||||
[build tsm library])])
|
||||
AC_MSG_RESULT([ok])
|
||||
|
||||
AC_MSG_CHECKING([whether to compile uterm])
|
||||
AC_ARG_ENABLE([uterm],
|
||||
[AS_HELP_STRING([--enable-uterm],
|
||||
[build uterm library])])
|
||||
AC_MSG_RESULT([ok])
|
||||
|
||||
AC_MSG_CHECKING([whether to compile kmscon])
|
||||
AC_ARG_ENABLE([kmscon],
|
||||
[AS_HELP_STRING([--disable-kmscon],
|
||||
[do not build kmscon])])
|
||||
AC_MSG_RESULT([ok])
|
||||
|
||||
AC_MSG_CHECKING([whether to build wlterm])
|
||||
AC_ARG_ENABLE([wlterm],
|
||||
[AS_HELP_STRING([--enable-wlterm],
|
||||
[build wlterm])])
|
||||
AC_MSG_RESULT([ok])
|
||||
|
||||
#
|
||||
# Parse depedency arguments
|
||||
# This parses all command-line arguments to check for which dependencies should
|
||||
# be used and how the applications should be built.
|
||||
#
|
||||
|
||||
AC_MSG_CHECKING([whether to use systemd for multi-seat support])
|
||||
@@ -157,6 +196,13 @@ AC_ARG_ENABLE([bbulk],
|
||||
[disable bbulk rendering backend])])
|
||||
AC_MSG_RESULT([ok])
|
||||
|
||||
#
|
||||
# Parse miscellaneous arguments
|
||||
# These don't belong into the categories above for several reason so they are
|
||||
# handled specially.
|
||||
# They configure compiler options and similar.
|
||||
#
|
||||
|
||||
AC_MSG_CHECKING([whether to build with debugging on])
|
||||
AC_ARG_ENABLE([debug],
|
||||
[AS_HELP_STRING([--enable-debug],
|
||||
@@ -186,25 +232,83 @@ if test ! x$enable_optimizations = xno ; then
|
||||
fi
|
||||
|
||||
if test x$debug_enabled = xyes ; then
|
||||
AC_DEFINE([KMSCON_ENABLE_DEBUG], [1],
|
||||
[Enable debug for kmscon])
|
||||
AC_DEFINE([LOG_ENABLE_DEBUG], [1],
|
||||
[Enable debug for log subsystem])
|
||||
AC_DEFINE([LLOG_ENABLE_DEBUG], [1],
|
||||
[Enable debug for llog subsystem])
|
||||
AC_DEFINE([BUILD_ENABLE_DEBUG], [1],
|
||||
[Enable debug mode])
|
||||
else
|
||||
AC_DEFINE([NDEBUG], [1], [No Debug])
|
||||
fi
|
||||
|
||||
AM_CONDITIONAL([DEBUG], [test x$debug_enabled = xyes])
|
||||
AM_CONDITIONAL([OPTIMIZATIONS], [test x$optimizations_enabled = xyes])
|
||||
AM_CONDITIONAL([BUILD_ENABLE_DEBUG],
|
||||
[test x$debug_enabled = xyes])
|
||||
AM_CONDITIONAL([BUILD_ENABLE_OPTIMIZATIONS],
|
||||
[test x$optimizations_enabled = xyes])
|
||||
|
||||
#
|
||||
# Main dependencies
|
||||
# This checks for all dependencies that are not optional.
|
||||
# Main applications
|
||||
# This checks which applications to build so we can optionally disable unused
|
||||
# dependencies below.
|
||||
#
|
||||
# Dependency Calculations
|
||||
# The first thing we do is checking which applications to build. Then we
|
||||
# forcibly enable all libraries that are needed by these and then we forcibly
|
||||
# enable all other source-code dependecies.
|
||||
#
|
||||
# The "enable_XY" flag is user input that is set to "yes" if they enabled it
|
||||
# explicitly, "no" if they disabled it explicitly or "" (empty) if they did
|
||||
# not specify it explicitly. In the latter case we enable it if all dependencies
|
||||
# are met, otherwise, we disable it. This does not work for applications,
|
||||
# though. If an application is not specified explicitly by the user, then we
|
||||
# force the default value.
|
||||
# An application also forces all _hard_ dependencies to "yes" and so fails if
|
||||
# they cannot be met.
|
||||
#
|
||||
|
||||
# We currently have no mandatory dependencies!
|
||||
kmscon_enabled=no
|
||||
if test ! x$enable_kmscon = xno ; then
|
||||
kmscon_enabled=yes
|
||||
enable_eloop=yes
|
||||
enable_tsm=yes
|
||||
enable_uterm=yes
|
||||
fi
|
||||
|
||||
AM_CONDITIONAL([BUILD_ENABLE_KMSCON],
|
||||
[test x$kmscon_enabled = xyes])
|
||||
|
||||
wlterm_enabled=no
|
||||
if test x$enable_wlterm = xyes ; then
|
||||
wlterm_enabled=yes
|
||||
enable_eloop=yes
|
||||
enable_tsm=yes
|
||||
enable_wayland=yes
|
||||
fi
|
||||
|
||||
AM_CONDITIONAL([BUILD_ENABLE_WLTERM],
|
||||
[test x$wlterm_enabled = xyes])
|
||||
|
||||
uterm_enabled=no
|
||||
if test x$enable_uterm = xyes ; then
|
||||
uterm_enabled=yes
|
||||
eloop_enabled=yes
|
||||
fi
|
||||
|
||||
AM_CONDITIONAL([BUILD_ENABLE_UTERM],
|
||||
[test x$uterm_enabled = xyes])
|
||||
|
||||
eloop_enabled=no
|
||||
if test x$enable_eloop = xyes ; then
|
||||
eloop_enabled=yes
|
||||
fi
|
||||
|
||||
AM_CONDITIONAL([BUILD_ENABLE_ELOOP],
|
||||
[test x$eloop_enabled = xyes])
|
||||
|
||||
tsm_enabled=no
|
||||
if test x$enable_tsm = xyes ; then
|
||||
tsm_enabled=yes
|
||||
fi
|
||||
|
||||
AM_CONDITIONAL([BUILD_ENABLE_TSM],
|
||||
[test x$tsm_enabled = xyes])
|
||||
|
||||
#
|
||||
# Systemd dependency
|
||||
@@ -223,7 +327,7 @@ if test ! x$enable_systemd = xno ; then
|
||||
fi
|
||||
|
||||
if test x$systemd_enabled = xyes ; then
|
||||
AC_DEFINE([UTERM_HAVE_SYSTEMD], [1],
|
||||
AC_DEFINE([BUILD_ENABLE_SYSTEMD], [1],
|
||||
[Use systemd for multi-seat support])
|
||||
else
|
||||
SYSTEMD_CFLAGS=""
|
||||
@@ -247,7 +351,7 @@ if test ! x$enable_udev = xno ; then
|
||||
fi
|
||||
|
||||
if test x$udev_enabled = xyes ; then
|
||||
AC_DEFINE([UTERM_HAVE_UDEV], [1],
|
||||
AC_DEFINE([BUILD_ENABLE_UDEV], [1],
|
||||
[Use udev for device hotplug support])
|
||||
else
|
||||
UDEV_CFLAGS=""
|
||||
@@ -261,7 +365,7 @@ fi
|
||||
#
|
||||
|
||||
dbus_enabled=no
|
||||
if test ! x$enable_dbus = xno ; then
|
||||
if test x$enable_dbus = xyes ; then
|
||||
if test x$have_dbus = xyes ; then
|
||||
dbus_enabled=yes
|
||||
elif test x$enable_dbus = xyes; then
|
||||
@@ -270,14 +374,14 @@ if test ! x$enable_dbus = xno ; then
|
||||
fi
|
||||
|
||||
if test x$dbus_enabled = xyes; then
|
||||
AC_DEFINE([EV_HAVE_DBUS], [1],
|
||||
AC_DEFINE([BUILD_ENABLE_DBUS], [1],
|
||||
[Use dbus for IPC])
|
||||
else
|
||||
DBUS_CFLAGS=""
|
||||
DBUS_LIBS=""
|
||||
fi
|
||||
|
||||
AM_CONDITIONAL([EV_HAVE_DBUS], [test x$dbus_enabled = xyes])
|
||||
AM_CONDITIONAL([BUILD_ENABLE_DBUS], [test x$dbus_enabled = xyes])
|
||||
|
||||
#
|
||||
# Uterm fbdev backend
|
||||
@@ -292,11 +396,11 @@ if test ! x$enable_fbdev = xno ; then
|
||||
fi
|
||||
|
||||
if test x$fbdev_enabled = xyes ; then
|
||||
AC_DEFINE([UTERM_HAVE_FBDEV], [1],
|
||||
AC_DEFINE([BUILD_ENABLE_FBDEV], [1],
|
||||
[Use uterm fbdev video backend])
|
||||
fi
|
||||
|
||||
AM_CONDITIONAL([UTERM_HAVE_FBDEV], [test x$fbdev_enabled = xyes])
|
||||
AM_CONDITIONAL([BUILD_ENABLE_FBDEV], [test x$fbdev_enabled = xyes])
|
||||
|
||||
#
|
||||
# Uterm drm backend
|
||||
@@ -332,11 +436,11 @@ if test ! x$enable_drm = xno ; then
|
||||
fi
|
||||
|
||||
if test x$dumb_enabled = xyes ; then
|
||||
AC_DEFINE([UTERM_HAVE_DUMB], [1],
|
||||
AC_DEFINE([BUILD_ENABLE_DUMB], [1],
|
||||
[Use uterm dumb drm video backend])
|
||||
|
||||
if test x$drm_enabled = xyes ; then
|
||||
AC_DEFINE([UTERM_HAVE_DRM], [1],
|
||||
AC_DEFINE([BUILD_ENABLE_DRM], [1],
|
||||
[Use uterm DRM video backend])
|
||||
else
|
||||
GBM_CFLAGS=""
|
||||
@@ -354,17 +458,18 @@ else
|
||||
fi
|
||||
|
||||
if test x$gles2_enabled = xyes ; then
|
||||
AC_DEFINE([KMSCON_HAVE_GLES2], [1],
|
||||
AC_DEFINE([BUILD_ENABLE_GLES2], [1],
|
||||
[Use OpenGLESv2 as drawing backend])
|
||||
else
|
||||
GLES2_CFLAGS=""
|
||||
GLES2_LIBS=""
|
||||
fi
|
||||
|
||||
AM_CONDITIONAL([UTERM_HAVE_DUMB], [test x$dumb_enabled = xyes])
|
||||
AM_CONDITIONAL([UTERM_HAVE_DRM], [test x$drm_enabled = xyes])
|
||||
AM_CONDITIONAL([KMSCON_HAVE_GLES2], [test x$gles2_enabled = xyes])
|
||||
AM_CONDITIONAL([BUILD_ENABLE_DUMB], [test x$dumb_enabled = xyes])
|
||||
AM_CONDITIONAL([BUILD_ENABLE_DRM], [test x$drm_enabled = xyes])
|
||||
AM_CONDITIONAL([BUILD_ENABLE_GLES2], [test x$gles2_enabled = xyes])
|
||||
|
||||
# check for gbm_bo_get_stride() function, otherwise gbm_bo_get_pitch() is used
|
||||
if test x$have_gbm = xyes ; then
|
||||
save_CFLAGS="$CFLAGS"
|
||||
save_LIBS="$LIBS"
|
||||
@@ -372,7 +477,7 @@ if test x$have_gbm = xyes ; then
|
||||
LIBS="$LIBS $GBM_LIBS $DRM_LIBS"
|
||||
AC_CHECK_LIB([gbm],
|
||||
[gbm_bo_get_stride],
|
||||
[AC_DEFINE([HAVE_GBM_BO_GET_STRIDE],
|
||||
[AC_DEFINE([BUILD_HAVE_GBM_BO_GET_STRIDE],
|
||||
[1],
|
||||
[Define to 1 if your libgbm provides gbm_bo_get_stride])])
|
||||
CFLAGS="$save_CFLAGS"
|
||||
@@ -395,14 +500,14 @@ if test ! x$enable_xkbcommon = xno ; then
|
||||
fi
|
||||
|
||||
if test x$xkbcommon_enabled = xyes ; then
|
||||
AC_DEFINE([UTERM_HAVE_XKBCOMMON], [1],
|
||||
AC_DEFINE([BUILD_ENABLE_XKBCOMMON], [1],
|
||||
[Use xkbcommon as input keyboard handling backend])
|
||||
else
|
||||
XKBCOMMON_CFLAGS=""
|
||||
XKBCOMMON_LIBS=""
|
||||
fi
|
||||
|
||||
AM_CONDITIONAL([UTERM_HAVE_XKBCOMMON], [test x$xkbcommon_enabled = xyes])
|
||||
AM_CONDITIONAL([BUILD_ENABLE_XKBCOMMON], [test x$xkbcommon_enabled = xyes])
|
||||
|
||||
#
|
||||
# Font backends
|
||||
@@ -421,11 +526,11 @@ if test x$enable_unifont = xyes ; then
|
||||
fi
|
||||
|
||||
if test x$unifont_enabled = xyes ; then
|
||||
AC_DEFINE([KMSCON_HAVE_UNIFONT], [1],
|
||||
AC_DEFINE([BUILD_ENABLE_UNIFONT], [1],
|
||||
[Use static unifont backend])
|
||||
fi
|
||||
|
||||
AM_CONDITIONAL([KMSCON_HAVE_UNIFONT], [test x$unifont_enabled = xyes])
|
||||
AM_CONDITIONAL([BUILD_ENABLE_UNIFONT], [test x$unifont_enabled = xyes])
|
||||
|
||||
f8x16_enabled=no
|
||||
if test ! x$enable_f8x16 = xno ; then
|
||||
@@ -433,11 +538,11 @@ if test ! x$enable_f8x16 = xno ; then
|
||||
fi
|
||||
|
||||
if test x$f8x16_enabled = xyes ; then
|
||||
AC_DEFINE([KMSCON_HAVE_8X16], [1],
|
||||
AC_DEFINE([BUILD_ENABLE_8X16], [1],
|
||||
[Use static 8x16 font backend])
|
||||
fi
|
||||
|
||||
AM_CONDITIONAL([KMSCON_HAVE_8X16], [test x$f8x16_enabled = xyes])
|
||||
AM_CONDITIONAL([BUILD_ENABLE_8X16], [test x$f8x16_enabled = xyes])
|
||||
|
||||
freetype2_enabled=no
|
||||
if test ! x$enable_freetype2 = xno ; then
|
||||
@@ -449,14 +554,14 @@ if test ! x$enable_freetype2 = xno ; then
|
||||
fi
|
||||
|
||||
if test x$freetype2_enabled = xyes ; then
|
||||
AC_DEFINE([KMSCON_HAVE_FREETYPE2], [1],
|
||||
AC_DEFINE([BUILD_ENABLE_FREETYPE2], [1],
|
||||
[Use freetype2 as font backend])
|
||||
else
|
||||
FREETYPE2_CFLAGS=""
|
||||
FREETYPE2_LIBS=""
|
||||
fi
|
||||
|
||||
AM_CONDITIONAL([KMSCON_HAVE_FREETYPE2], [test x$freetype2_enabled = xyes])
|
||||
AM_CONDITIONAL([BUILD_ENABLE_FREETYPE2], [test x$freetype2_enabled = xyes])
|
||||
|
||||
pango_enabled=no
|
||||
if test ! x$enable_pango = xno ; then
|
||||
@@ -468,14 +573,14 @@ if test ! x$enable_pango = xno ; then
|
||||
fi
|
||||
|
||||
if test x$pango_enabled = xyes ; then
|
||||
AC_DEFINE([KMSCON_HAVE_PANGO], [1],
|
||||
AC_DEFINE([BUILD_ENABLE_PANGO], [1],
|
||||
[Use pango as font backend])
|
||||
else
|
||||
PANGO_CFLAGS=""
|
||||
PANGO_LIBS=""
|
||||
fi
|
||||
|
||||
AM_CONDITIONAL([KMSCON_HAVE_PANGO], [test x$pango_enabled = xyes])
|
||||
AM_CONDITIONAL([BUILD_ENABLE_PANGO], [test x$pango_enabled = xyes])
|
||||
|
||||
#
|
||||
# BBlit Rendering backend
|
||||
@@ -487,11 +592,11 @@ if test ! x$enable_bblit = xno ; then
|
||||
fi
|
||||
|
||||
if test x$bblit_enabled = xyes ; then
|
||||
AC_DEFINE([KMSCON_HAVE_BBLIT], [1],
|
||||
AC_DEFINE([BUILD_ENABLE_BBLIT], [1],
|
||||
[Use bblit rendering backend])
|
||||
fi
|
||||
|
||||
AM_CONDITIONAL([KMSCON_HAVE_BBLIT], [test x$bblit_enabled = xyes])
|
||||
AM_CONDITIONAL([BUILD_ENABLE_BBLIT], [test x$bblit_enabled = xyes])
|
||||
|
||||
#
|
||||
# BBulk Rendering backend
|
||||
@@ -503,11 +608,11 @@ if test ! x$enable_bbulk = xno ; then
|
||||
fi
|
||||
|
||||
if test x$bbulk_enabled = xyes ; then
|
||||
AC_DEFINE([KMSCON_HAVE_BBULK], [1],
|
||||
AC_DEFINE([BUILD_ENABLE_BBULK], [1],
|
||||
[Use bbulk rendering backend])
|
||||
fi
|
||||
|
||||
AM_CONDITIONAL([KMSCON_HAVE_BBULK], [test x$bbulk_enabled = xyes])
|
||||
AM_CONDITIONAL([BUILD_ENABLE_BBULK], [test x$bbulk_enabled = xyes])
|
||||
|
||||
#
|
||||
# OpenGL Texture rendering backend
|
||||
@@ -520,6 +625,28 @@ if test x$gles2_enabled = xyes ; then
|
||||
gltex_enabled=yes
|
||||
fi
|
||||
|
||||
#
|
||||
# Wayland
|
||||
# This checks whether the wayland libraries are needed and available.
|
||||
#
|
||||
|
||||
wayland_enabled=no
|
||||
if test ! x$enable_wayland = xno ; then
|
||||
if test x$have_wayland = xyes ; then
|
||||
wayland_enabled=yes
|
||||
elif test x$enable_wayland = xyes ; then
|
||||
AC_ERROR([wayland libraries not found])
|
||||
fi
|
||||
fi
|
||||
|
||||
if test x$wayland_enabled = xyes ; then
|
||||
AC_DEFINE([BUILD_ENABLE_WAYLAND], [1],
|
||||
[Enable wayland backends])
|
||||
else
|
||||
WAYLAND_CFLAGS=""
|
||||
WAYLAND_LIBS=""
|
||||
fi
|
||||
|
||||
#
|
||||
# Makefile vars
|
||||
# After everything is configured, we correctly substitute the values for the
|
||||
@@ -546,6 +673,8 @@ AC_SUBST(FREETYPE2_CFLAGS)
|
||||
AC_SUBST(FREETYPE2_LIBS)
|
||||
AC_SUBST(PANGO_CFLAGS)
|
||||
AC_SUBST(PANGO_LIBS)
|
||||
AC_SUBST(WAYLAND_CFLAGS)
|
||||
AC_SUBST(WAYLAND_LIBS)
|
||||
|
||||
AC_CONFIG_FILES([Makefile libeloop.pc libtsm.pc libuterm.pc])
|
||||
AC_OUTPUT
|
||||
@@ -558,9 +687,18 @@ AC_OUTPUT
|
||||
|
||||
AC_MSG_NOTICE([Build configuration:
|
||||
|
||||
Applications and libraries:
|
||||
kmscon: $kmscon_enabled
|
||||
wlterm: $wlterm_enabled
|
||||
uterm: $uterm_enabled
|
||||
eloop: $eloop_enabled
|
||||
tsm: $tsm_enabled
|
||||
|
||||
Miscellaneous options:
|
||||
debug: $debug_enabled
|
||||
optimizations: $optimizations_enabled
|
||||
|
||||
Optional dependencies:
|
||||
systemd: $systemd_enabled
|
||||
udev: $udev_enabled
|
||||
dbus: $dbus_enabled
|
||||
|
||||
@@ -73,6 +73,7 @@ static void log__time(long long *sec, long long *usec)
|
||||
* this so we default to 1 if no external build-number is specified.
|
||||
*/
|
||||
|
||||
/* TODO: define LOG_BUILD as incremental build number */
|
||||
#ifdef LOG_BUILD
|
||||
static unsigned long log_build = LOG_BUILD;
|
||||
#else
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
* debugging-only because it may slow-down your application if every message is
|
||||
* filtered.
|
||||
*
|
||||
* Define LOG_ENABLE_DEBUG before including this header to enable debug-messages
|
||||
* for this file.
|
||||
* Define BUILD_ENABLE_DEBUG before including this header to enable
|
||||
* debug-messages for this file.
|
||||
*/
|
||||
|
||||
#ifndef LOG_H_INCLUDED
|
||||
@@ -258,11 +258,11 @@ extern const char *LOG_SUBSYSTEM;
|
||||
* Helpers
|
||||
* The pick-up all the default values and submit the message to the
|
||||
* log-subsystem. The log_debug() function produces zero-code if
|
||||
* LOG_ENABLE_DEBUG is not defined. Therefore, it can be heavily used for
|
||||
* BUILD_ENABLE_DEBUG is not defined. Therefore, it can be heavily used for
|
||||
* debugging and will not have any side-effects.
|
||||
*/
|
||||
|
||||
#ifdef LOG_ENABLE_DEBUG
|
||||
#ifdef BUILD_ENABLE_DEBUG
|
||||
#define log_debug(format, ...) \
|
||||
log_printf(LOG_DEBUG, (format), ##__VA_ARGS__)
|
||||
#else
|
||||
|
||||
+11
-4
@@ -101,22 +101,29 @@ static const char *LLOG_SUBSYSTEM __attribute__((__unused__));
|
||||
#define llog_dprintf(obj, sev, format, ...) \
|
||||
llog_format((obj), LLOG_DEFAULT, (sev), (format), ##__VA_ARGS__)
|
||||
|
||||
static inline void llog_dummyf(llog_submit_t llog, unsigned int sev,
|
||||
const char *format, ...)
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
* Helpers
|
||||
* They pick-up all the default values and submit the message to the
|
||||
* llog-subsystem. The llog_debug() function produces zero-code if
|
||||
* LLOG_ENABLE_DEBUG is not defined. Therefore, it can be heavily used for
|
||||
* BUILD_ENABLE_DEBUG is not defined. Therefore, it can be heavily used for
|
||||
* debugging and will not have any side-effects.
|
||||
*/
|
||||
|
||||
#ifdef LLOG_ENABLE_DEBUG
|
||||
#ifdef BUILD_ENABLE_DEBUG
|
||||
#define llog_ddebug(obj, format, ...) \
|
||||
llog_dprintf((obj), LLOG_DEBUG, (format), ##__VA_ARGS__)
|
||||
#define llog_debug(obj, format, ...) \
|
||||
llog_ddebug((obj)->llog, (format), ##__VA_ARGS__)
|
||||
#else
|
||||
#define llog_ddebug(obj, format, ...) ((void)0)
|
||||
#define llog_debug(obj, format, ...) ((void)0)
|
||||
#define llog_ddebug(obj, format, ...) \
|
||||
llog_dummyf((obj), LLOG_DEBUG, (format), ##__VA_ARGS__)
|
||||
#define llog_debug(obj, format, ...) \
|
||||
llog_ddebug((obj)->llog, (format), ##__VA_ARGS__)
|
||||
#endif
|
||||
|
||||
#define llog_info(obj, format, ...) \
|
||||
|
||||
+7
-7
@@ -175,7 +175,7 @@ int kmscon_text_render_cb(struct tsm_screen *con, void *data);
|
||||
|
||||
/* modularized backends */
|
||||
|
||||
#ifdef KMSCON_HAVE_UNIFONT
|
||||
#ifdef BUILD_ENABLE_UNIFONT
|
||||
|
||||
int kmscon_font_unifont_load(void);
|
||||
void kmscon_font_unifont_unload(void);
|
||||
@@ -194,7 +194,7 @@ static inline void kmscon_font_unifont_unload(void)
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef KMSCON_HAVE_8X16
|
||||
#ifdef BUILD_ENABLE_8X16
|
||||
|
||||
int kmscon_font_8x16_load(void);
|
||||
void kmscon_font_8x16_unload(void);
|
||||
@@ -212,7 +212,7 @@ static inline void kmscon_font_8x16_unload(void)
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef KMSCON_HAVE_FREETYPE2
|
||||
#ifdef BUILD_ENABLE_FREETYPE2
|
||||
|
||||
int kmscon_font_freetype2_load(void);
|
||||
void kmscon_font_freetype2_unload(void);
|
||||
@@ -230,7 +230,7 @@ static inline void kmscon_font_freetype2_unload(void)
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef KMSCON_HAVE_PANGO
|
||||
#ifdef BUILD_ENABLE_PANGO
|
||||
|
||||
int kmscon_font_pango_load(void);
|
||||
void kmscon_font_pango_unload(void);
|
||||
@@ -248,7 +248,7 @@ static inline void kmscon_font_pango_unload(void)
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef KMSCON_HAVE_BBLIT
|
||||
#ifdef BUILD_ENABLE_BBLIT
|
||||
|
||||
int kmscon_text_bblit_load(void);
|
||||
void kmscon_text_bblit_unload(void);
|
||||
@@ -266,7 +266,7 @@ static inline void kmscon_text_bblit_unload(void)
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef KMSCON_HAVE_BBULK
|
||||
#ifdef BUILD_ENABLE_BBULK
|
||||
|
||||
int kmscon_text_bbulk_load(void);
|
||||
void kmscon_text_bbulk_unload(void);
|
||||
@@ -284,7 +284,7 @@ static inline void kmscon_text_bbulk_unload(void)
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef KMSCON_HAVE_GLES2
|
||||
#ifdef BUILD_ENABLE_GLES2
|
||||
|
||||
int kmscon_text_gltex_load(void);
|
||||
void kmscon_text_gltex_unload(void);
|
||||
|
||||
+1
-1
@@ -485,7 +485,7 @@ int tsm_vte_set_palette(struct tsm_vte *vte, const char *palette)
|
||||
static void vte_write_debug(struct tsm_vte *vte, const char *u8, size_t len,
|
||||
bool raw, const char *file, int line)
|
||||
{
|
||||
#ifdef KMSCON_ENABLE_DEBUG
|
||||
#ifdef BUILD_ENABLE_DEBUG
|
||||
/* in debug mode we check that escape sequences are always <0x7f so they
|
||||
* are correctly parsed by non-unicode and non-8bit-mode clients. */
|
||||
size_t i;
|
||||
|
||||
+1
-1
@@ -499,7 +499,7 @@ int uterm_input_string_to_keysym(struct uterm_input *input, const char *n,
|
||||
if (input)
|
||||
return kbd_desc_string_to_keysym(input->desc, n, out);
|
||||
|
||||
#ifdef UTERM_HAVE_XKBCOMMON
|
||||
#ifdef BUILD_ENABLE_XKBCOMMON
|
||||
return uxkb_string_to_keysym(n, out);
|
||||
#endif
|
||||
|
||||
|
||||
+3
-3
@@ -71,7 +71,7 @@ extern const struct kbd_dev_ops plain_dev_ops;
|
||||
|
||||
extern int plain_string_to_keysym(const char *n, uint32_t *out);
|
||||
|
||||
#ifdef UTERM_HAVE_XKBCOMMON
|
||||
#ifdef BUILD_ENABLE_XKBCOMMON
|
||||
|
||||
struct uxkb_desc {
|
||||
struct xkb_context *ctx;
|
||||
@@ -88,7 +88,7 @@ extern const struct kbd_dev_ops uxkb_dev_ops;
|
||||
|
||||
extern int uxkb_string_to_keysym(const char *n, uint32_t *out);
|
||||
|
||||
#else /* !UTERM_HAVE_XKBCOMMON */
|
||||
#else /* !BUILD_ENABLE_XKBCOMMON */
|
||||
|
||||
struct uxkb_desc {
|
||||
int unused;
|
||||
@@ -102,7 +102,7 @@ static const bool uxkb_available = false;
|
||||
static const struct kbd_desc_ops uxkb_desc_ops;
|
||||
static const struct kbd_dev_ops uxkb_dev_ops;
|
||||
|
||||
#endif /* UTERM_HAVE_XKBCOMMON */
|
||||
#endif /* BUILD_ENABLE_XKBCOMMON */
|
||||
|
||||
struct kbd_desc {
|
||||
unsigned long ref;
|
||||
|
||||
+8
-8
@@ -44,7 +44,7 @@
|
||||
#include "shl_dlist.h"
|
||||
#include "uterm.h"
|
||||
|
||||
#ifdef UTERM_HAVE_SYSTEMD
|
||||
#ifdef BUILD_ENABLE_SYSTEMD
|
||||
#include <systemd/sd-login.h>
|
||||
#endif
|
||||
|
||||
@@ -72,7 +72,7 @@ struct uterm_monitor {
|
||||
uterm_monitor_cb cb;
|
||||
void *data;
|
||||
|
||||
#ifdef UTERM_HAVE_SYSTEMD
|
||||
#ifdef BUILD_ENABLE_SYSTEMD
|
||||
sd_login_monitor *sd_mon;
|
||||
struct ev_fd *sd_mon_fd;
|
||||
#endif
|
||||
@@ -87,7 +87,7 @@ struct uterm_monitor {
|
||||
static void monitor_new_seat(struct uterm_monitor *mon, const char *name);
|
||||
static void monitor_free_seat(struct uterm_monitor_seat *seat);
|
||||
|
||||
#ifdef UTERM_HAVE_SYSTEMD
|
||||
#ifdef BUILD_ENABLE_SYSTEMD
|
||||
|
||||
static void monitor_refresh_seats(struct uterm_monitor *mon)
|
||||
{
|
||||
@@ -184,7 +184,7 @@ static void monitor_sd_deinit(struct uterm_monitor *mon)
|
||||
sd_login_monitor_unref(mon->sd_mon);
|
||||
}
|
||||
|
||||
#else /* !UTERM_HAVE_SYSTEMD */
|
||||
#else /* !BUILD_ENABLE_SYSTEMD */
|
||||
|
||||
static void monitor_refresh_seats(struct uterm_monitor *mon)
|
||||
{
|
||||
@@ -205,7 +205,7 @@ static void monitor_sd_deinit(struct uterm_monitor *mon)
|
||||
{
|
||||
}
|
||||
|
||||
#endif /* UTERM_HAVE_SYSTEMD */
|
||||
#endif /* BUILD_ENABLE_SYSTEMD */
|
||||
|
||||
static void seat_new_dev(struct uterm_monitor_seat *seat,
|
||||
unsigned int type,
|
||||
@@ -474,7 +474,7 @@ static void monitor_udev_add(struct uterm_monitor *mon,
|
||||
}
|
||||
|
||||
if (!strcmp(subs, "drm")) {
|
||||
#ifdef UTERM_HAVE_SYSTEMD
|
||||
#ifdef BUILD_ENABLE_SYSTEMD
|
||||
if (udev_device_has_tag(dev, "seat") != 1) {
|
||||
log_debug("adding non-seat'ed device %s", name);
|
||||
return;
|
||||
@@ -488,7 +488,7 @@ static void monitor_udev_add(struct uterm_monitor *mon,
|
||||
sname = udev_device_get_property_value(dev, "ID_SEAT");
|
||||
type = UTERM_MONITOR_DRM;
|
||||
} else if (!strcmp(subs, "graphics")) {
|
||||
#ifdef UTERM_HAVE_SYSTEMD
|
||||
#ifdef BUILD_ENABLE_SYSTEMD
|
||||
if (udev_device_has_tag(dev, "seat") != 1) {
|
||||
log_debug("adding non-seat'ed device %s", name);
|
||||
return;
|
||||
@@ -516,7 +516,7 @@ static void monitor_udev_add(struct uterm_monitor *mon,
|
||||
log_debug("adding device without parent %s", name);
|
||||
return;
|
||||
}
|
||||
#ifdef UTERM_HAVE_SYSTEMD
|
||||
#ifdef BUILD_ENABLE_SYSTEMD
|
||||
if (udev_device_has_tag(p, "seat") != 1) {
|
||||
log_debug("adding non-seat'ed device %s", name);
|
||||
return;
|
||||
|
||||
+9
-9
@@ -86,7 +86,7 @@ struct video_ops {
|
||||
|
||||
/* drm */
|
||||
|
||||
#ifdef UTERM_HAVE_DRM
|
||||
#ifdef BUILD_ENABLE_DRM
|
||||
|
||||
#include <EGL/egl.h>
|
||||
#include <EGL/eglext.h>
|
||||
@@ -148,7 +148,7 @@ extern const struct mode_ops drm_mode_ops;
|
||||
extern const struct display_ops drm_display_ops;
|
||||
extern const struct video_ops drm_video_ops;
|
||||
|
||||
#else /* !UTERM_HAVE_DRM */
|
||||
#else /* !BUILD_ENABLE_DRM */
|
||||
|
||||
struct drm_mode {
|
||||
int unused;
|
||||
@@ -167,11 +167,11 @@ static const struct mode_ops drm_mode_ops;
|
||||
static const struct display_ops drm_display_ops;
|
||||
static const struct video_ops drm_video_ops;
|
||||
|
||||
#endif /* UTERM_HAVE_DRM */
|
||||
#endif /* BUILD_ENABLE_DRM */
|
||||
|
||||
/* dumb drm */
|
||||
|
||||
#ifdef UTERM_HAVE_DUMB
|
||||
#ifdef BUILD_ENABLE_DUMB
|
||||
|
||||
#include <xf86drm.h>
|
||||
#include <xf86drmMode.h>
|
||||
@@ -208,7 +208,7 @@ extern const struct mode_ops dumb_mode_ops;
|
||||
extern const struct display_ops dumb_display_ops;
|
||||
extern const struct video_ops dumb_video_ops;
|
||||
|
||||
#else /* !UTERM_HAVE_DUMB */
|
||||
#else /* !BUILD_ENABLE_DUMB */
|
||||
|
||||
struct dumb_mode {
|
||||
int unused;
|
||||
@@ -227,11 +227,11 @@ static const struct mode_ops dumb_mode_ops;
|
||||
static const struct display_ops dumb_display_ops;
|
||||
static const struct video_ops dumb_video_ops;
|
||||
|
||||
#endif /* UTERM_HAVE_DUMB */
|
||||
#endif /* BUILD_ENABLE_DUMB */
|
||||
|
||||
/* fbdev */
|
||||
|
||||
#ifdef UTERM_HAVE_FBDEV
|
||||
#ifdef BUILD_ENABLE_FBDEV
|
||||
|
||||
#include <linux/fb.h>
|
||||
|
||||
@@ -277,7 +277,7 @@ extern const struct mode_ops fbdev_mode_ops;
|
||||
extern const struct display_ops fbdev_display_ops;
|
||||
extern const struct video_ops fbdev_video_ops;
|
||||
|
||||
#else /* !UTERM_HAVE_FBDEV */
|
||||
#else /* !BUILD_ENABLE_FBDEV */
|
||||
|
||||
struct fbdev_mode {
|
||||
int unused;
|
||||
@@ -296,7 +296,7 @@ static const struct mode_ops fbdev_mode_ops;
|
||||
static const struct display_ops fbdev_display_ops;
|
||||
static const struct video_ops fbdev_video_ops;
|
||||
|
||||
#endif /* UTERM_HAVE_FBDEV */
|
||||
#endif /* BUILD_ENABLE_FBDEV */
|
||||
|
||||
/* uterm_screen */
|
||||
|
||||
|
||||
@@ -82,7 +82,7 @@ static int init_rb(struct uterm_display *disp, struct drm_rb *rb)
|
||||
return -EFAULT;
|
||||
}
|
||||
|
||||
#ifdef HAVE_GBM_BO_GET_STRIDE
|
||||
#ifdef BUILD_HAVE_GBM_BO_GET_STRIDE
|
||||
stride = gbm_bo_get_stride(rb->bo);
|
||||
#else
|
||||
stride = gbm_bo_get_pitch(rb->bo);
|
||||
|
||||
+271
@@ -0,0 +1,271 @@
|
||||
/*
|
||||
* wlt - Wayland Terminal
|
||||
*
|
||||
* Copyright (c) 2012 David Herrmann <dh.herrmann@googlemail.com>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files
|
||||
* (the "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Wayland Terminal main application
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/signalfd.h>
|
||||
#include <wayland-client.h>
|
||||
#include "conf.h"
|
||||
#include "eloop.h"
|
||||
#include "log.h"
|
||||
#include "wlt_main.h"
|
||||
#include "wlt_terminal.h"
|
||||
#include "wlt_theme.h"
|
||||
#include "wlt_toolkit.h"
|
||||
|
||||
#define LOG_SUBSYSTEM "wlt"
|
||||
|
||||
struct wlt_app {
|
||||
struct ev_eloop *eloop;
|
||||
struct wlt_display *disp;
|
||||
struct wlt_window *wnd;
|
||||
};
|
||||
|
||||
static void sig_generic(struct ev_eloop *eloop, struct signalfd_siginfo *info,
|
||||
void *data)
|
||||
{
|
||||
struct wlt_app *app = data;
|
||||
|
||||
ev_eloop_exit(app->eloop);
|
||||
log_info("terminating due to caught signal %d", info->ssi_signo);
|
||||
}
|
||||
|
||||
static void window_close(struct wlt_window *wnd, void *data)
|
||||
{
|
||||
struct wlt_app *app = data;
|
||||
|
||||
log_info("closing window");
|
||||
ev_eloop_exit(app->eloop);
|
||||
}
|
||||
|
||||
static int window_init(struct wlt_app *app)
|
||||
{
|
||||
int ret;
|
||||
struct wlt_theme *theme;
|
||||
struct wlt_terminal *term;
|
||||
|
||||
ret = wlt_display_create_window(app->disp, &app->wnd,
|
||||
200, 200, app);
|
||||
if (ret) {
|
||||
log_error("cannot create wayland window");
|
||||
return ret;
|
||||
}
|
||||
wlt_window_set_close_cb(app->wnd, window_close);
|
||||
|
||||
ret = wlt_theme_new(&theme, app->wnd);
|
||||
if (ret) {
|
||||
log_error("cannot create theme");
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = wlt_terminal_new(&term, app->wnd);
|
||||
if (ret) {
|
||||
log_error("cannot create terminal");
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void display_event(struct wlt_display *disp, unsigned int event,
|
||||
void *data)
|
||||
{
|
||||
struct wlt_app *app = data;
|
||||
int ret;
|
||||
|
||||
switch (event) {
|
||||
case WLT_DISPLAY_READY:
|
||||
log_info("wayland display initialized");
|
||||
ret = window_init(app);
|
||||
if (ret)
|
||||
ev_eloop_exit(app->eloop);
|
||||
break;
|
||||
case WLT_DISPLAY_HUP:
|
||||
log_info("wayland display connection lost");
|
||||
ev_eloop_exit(app->eloop);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void destroy_app(struct wlt_app *app)
|
||||
{
|
||||
wlt_window_unref(app->wnd);
|
||||
wlt_display_unregister_cb(app->disp, display_event, app);
|
||||
wlt_display_unref(app->disp);
|
||||
ev_eloop_unregister_signal_cb(app->eloop, SIGINT, sig_generic, app);
|
||||
ev_eloop_unregister_signal_cb(app->eloop, SIGTERM, sig_generic, app);
|
||||
ev_eloop_unref(app->eloop);
|
||||
}
|
||||
|
||||
static int setup_app(struct wlt_app *app)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = ev_eloop_new(&app->eloop, log_llog);
|
||||
if (ret)
|
||||
goto err_app;
|
||||
|
||||
ret = ev_eloop_register_signal_cb(app->eloop, SIGTERM,
|
||||
sig_generic, app);
|
||||
if (ret)
|
||||
goto err_app;
|
||||
|
||||
ret = ev_eloop_register_signal_cb(app->eloop, SIGINT,
|
||||
sig_generic, app);
|
||||
if (ret)
|
||||
goto err_app;
|
||||
|
||||
ret = wlt_display_new(&app->disp, app->eloop);
|
||||
if (ret)
|
||||
goto err_app;
|
||||
|
||||
ret = wlt_display_register_cb(app->disp, display_event, app);
|
||||
if (ret)
|
||||
goto err_app;
|
||||
|
||||
return 0;
|
||||
|
||||
err_app:
|
||||
destroy_app(app);
|
||||
return ret;
|
||||
}
|
||||
|
||||
struct wlt_conf_t wlt_conf;
|
||||
|
||||
static void print_help()
|
||||
{
|
||||
/*
|
||||
* Usage/Help information
|
||||
* This should be scaled to a maximum of 80 characters per line:
|
||||
*
|
||||
* 80 char line:
|
||||
* | 10 | 20 | 30 | 40 | 50 | 60 | 70 | 80 |
|
||||
* "12345678901234567890123456789012345678901234567890123456789012345678901234567890\n"
|
||||
* 80 char line starting with tab:
|
||||
* |10| 20 | 30 | 40 | 50 | 60 | 70 | 80 |
|
||||
* "\t901234567890123456789012345678901234567890123456789012345678901234567890\n"
|
||||
*/
|
||||
fprintf(stderr,
|
||||
"Usage:\n"
|
||||
"\t%1$s [options]\n"
|
||||
"\t%1$s -h [options]\n"
|
||||
"\n"
|
||||
"You can prefix boolean options with \"no-\" to negate it. If an argument is\n"
|
||||
"given multiple times, only the last argument matters if not otherwise stated.\n"
|
||||
"\n"
|
||||
"General Options:\n"
|
||||
"\t-h, --help [off] Print this help and exit\n"
|
||||
"\t-v, --verbose [off] Print verbose messages\n"
|
||||
"\t --debug [off] Enable debug mode\n"
|
||||
"\t --silent [off] Suppress notices and warnings\n",
|
||||
"wlterm");
|
||||
/*
|
||||
* 80 char line:
|
||||
* | 10 | 20 | 30 | 40 | 50 | 60 | 70 | 80 |
|
||||
* "12345678901234567890123456789012345678901234567890123456789012345678901234567890\n"
|
||||
* 80 char line starting with tab:
|
||||
* |10| 20 | 30 | 40 | 50 | 60 | 70 | 80 |
|
||||
* "\t901234567890123456789012345678901234567890123456789012345678901234567890\n"
|
||||
*/
|
||||
}
|
||||
|
||||
static int aftercheck_debug(struct conf_option *opt, int argc, char **argv,
|
||||
int idx)
|
||||
{
|
||||
/* --debug implies --verbose */
|
||||
if (wlt_conf.debug)
|
||||
wlt_conf.verbose = 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int aftercheck_help(struct conf_option *opt, int argc, char **argv,
|
||||
int idx)
|
||||
{
|
||||
/* exit after printing --help information */
|
||||
if (wlt_conf.help) {
|
||||
print_help();
|
||||
wlt_conf.exit = true;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct conf_option options[] = {
|
||||
CONF_OPTION_BOOL('h', "help", aftercheck_help, &wlt_conf.help, false),
|
||||
CONF_OPTION_BOOL('v', "verbose", NULL, &wlt_conf.verbose, false),
|
||||
CONF_OPTION_BOOL(0, "debug", aftercheck_debug, &wlt_conf.debug, false),
|
||||
CONF_OPTION_BOOL(0, "silent", NULL, &wlt_conf.silent, false),
|
||||
};
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int ret;
|
||||
struct wlt_app app;
|
||||
size_t onum;
|
||||
|
||||
onum = sizeof(options) / sizeof(*options);
|
||||
ret = conf_parse_argv(options, onum, argc, argv);
|
||||
if (ret)
|
||||
goto err_out;
|
||||
|
||||
if (wlt_conf.exit) {
|
||||
conf_free(options, onum);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
if (!wlt_conf.debug && !wlt_conf.verbose && wlt_conf.silent)
|
||||
log_set_config(&LOG_CONFIG_WARNING(0, 0, 0, 0));
|
||||
else
|
||||
log_set_config(&LOG_CONFIG_INFO(wlt_conf.debug,
|
||||
wlt_conf.verbose));
|
||||
|
||||
log_print_init("wlterm");
|
||||
|
||||
memset(&app, 0, sizeof(app));
|
||||
ret = setup_app(&app);
|
||||
if (ret)
|
||||
goto err_out;
|
||||
|
||||
ev_eloop_run(app.eloop, -1);
|
||||
|
||||
destroy_app(&app);
|
||||
conf_free(options, onum);
|
||||
log_info("exiting");
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
err_out:
|
||||
conf_free(options, onum);
|
||||
log_err("cannot initialize wlterm, errno %d: %s", ret, strerror(-ret));
|
||||
return -ret;
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* wlt - Main Header
|
||||
*
|
||||
* Copyright (c) 2012 David Herrmann <dh.herrmann@googlemail.com>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files
|
||||
* (the "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Wayland Terminal global information and state
|
||||
*/
|
||||
|
||||
#ifndef WLT_MAIN_H
|
||||
#define WLT_MAIN_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
struct wlt_conf_t {
|
||||
/* show help/usage information */
|
||||
bool help;
|
||||
/* exit application after parsing options */
|
||||
bool exit;
|
||||
/* enable debug messages */
|
||||
bool debug;
|
||||
/* enable verbose info messages */
|
||||
bool verbose;
|
||||
/* disable notices and warnings */
|
||||
bool silent;
|
||||
};
|
||||
|
||||
extern struct wlt_conf_t wlt_conf;
|
||||
|
||||
#endif /* WLT_MAIN_H */
|
||||
@@ -0,0 +1,119 @@
|
||||
/*
|
||||
* wlt - Terminals
|
||||
*
|
||||
* Copyright (c) 2012 David Herrmann <dh.herrmann@googlemail.com>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files
|
||||
* (the "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Wayland Terminal console helpers
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "log.h"
|
||||
#include "tsm_unicode.h"
|
||||
#include "tsm_screen.h"
|
||||
#include "tsm_vte.h"
|
||||
#include "wlt_toolkit.h"
|
||||
|
||||
#define LOG_SUBSYSTEM "wlt_terminal"
|
||||
|
||||
struct wlt_terminal {
|
||||
struct wlt_window *wnd;
|
||||
struct wlt_widget *widget;
|
||||
struct wlt_shm_buffer buffer;
|
||||
};
|
||||
|
||||
static void widget_redraw(struct wlt_widget *widget, void *data)
|
||||
{
|
||||
struct wlt_terminal *term = data;
|
||||
unsigned int i, j;
|
||||
uint8_t *dst;
|
||||
uint32_t *line;
|
||||
|
||||
dst = term->buffer.data;
|
||||
for (i = 0; i < term->buffer.height; ++i) {
|
||||
line = (uint32_t*)dst;
|
||||
for (j = 0; j < term->buffer.width; ++j)
|
||||
line[j] = 0xffffffff;
|
||||
dst += term->buffer.stride;
|
||||
}
|
||||
}
|
||||
|
||||
static void widget_resize(struct wlt_widget *widget, struct wlt_rect *alloc,
|
||||
void *data)
|
||||
{
|
||||
struct wlt_terminal *term = data;
|
||||
|
||||
wlt_window_get_buffer(term->wnd, alloc, &term->buffer);
|
||||
|
||||
/* don't allow children */
|
||||
alloc->width = 0;
|
||||
alloc->height = 0;
|
||||
}
|
||||
|
||||
static void widget_destroy(struct wlt_widget *widget, void *data)
|
||||
{
|
||||
struct wlt_terminal *term = data;
|
||||
|
||||
free(term);
|
||||
}
|
||||
|
||||
int wlt_terminal_new(struct wlt_terminal **out, struct wlt_window *wnd)
|
||||
{
|
||||
struct wlt_terminal *term;
|
||||
int ret;
|
||||
|
||||
if (!out || !wnd)
|
||||
return -EINVAL;
|
||||
|
||||
term = malloc(sizeof(*term));
|
||||
if (!term)
|
||||
return -ENOMEM;
|
||||
memset(term, 0, sizeof(*term));
|
||||
term->wnd = wnd;
|
||||
|
||||
ret = wlt_window_create_widget(wnd, &term->widget, term);
|
||||
if (ret) {
|
||||
log_error("cannot create terminal widget");
|
||||
goto err_free;
|
||||
}
|
||||
|
||||
wlt_widget_set_destroy_cb(term->widget, widget_destroy);
|
||||
wlt_widget_set_redraw_cb(term->widget, widget_redraw);
|
||||
wlt_widget_set_resize_cb(term->widget, NULL, widget_resize);
|
||||
*out = term;
|
||||
return 0;
|
||||
|
||||
err_free:
|
||||
free(term);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void wlt_terminal_destroy(struct wlt_terminal *term)
|
||||
{
|
||||
if (!term)
|
||||
return;
|
||||
|
||||
wlt_widget_destroy(term->widget);
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* wlt - Terminals
|
||||
*
|
||||
* Copyright (c) 2012 David Herrmann <dh.herrmann@googlemail.com>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files
|
||||
* (the "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Wayland Terminal console helpers
|
||||
*/
|
||||
|
||||
#ifndef WLT_TERMINAL_H
|
||||
#define WLT_TERMINAL_H
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "wlt_toolkit.h"
|
||||
|
||||
struct wlt_terminal;
|
||||
|
||||
int wlt_terminal_new(struct wlt_terminal **out, struct wlt_window *wnd);
|
||||
void wlt_terminal_destroy(struct wlt_terminal *term);
|
||||
|
||||
#endif /* WLT_TERMINAL_H */
|
||||
+563
@@ -0,0 +1,563 @@
|
||||
/*
|
||||
* wlt - Theme Helper
|
||||
*
|
||||
* Copyright (c) 2012 David Herrmann <dh.herrmann@googlemail.com>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files
|
||||
* (the "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Wayland Terminal theme/decoration drawing helper
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include <linux/input.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <wayland-client.h>
|
||||
#include "log.h"
|
||||
#include "wlt_theme.h"
|
||||
#include "wlt_toolkit.h"
|
||||
|
||||
#define LOG_SUBSYSTEM "wlt_theme"
|
||||
|
||||
enum theme_location {
|
||||
LOC_NOWHERE,
|
||||
LOC_SOMEWHERE,
|
||||
LOC_RESIZE_TOP,
|
||||
LOC_RESIZE_BOTTOM,
|
||||
LOC_RESIZE_LEFT,
|
||||
LOC_RESIZE_RIGHT,
|
||||
LOC_RESIZE_TOP_LEFT,
|
||||
LOC_RESIZE_TOP_RIGHT,
|
||||
LOC_RESIZE_BOTTOM_LEFT,
|
||||
LOC_RESIZE_BOTTOM_RIGHT,
|
||||
LOC_CONTROL,
|
||||
LOC_MINIMIZE,
|
||||
LOC_MAXIMIZE,
|
||||
LOC_CLOSE,
|
||||
};
|
||||
|
||||
struct wlt_theme {
|
||||
struct wlt_window *wnd;
|
||||
struct wlt_widget *widget;
|
||||
struct wlt_shm_buffer buffer;
|
||||
struct wlt_rect alloc;
|
||||
unsigned int control_height;
|
||||
unsigned int frame_width;
|
||||
unsigned int resize_margin;
|
||||
unsigned int button_size;
|
||||
unsigned int button_padding;
|
||||
unsigned int button_margin;
|
||||
|
||||
unsigned int pointer_x;
|
||||
unsigned int pointer_y;
|
||||
unsigned int pointer_loc;
|
||||
bool pointer_pressed;
|
||||
unsigned int pointer_grabbed;
|
||||
};
|
||||
|
||||
static void draw_control(struct wlt_theme *theme)
|
||||
{
|
||||
uint8_t *dst;
|
||||
uint32_t *line, backcol;
|
||||
unsigned int i, j;
|
||||
unsigned int b1off, b2off, b3off;
|
||||
|
||||
/* background */
|
||||
if (theme->pointer_loc == LOC_NOWHERE)
|
||||
backcol = (0x60 << 24) | (0xaa << 16) |
|
||||
(0xaa << 8) | 0xaa;
|
||||
else
|
||||
backcol = (0x20 << 24) | (0xee << 16) |
|
||||
(0xee << 8) | 0xee;
|
||||
dst = theme->buffer.data;
|
||||
for (i = 0; i < theme->control_height; ++i) {
|
||||
line = (uint32_t*)dst;
|
||||
for (j = 0; j < theme->buffer.width; ++j) {
|
||||
if (i == 0 || i == theme->control_height - 1 ||
|
||||
j == 0 || j == theme->buffer.width - 1)
|
||||
line[j] = 0xff << 24;
|
||||
else
|
||||
line[j] = backcol;
|
||||
}
|
||||
dst += theme->buffer.stride;
|
||||
}
|
||||
|
||||
/* buttons */
|
||||
b1off = theme->buffer.width - theme->button_margin - theme->button_size;
|
||||
b2off = b1off - theme->button_padding - theme->button_size;
|
||||
b3off = b2off - theme->button_padding - theme->button_size;
|
||||
dst = theme->buffer.data + theme->buffer.stride * theme->button_margin;
|
||||
for (i = 0; i < theme->button_size; ++i) {
|
||||
line = (uint32_t*)dst;
|
||||
for (j = 0; j < theme->buffer.width; ++j) {
|
||||
if (j >= b1off &&
|
||||
j < b1off + theme->button_size) {
|
||||
if (i == 0 ||
|
||||
i == theme->button_size - 1 ||
|
||||
j == b1off ||
|
||||
j == b1off + theme->button_size - 1)
|
||||
line[j] = 0xff << 24;
|
||||
else if (theme->pointer_loc == LOC_CLOSE &&
|
||||
theme->pointer_pressed &&
|
||||
theme->pointer_grabbed == LOC_CLOSE)
|
||||
line[j] = (0xff << 24) | 0x1f1f1f1f;
|
||||
else if (theme->pointer_loc == LOC_CLOSE &&
|
||||
!theme->pointer_pressed)
|
||||
line[j] = 0xffffffff;
|
||||
else
|
||||
line[j] = (0xff << 24) | 0x33333333;
|
||||
} else if (j >= b2off &&
|
||||
j < b2off + theme->button_size) {
|
||||
if (i == 0 ||
|
||||
i == theme->button_size - 1 ||
|
||||
j == b2off ||
|
||||
j == b2off + theme->button_size - 1)
|
||||
line[j] = 0xff << 24;
|
||||
else if (theme->pointer_loc == LOC_MAXIMIZE &&
|
||||
theme->pointer_pressed &&
|
||||
theme->pointer_grabbed == LOC_MAXIMIZE)
|
||||
line[j] = (0xff << 24) | 0x1f1f1f1f;
|
||||
else if (theme->pointer_loc == LOC_MAXIMIZE &&
|
||||
!theme->pointer_pressed)
|
||||
line[j] = 0xffffffff;
|
||||
else
|
||||
line[j] = (0xff << 24) | 0x66666666;
|
||||
} else if (j >= b3off &&
|
||||
j < b3off + theme->button_size) {
|
||||
if (i == 0 ||
|
||||
i == theme->button_size - 1 ||
|
||||
j == b3off ||
|
||||
j == b3off + theme->button_size - 1)
|
||||
line[j] = 0xff << 24;
|
||||
else if (theme->pointer_loc == LOC_MINIMIZE &&
|
||||
theme->pointer_pressed &&
|
||||
theme->pointer_grabbed == LOC_MINIMIZE)
|
||||
line[j] = (0xff << 24) | 0x1f1f1f1f;
|
||||
else if (theme->pointer_loc == LOC_MINIMIZE &&
|
||||
!theme->pointer_pressed)
|
||||
line[j] = 0xffffffff;
|
||||
else
|
||||
line[j] = (0xff << 24) | 0xaaaaaaaa;
|
||||
}
|
||||
}
|
||||
dst += theme->buffer.stride;
|
||||
}
|
||||
}
|
||||
|
||||
static void draw_frame(struct wlt_theme *theme)
|
||||
{
|
||||
uint8_t *dst;
|
||||
uint32_t *line;
|
||||
unsigned int i, j, height;
|
||||
|
||||
/* top frame */
|
||||
dst = theme->buffer.data + theme->buffer.stride *
|
||||
theme->control_height;
|
||||
for (i = 0; i < theme->frame_width; ++i) {
|
||||
line = (uint32_t*)dst;
|
||||
for (j = 0; j < theme->buffer.width; ++j)
|
||||
line[j] = 0xa0 << 24;
|
||||
dst += theme->buffer.stride;
|
||||
}
|
||||
|
||||
/* bottom frame */
|
||||
dst = theme->buffer.data + theme->buffer.stride *
|
||||
(theme->buffer.height - theme->frame_width);
|
||||
for (i = 0; i < theme->frame_width; ++i) {
|
||||
line = (uint32_t*)dst;
|
||||
for (j = 0; j < theme->buffer.width; ++j)
|
||||
line[j] = 0xa0 << 24;
|
||||
dst += theme->buffer.stride;
|
||||
}
|
||||
|
||||
/* left frame */
|
||||
dst = theme->buffer.data + theme->buffer.stride *
|
||||
(theme->control_height + theme->frame_width);
|
||||
height = theme->buffer.height - theme->control_height -
|
||||
theme->frame_width * 2;
|
||||
for (i = 0; i < height; ++i) {
|
||||
line = (uint32_t*)dst;
|
||||
for (j = 0; j < theme->frame_width; ++j)
|
||||
line[j] = 0xa0 << 24;
|
||||
dst += theme->buffer.stride;
|
||||
}
|
||||
|
||||
/* right frame */
|
||||
dst = theme->buffer.data + theme->buffer.stride *
|
||||
(theme->control_height + theme->frame_width);
|
||||
height = theme->buffer.height - theme->control_height -
|
||||
theme->frame_width * 2;
|
||||
for (i = 0; i < height; ++i) {
|
||||
line = (uint32_t*)dst;
|
||||
line += theme->buffer.width - theme->frame_width;
|
||||
for (j = 0; j < theme->frame_width; ++j)
|
||||
line[j] = 0xa0 << 24;
|
||||
dst += theme->buffer.stride;
|
||||
}
|
||||
}
|
||||
|
||||
static void widget_draw_fallback(struct wlt_theme *theme)
|
||||
{
|
||||
uint8_t *dst;
|
||||
uint32_t *line;
|
||||
unsigned int i, j;
|
||||
|
||||
dst = theme->buffer.data;
|
||||
for (i = 0; i < theme->buffer.height; ++i) {
|
||||
line = (uint32_t*)dst;
|
||||
for (j = 0; j < theme->buffer.width; ++j) {
|
||||
line[j] = 0xff << 24;
|
||||
}
|
||||
dst += theme->buffer.stride;
|
||||
}
|
||||
}
|
||||
|
||||
static void widget_redraw(struct wlt_widget *widget, void *data)
|
||||
{
|
||||
struct wlt_theme *theme = data;
|
||||
unsigned int width, height;
|
||||
|
||||
width = theme->buffer.width;
|
||||
height = theme->buffer.height;
|
||||
if (width < 2 ||
|
||||
width < 2 * theme->frame_width) {
|
||||
widget_draw_fallback(theme);
|
||||
} else if (height < theme->control_height + 2 * theme->frame_width) {
|
||||
widget_draw_fallback(theme);
|
||||
} else {
|
||||
draw_frame(theme);
|
||||
draw_control(theme);
|
||||
}
|
||||
}
|
||||
|
||||
static void widget_prepare_resize(struct wlt_widget *widget,
|
||||
unsigned int *width, unsigned int *height,
|
||||
void *data)
|
||||
{
|
||||
struct wlt_theme *theme = data;
|
||||
unsigned int minw, minh;
|
||||
|
||||
minw = theme->frame_width * 2;
|
||||
minh = theme->control_height + theme->frame_width * 2;
|
||||
if (*width < minw)
|
||||
*width = minw;
|
||||
if (*height < minh)
|
||||
*height = minh;
|
||||
}
|
||||
|
||||
static void widget_resize(struct wlt_widget *widget, struct wlt_rect *alloc,
|
||||
void *data)
|
||||
{
|
||||
struct wlt_theme *theme = data;
|
||||
unsigned int nwidth, nheight;
|
||||
|
||||
wlt_window_get_buffer(theme->wnd, alloc, &theme->buffer);
|
||||
memcpy(&theme->alloc, alloc, sizeof(*alloc));
|
||||
|
||||
alloc->x = theme->frame_width;
|
||||
alloc->y = theme->control_height + theme->frame_width;
|
||||
nwidth = alloc->width - 2 * theme->frame_width;
|
||||
nheight = alloc->height;
|
||||
nheight -= (theme->control_height + 2 * theme->frame_width);
|
||||
|
||||
if (nwidth > alloc->width || nheight > alloc->height) {
|
||||
alloc->width = 0;
|
||||
alloc->height = 0;
|
||||
} else {
|
||||
alloc->width = nwidth;
|
||||
alloc->height = nheight;
|
||||
}
|
||||
}
|
||||
|
||||
static unsigned int get_pointer_location(struct wlt_theme *theme)
|
||||
{
|
||||
unsigned int m = theme->resize_margin;
|
||||
unsigned int b1off, b2off, b3off;
|
||||
|
||||
if (theme->pointer_y < m) {
|
||||
if (theme->pointer_x < m)
|
||||
return LOC_RESIZE_TOP_LEFT;
|
||||
else if (theme->pointer_x >= theme->buffer.width - m)
|
||||
return LOC_RESIZE_TOP_RIGHT;
|
||||
else
|
||||
return LOC_RESIZE_TOP;
|
||||
}
|
||||
|
||||
if (theme->pointer_y >= theme->buffer.height - m) {
|
||||
if (theme->pointer_x < m)
|
||||
return LOC_RESIZE_BOTTOM_LEFT;
|
||||
else if (theme->pointer_x >= theme->buffer.width - m)
|
||||
return LOC_RESIZE_BOTTOM_RIGHT;
|
||||
else
|
||||
return LOC_RESIZE_BOTTOM;
|
||||
}
|
||||
|
||||
if (theme->pointer_x < m)
|
||||
return LOC_RESIZE_LEFT;
|
||||
|
||||
if (theme->pointer_x >= theme->buffer.width - m)
|
||||
return LOC_RESIZE_RIGHT;
|
||||
|
||||
if (theme->pointer_y < theme->control_height) {
|
||||
b1off = theme->buffer.width - theme->button_margin -
|
||||
theme->button_size;
|
||||
b2off = b1off - theme->button_padding - theme->button_size;
|
||||
b3off = b2off - theme->button_padding - theme->button_size;
|
||||
|
||||
if (theme->pointer_y >= theme->button_margin &&
|
||||
theme->pointer_y < theme->control_height -
|
||||
theme->button_margin) {
|
||||
if (theme->pointer_x >= b1off &&
|
||||
theme->pointer_x < b1off + theme->button_size)
|
||||
return LOC_CLOSE;
|
||||
if (theme->pointer_x >= b2off &&
|
||||
theme->pointer_x < b2off + theme->button_size)
|
||||
return LOC_MAXIMIZE;
|
||||
if (theme->pointer_x >= b3off &&
|
||||
theme->pointer_x < b3off + theme->button_size)
|
||||
return LOC_MINIMIZE;
|
||||
}
|
||||
|
||||
return LOC_CONTROL;
|
||||
}
|
||||
|
||||
return LOC_SOMEWHERE;
|
||||
}
|
||||
|
||||
static void set_pointer_location(struct wlt_theme *theme, unsigned int loc)
|
||||
{
|
||||
if (theme->pointer_loc == loc)
|
||||
return;
|
||||
|
||||
theme->pointer_loc = loc;
|
||||
if (loc == LOC_NOWHERE) {
|
||||
theme->pointer_x = -1;
|
||||
theme->pointer_y = -1;
|
||||
}
|
||||
|
||||
wlt_window_schedule_redraw(theme->wnd);
|
||||
}
|
||||
|
||||
static void widget_pointer_motion(struct wlt_widget *widget,
|
||||
unsigned int x, unsigned int y, void *data)
|
||||
{
|
||||
struct wlt_theme *theme = data;
|
||||
|
||||
if (!wlt_rect_contains(&theme->alloc, x, y)) {
|
||||
set_pointer_location(theme, LOC_NOWHERE);
|
||||
return;
|
||||
} else {
|
||||
theme->pointer_x = x + theme->alloc.x;
|
||||
theme->pointer_y = y + theme->alloc.y;
|
||||
set_pointer_location(theme, get_pointer_location(theme));
|
||||
}
|
||||
|
||||
switch (theme->pointer_loc) {
|
||||
case LOC_RESIZE_LEFT:
|
||||
wlt_window_set_cursor(theme->wnd, WLT_CURSOR_LEFT);
|
||||
break;
|
||||
case LOC_RESIZE_RIGHT:
|
||||
wlt_window_set_cursor(theme->wnd, WLT_CURSOR_RIGHT);
|
||||
break;
|
||||
case LOC_RESIZE_TOP:
|
||||
wlt_window_set_cursor(theme->wnd, WLT_CURSOR_TOP);
|
||||
break;
|
||||
case LOC_RESIZE_BOTTOM:
|
||||
wlt_window_set_cursor(theme->wnd, WLT_CURSOR_BOTTOM);
|
||||
break;
|
||||
case LOC_RESIZE_TOP_LEFT:
|
||||
wlt_window_set_cursor(theme->wnd, WLT_CURSOR_TOP_LEFT);
|
||||
break;
|
||||
case LOC_RESIZE_TOP_RIGHT:
|
||||
wlt_window_set_cursor(theme->wnd, WLT_CURSOR_TOP_RIGHT);
|
||||
break;
|
||||
case LOC_RESIZE_BOTTOM_LEFT:
|
||||
wlt_window_set_cursor(theme->wnd,
|
||||
WLT_CURSOR_BOTTOM_LEFT);
|
||||
break;
|
||||
case LOC_RESIZE_BOTTOM_RIGHT:
|
||||
wlt_window_set_cursor(theme->wnd,
|
||||
WLT_CURSOR_BOTTOM_RIGHT);
|
||||
break;
|
||||
default:
|
||||
wlt_window_set_cursor(theme->wnd, WLT_CURSOR_LEFT_PTR);
|
||||
}
|
||||
}
|
||||
|
||||
static void widget_pointer_enter(struct wlt_widget *widget,
|
||||
unsigned int x, unsigned int y, void *data)
|
||||
{
|
||||
struct wlt_theme *theme = data;
|
||||
|
||||
widget_pointer_motion(widget, x, y, theme);
|
||||
}
|
||||
|
||||
static void widget_pointer_leave(struct wlt_widget *widget, void *data)
|
||||
{
|
||||
struct wlt_theme *theme = data;
|
||||
|
||||
if (theme->pointer_pressed) {
|
||||
theme->pointer_pressed = false;
|
||||
wlt_window_schedule_redraw(theme->wnd);
|
||||
}
|
||||
|
||||
set_pointer_location(theme, LOC_NOWHERE);
|
||||
}
|
||||
|
||||
static void button_action(struct wlt_theme *theme)
|
||||
{
|
||||
if (theme->pointer_grabbed != theme->pointer_loc)
|
||||
return;
|
||||
|
||||
switch (theme->pointer_loc) {
|
||||
case LOC_CLOSE:
|
||||
wlt_window_close(theme->wnd);
|
||||
break;
|
||||
case LOC_MAXIMIZE:
|
||||
break;
|
||||
case LOC_MINIMIZE:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void widget_pointer_button(struct wlt_widget *widget,
|
||||
uint32_t button, uint32_t state, void *data)
|
||||
{
|
||||
struct wlt_theme *theme = data;
|
||||
|
||||
if (button != BTN_LEFT)
|
||||
return;
|
||||
|
||||
if (state != WL_POINTER_BUTTON_STATE_PRESSED) {
|
||||
if (theme->pointer_pressed) {
|
||||
button_action(theme);
|
||||
theme->pointer_pressed = false;
|
||||
theme->pointer_grabbed = LOC_NOWHERE;
|
||||
wlt_window_schedule_redraw(theme->wnd);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (!theme->pointer_pressed) {
|
||||
theme->pointer_pressed = true;
|
||||
theme->pointer_grabbed = theme->pointer_loc;
|
||||
wlt_window_schedule_redraw(theme->wnd);
|
||||
}
|
||||
|
||||
switch (theme->pointer_loc) {
|
||||
case LOC_RESIZE_LEFT:
|
||||
wlt_window_resize(theme->wnd, WL_SHELL_SURFACE_RESIZE_LEFT);
|
||||
break;
|
||||
case LOC_RESIZE_RIGHT:
|
||||
wlt_window_resize(theme->wnd, WL_SHELL_SURFACE_RESIZE_RIGHT);
|
||||
break;
|
||||
case LOC_RESIZE_TOP:
|
||||
wlt_window_resize(theme->wnd,
|
||||
WL_SHELL_SURFACE_RESIZE_TOP);
|
||||
break;
|
||||
case LOC_RESIZE_BOTTOM:
|
||||
wlt_window_resize(theme->wnd,
|
||||
WL_SHELL_SURFACE_RESIZE_BOTTOM);
|
||||
break;
|
||||
case LOC_RESIZE_TOP_LEFT:
|
||||
wlt_window_resize(theme->wnd,
|
||||
WL_SHELL_SURFACE_RESIZE_TOP_LEFT);
|
||||
break;
|
||||
case LOC_RESIZE_TOP_RIGHT:
|
||||
wlt_window_resize(theme->wnd,
|
||||
WL_SHELL_SURFACE_RESIZE_TOP_RIGHT);
|
||||
break;
|
||||
case LOC_RESIZE_BOTTOM_LEFT:
|
||||
wlt_window_resize(theme->wnd,
|
||||
WL_SHELL_SURFACE_RESIZE_BOTTOM_LEFT);
|
||||
break;
|
||||
case LOC_RESIZE_BOTTOM_RIGHT:
|
||||
wlt_window_resize(theme->wnd,
|
||||
WL_SHELL_SURFACE_RESIZE_BOTTOM_RIGHT);
|
||||
break;
|
||||
case LOC_CONTROL:
|
||||
wlt_window_move(theme->wnd);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void widget_destroy(struct wlt_widget *widget, void *data)
|
||||
{
|
||||
struct wlt_theme *theme = data;
|
||||
|
||||
log_debug("destroy theme");
|
||||
|
||||
free(theme);
|
||||
}
|
||||
|
||||
int wlt_theme_new(struct wlt_theme **out, struct wlt_window *wnd)
|
||||
{
|
||||
struct wlt_theme *theme;
|
||||
int ret;
|
||||
|
||||
if (!out || !wnd)
|
||||
return -EINVAL;
|
||||
|
||||
log_debug("create new theme");
|
||||
|
||||
theme = malloc(sizeof(*theme));
|
||||
if (!theme)
|
||||
return -ENOMEM;
|
||||
memset(theme, 0, sizeof(*theme));
|
||||
theme->wnd = wnd;
|
||||
theme->control_height = 25;
|
||||
theme->frame_width = 5;
|
||||
theme->resize_margin = 5;
|
||||
theme->button_size = 15;
|
||||
theme->button_padding = 3;
|
||||
theme->button_margin = 5;
|
||||
theme->pointer_grabbed = LOC_NOWHERE;
|
||||
set_pointer_location(theme, LOC_NOWHERE);
|
||||
|
||||
ret = wlt_window_create_widget(wnd, &theme->widget, theme);
|
||||
if (ret) {
|
||||
log_error("cannot create widget");
|
||||
goto err_free;
|
||||
}
|
||||
|
||||
wlt_widget_set_destroy_cb(theme->widget, widget_destroy);
|
||||
wlt_widget_set_redraw_cb(theme->widget, widget_redraw);
|
||||
wlt_widget_set_resize_cb(theme->widget, widget_prepare_resize,
|
||||
widget_resize);
|
||||
wlt_widget_set_pointer_cb(theme->widget, widget_pointer_enter,
|
||||
widget_pointer_leave, widget_pointer_motion,
|
||||
widget_pointer_button);
|
||||
*out = theme;
|
||||
return 0;
|
||||
|
||||
err_free:
|
||||
free(theme);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void wlt_theme_destroy(struct wlt_theme *theme)
|
||||
{
|
||||
if (!theme)
|
||||
return;
|
||||
|
||||
wlt_widget_destroy(theme->widget);
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* wlt - Theme Helper
|
||||
*
|
||||
* Copyright (c) 2012 David Herrmann <dh.herrmann@googlemail.com>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files
|
||||
* (the "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Wayland Terminal theme/decoration drawing helper
|
||||
*/
|
||||
|
||||
#ifndef WLT_THEME_H
|
||||
#define WLT_THEME_H
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "wlt_toolkit.h"
|
||||
|
||||
struct wlt_theme;
|
||||
|
||||
int wlt_theme_new(struct wlt_theme **out, struct wlt_window *wnd);
|
||||
void wlt_theme_destroy(struct wlt_theme *theme);
|
||||
|
||||
#endif /* WLT_THEME_H */
|
||||
+1283
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,168 @@
|
||||
/*
|
||||
* wlt - Toolkit Helper
|
||||
*
|
||||
* Copyright (c) 2012 David Herrmann <dh.herrmann@googlemail.com>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files
|
||||
* (the "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Wayland Terminal toolkit helpers
|
||||
*/
|
||||
|
||||
#ifndef WLT_TOOLKIT_H
|
||||
#define WLT_TOOLKIT_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
#include "eloop.h"
|
||||
|
||||
struct wlt_display;
|
||||
struct wlt_window;
|
||||
struct wlt_widget;
|
||||
|
||||
enum wlt_display_event {
|
||||
WLT_DISPLAY_HUP,
|
||||
WLT_DISPLAY_READY,
|
||||
};
|
||||
|
||||
struct wlt_rect {
|
||||
unsigned int x;
|
||||
unsigned int y;
|
||||
unsigned int width;
|
||||
unsigned int height;
|
||||
};
|
||||
|
||||
struct wlt_shm_buffer {
|
||||
uint8_t *data;
|
||||
unsigned int width;
|
||||
unsigned int height;
|
||||
unsigned int stride;
|
||||
};
|
||||
|
||||
enum cursor_type {
|
||||
WLT_CURSOR_NONE,
|
||||
WLT_CURSOR_TOP,
|
||||
WLT_CURSOR_BOTTOM,
|
||||
WLT_CURSOR_LEFT,
|
||||
WLT_CURSOR_RIGHT,
|
||||
WLT_CURSOR_TOP_LEFT,
|
||||
WLT_CURSOR_TOP_RIGHT,
|
||||
WLT_CURSOR_BOTTOM_LEFT,
|
||||
WLT_CURSOR_BOTTOM_RIGHT,
|
||||
WLT_CURSOR_DRAGGING,
|
||||
WLT_CURSOR_LEFT_PTR,
|
||||
WLT_CURSOR_IBEAM,
|
||||
WLT_CURSOR_NUM,
|
||||
};
|
||||
|
||||
typedef void (*wlt_display_cb) (struct wlt_display *disp,
|
||||
unsigned int event,
|
||||
void *data);
|
||||
typedef void (*wlt_window_close_cb) (struct wlt_window *wnd, void *data);
|
||||
typedef void (*wlt_widget_redraw_cb) (struct wlt_widget *widget,
|
||||
void *data);
|
||||
typedef void (*wlt_widget_destroy_cb) (struct wlt_widget *widget,
|
||||
void *data);
|
||||
typedef void (*wlt_widget_prepare_resize_cb) (struct wlt_widget *widget,
|
||||
unsigned int *width,
|
||||
unsigned int *height,
|
||||
void *data);
|
||||
typedef void (*wlt_widget_resize_cb) (struct wlt_widget *widget,
|
||||
struct wlt_rect *allocation,
|
||||
void *data);
|
||||
typedef void (*wlt_widget_pointer_enter_cb) (struct wlt_widget *widget,
|
||||
unsigned int x,
|
||||
unsigned int y,
|
||||
void *data);
|
||||
typedef void (*wlt_widget_pointer_leave_cb) (struct wlt_widget *widget,
|
||||
void *data);
|
||||
typedef void (*wlt_widget_pointer_motion_cb) (struct wlt_widget *widget,
|
||||
unsigned int x,
|
||||
unsigned int y,
|
||||
void *data);
|
||||
typedef void (*wlt_widget_pointer_button_cb) (struct wlt_widget *widget,
|
||||
uint32_t button,
|
||||
uint32_t state,
|
||||
void *data);
|
||||
|
||||
int wlt_display_new(struct wlt_display **out,
|
||||
struct ev_eloop *eloop);
|
||||
void wlt_display_ref(struct wlt_display *disp);
|
||||
void wlt_display_unref(struct wlt_display *disp);
|
||||
|
||||
int wlt_display_create_window(struct wlt_display *disp,
|
||||
struct wlt_window **out,
|
||||
unsigned int width,
|
||||
unsigned int height,
|
||||
void *data);
|
||||
int wlt_display_register_cb(struct wlt_display *disp,
|
||||
wlt_display_cb cb, void *data);
|
||||
void wlt_display_unregister_cb(struct wlt_display *disp,
|
||||
wlt_display_cb cb, void *data);
|
||||
|
||||
void wlt_window_ref(struct wlt_window *wnd);
|
||||
void wlt_window_unref(struct wlt_window *wnd);
|
||||
|
||||
int wlt_window_create_widget(struct wlt_window *wnd,
|
||||
struct wlt_widget **out,
|
||||
void *data);
|
||||
void wlt_window_schedule_redraw(struct wlt_window *wnd);
|
||||
void wlt_window_damage(struct wlt_window *wnd,
|
||||
struct wlt_rect *damage);
|
||||
void wlt_window_get_buffer(struct wlt_window *wnd,
|
||||
const struct wlt_rect *alloc,
|
||||
struct wlt_shm_buffer *buf);
|
||||
void wlt_window_move(struct wlt_window *wnd);
|
||||
void wlt_window_resize(struct wlt_window *wnd, uint32_t edges);
|
||||
int wlt_window_set_size(struct wlt_window *wnd,
|
||||
unsigned int width, unsigned int height);
|
||||
void wlt_window_set_cursor(struct wlt_window *wnd, unsigned int cursor);
|
||||
void wlt_window_set_close_cb(struct wlt_window *wnd,
|
||||
wlt_window_close_cb cb);
|
||||
void wlt_window_close(struct wlt_window *wnd);
|
||||
|
||||
void wlt_widget_destroy(struct wlt_widget *widget);
|
||||
struct wlt_window *wlt_widget_get_window(struct wlt_widget *widget);
|
||||
void wlt_widget_set_redraw_cb(struct wlt_widget *widget,
|
||||
wlt_widget_redraw_cb cb);
|
||||
void wlt_widget_set_destroy_cb(struct wlt_widget *widget,
|
||||
wlt_widget_destroy_cb cb);
|
||||
void wlt_widget_set_resize_cb(struct wlt_widget *widget,
|
||||
wlt_widget_prepare_resize_cb prepare_cb,
|
||||
wlt_widget_resize_cb cb);
|
||||
void wlt_widget_set_pointer_cb(struct wlt_widget *widget,
|
||||
wlt_widget_pointer_enter_cb enter_cb,
|
||||
wlt_widget_pointer_leave_cb leave_cb,
|
||||
wlt_widget_pointer_motion_cb motion_cb,
|
||||
wlt_widget_pointer_button_cb button_cb);
|
||||
|
||||
static inline bool wlt_rect_contains(struct wlt_rect *rect,
|
||||
unsigned int x,
|
||||
unsigned int y)
|
||||
{
|
||||
if (x >= rect->x + rect->width)
|
||||
return false;
|
||||
if (y >= rect->y + rect->height)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif /* WLT_TOOLKIT_H */
|
||||
Reference in new issue
Block a user