Merge branch 'wlroots'

This commit is contained in:
Drew DeVault 2018-04-12 20:19:54 -04:00
commit cd1b32453a
281 changed files with 14867 additions and 21088 deletions

View File

@ -1,24 +1,29 @@
# vim: ft=yaml ts=2 sw=2 et :
image: archlinux
packages:
- cmake
- wlc-git
- meson
- xorg-server-xwayland
- xcb-util-image
- json-c
- pango
- cairo
- wayland
- wayland-protocols
- gdk-pixbuf2
- libinput
- libxkbcommon
sources:
- https://git.sr.ht/~sircmpwn/sway
- https://github.com/swaywm/sway
- https://github.com/swaywm/wlroots
tasks:
- wlroots: |
cd wlroots
meson --prefix=/usr build
ninja -C build
sudo ninja -C build install
- setup: |
cd sway
mkdir build
cd build
cmake ..
meson build
- build: |
cd sway
cd build
make
ninja -C build

6
.gitignore vendored
View File

@ -1,7 +1,3 @@
CMakeCache.txt
CMakeFiles
Makefile
cmake_install.cmake
install_manifest.txt
*.swp
*.o
@ -12,3 +8,5 @@ build/
.lvimrc
config-debug
wayland-*-protocol.*
/subprojects/wlroots
subprojects

View File

@ -1,31 +0,0 @@
sudo: required
language: c
compiler:
- gcc
- clang
env:
- BUILD_TYPE=Release
- BUILD_TYPE=Debug
- BUILD_TYPE=ASAN
arch:
packages:
- cmake
- xorg-server-xwayland
- json-c
- wayland
- xcb-util-image
- pango
- cairo
- gdk-pixbuf2
- wlc-git
- libcap
script:
- "cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE ."
- "make"
script:
- "curl -s https://raw.githubusercontent.com/mikkeloscar/arch-travis/master/arch-travis.sh | bash"

View File

@ -1,75 +0,0 @@
#
# (c)2015 KiCad Developers
# (c)2015 Brian Sidebotham <brian.sidebotham@gmail.com>
#
# CMake module to find a2x (part of the asciidoc toolchain).
#
# Variables generated:
#
# A2X_FOUND true when A2X_COMMAND is valid
# A2X_COMMAND The command to run a2x (may be a list including an interpreter)
# A2X_VERSION The a2x version that has been found
#
# Have a go at finding a a2x executable
find_program( A2X_PROGRAM a2x )
# Found something, attempt to try and use it...
if( A2X_PROGRAM )
execute_process(
COMMAND ${A2X_PROGRAM} --version
OUTPUT_VARIABLE _OUT
ERROR_VARIABLE _ERR
RESULT_VARIABLE _RES
OUTPUT_STRIP_TRAILING_WHITESPACE )
# If it worked, set the A2X_COMMAND
if( _RES MATCHES 0 )
set( A2X_COMMAND "${A2X_PROGRAM}" )
endif()
endif()
# If nothing could be found, test to see if we can just find the script file,
# that we'll then run with the python interpreter
if( NOT A2X_COMMAND )
find_file( A2X_SCRIPT a2x.py )
if( A2X_SCRIPT )
# Find the python interpreter quietly
if( NOT PYTHONINTERP_FOUND )
find_package( PYTHONINTERP QUIET )
endif()
if( NOT PYTHONINTERP_FOUND )
# Python's not available so can't find a2x...
set( A2X_COMMAND "" )
else()
# Build the python based command
set( A2X_COMMAND "${PYTHON_EXECUTABLE}" "${A2X_SCRIPT}" )
execute_process(
COMMAND ${A2X_COMMAND} --version
OUTPUT_VARIABLE _OUT
ERROR_VARIABLE _ERR
RESULT_VARIABLE _RES
OUTPUT_STRIP_TRAILING_WHITESPACE )
# If it still can't be run, then give up
if( NOT _RES MATCHES 0 )
set( A2X_COMMAND "" )
endif()
endif()
endif()
endif()
# If we've found a command that works, check the version
if( A2X_COMMAND )
string(REGEX REPLACE ".*a2x[^0-9.]*\([0-9.]+\).*" "\\1" A2X_VERSION "${_OUT}")
endif()
# Generate the *_FOUND as necessary, etc.
include( FindPackageHandleStandardArgs )
find_package_handle_standard_args(
A2X
REQUIRED_VARS A2X_COMMAND
VERSION_VAR A2X_VERSION )

View File

@ -1,42 +0,0 @@
# - Try to find the cairo library
# Once done this will define
#
# CAIRO_FOUND - system has cairo
# CAIRO_INCLUDE_DIRS - the cairo include directory
# CAIRO_LIBRARIES - Link these to use cairo
#
# Define CAIRO_MIN_VERSION for which version desired.
#
find_package(PkgConfig)
if(Cairo_FIND_REQUIRED)
set(_pkgconfig_REQUIRED "REQUIRED")
else(Cairo_FIND_REQUIRED)
set(_pkgconfig_REQUIRED "")
endif(Cairo_FIND_REQUIRED)
if(CAIRO_MIN_VERSION)
pkg_check_modules(CAIRO ${_pkgconfig_REQUIRED} cairo>=${CAIRO_MIN_VERSION})
else(CAIRO_MIN_VERSION)
pkg_check_modules(CAIRO ${_pkgconfig_REQUIRED} cairo)
endif(CAIRO_MIN_VERSION)
if(NOT CAIRO_FOUND AND NOT PKG_CONFIG_FOUND)
find_path(CAIRO_INCLUDE_DIRS cairo.h)
find_library(CAIRO_LIBRARIES cairo)
else(NOT CAIRO_FOUND AND NOT PKG_CONFIG_FOUND)
# Make paths absolute https://stackoverflow.com/a/35476270
# Important on FreeBSD because /usr/local/lib is not on /usr/bin/ld's default path
set(CAIRO_LIBS_ABSOLUTE)
foreach(lib ${CAIRO_LIBRARIES})
set(var_name CAIRO_${lib}_ABS)
find_library(${var_name} ${lib} ${CAIRO_LIBRARY_DIRS})
list(APPEND CAIRO_LIBS_ABSOLUTE ${${var_name}})
endforeach()
set(CAIRO_LIBRARIES ${CAIRO_LIBS_ABSOLUTE})
endif(NOT CAIRO_FOUND AND NOT PKG_CONFIG_FOUND)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(CAIRO DEFAULT_MSG CAIRO_LIBRARIES CAIRO_INCLUDE_DIRS)
mark_as_advanced(CAIRO_LIBRARIES CAIRO_INCLUDE_DIRS)

View File

@ -1,59 +0,0 @@
# - Try to find DBus
# Once done, this will define
#
# DBUS_FOUND - system has DBus
# DBUS_INCLUDE_DIRS - the DBus include directories
# DBUS_LIBRARIES - link these to use DBus
#
# Copyright (C) 2012 Raphael Kubo da Costa <rakuco@webkit.org>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND ITS CONTRIBUTORS ``AS
# IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR ITS
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
FIND_PACKAGE(PkgConfig)
PKG_CHECK_MODULES(PC_DBUS QUIET dbus-1)
FIND_LIBRARY(DBUS_LIBRARIES
NAMES dbus-1
HINTS ${PC_DBUS_LIBDIR}
${PC_DBUS_LIBRARY_DIRS}
)
FIND_PATH(DBUS_INCLUDE_DIR
NAMES dbus/dbus.h
HINTS ${PC_DBUS_INCLUDEDIR}
${PC_DBUS_INCLUDE_DIRS}
)
GET_FILENAME_COMPONENT(_DBUS_LIBRARY_DIR ${DBUS_LIBRARIES} PATH)
FIND_PATH(DBUS_ARCH_INCLUDE_DIR
NAMES dbus/dbus-arch-deps.h
HINTS ${PC_DBUS_INCLUDEDIR}
${PC_DBUS_INCLUDE_DIRS}
${_DBUS_LIBRARY_DIR}
${DBUS_INCLUDE_DIR}
PATH_SUFFIXES include
)
SET(DBUS_INCLUDE_DIRS ${DBUS_INCLUDE_DIR} ${DBUS_ARCH_INCLUDE_DIR})
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(DBUS REQUIRED_VARS DBUS_INCLUDE_DIRS DBUS_LIBRARIES)

View File

@ -1,17 +0,0 @@
# - Find EpollShim
# Once done, this will define
#
# EPOLLSHIM_FOUND - System has EpollShim
# EPOLLSHIM_INCLUDE_DIRS - The EpollShim include directories
# EPOLLSHIM_LIBRARIES - The libraries needed to use EpollShim
find_path(EPOLLSHIM_INCLUDE_DIRS NAMES sys/epoll.h sys/timerfd.h HINTS /usr/local/include/libepoll-shim)
find_library(EPOLLSHIM_LIBRARIES NAMES epoll-shim libepoll-shim HINTS /usr/local/lib)
if (EPOLLSHIM_INCLUDE_DIRS AND EPOLLSHIM_LIBRARIES)
set(EPOLLSHIM_FOUND TRUE)
endif (EPOLLSHIM_INCLUDE_DIRS AND EPOLLSHIM_LIBRARIES)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(EPOLLSHIM DEFAULT_MSG EPOLLSHIM_LIBRARIES EPOLLSHIM_INCLUDE_DIRS)
mark_as_advanced(EPOLLSHIM_INCLUDE_DIRS EPOLLSHIM_LIBRARIES)

View File

@ -1,43 +0,0 @@
# - Try to find the gdk-pixbuf-2.0 library
# Once done this will define
#
# GDK_PIXBUF_FOUND - system has gdk-pixbuf-2.0
# GDK_PIXBUF_INCLUDE_DIRS - the gdk-pixbuf-2.0 include directory
# GDK_PIXBUF_LIBRARIES - Link these to use gdk-pixbuf-2.0
#
# Define GDK_PIXBUF_MIN_VERSION for which version desired.
#
find_package(PkgConfig)
if(GdkPixbuf_FIND_REQUIRED)
set(_pkgconfig_REQUIRED "REQUIRED")
else(GdkPixbuf_FIND_REQUIRED)
set(_pkgconfig_REQUIRED "")
endif(GdkPixbuf_FIND_REQUIRED)
if(GDK_PIXBUF_MIN_VERSION)
pkg_check_modules(GDK_PIXBUF ${_pkgconfig_REQUIRED} "gdk-pixbuf-2.0>=${GDK_PIXBUF_MIN_VERSION}")
else(GDK_PIXBUF_MIN_VERSION)
pkg_check_modules(GDK_PIXBUF ${_pkgconfig_REQUIRED} "gdk-pixbuf-2.0")
endif(GDK_PIXBUF_MIN_VERSION)
if(NOT GDK_PIXBUF_FOUND AND NOT PKG_CONFIG_FOUND)
find_path(GDK_PIXBUF_INCLUDE_DIRS gdk-pixbuf/gdk-pixbuf.h)
find_library(GDK_PIXBUF_LIBRARIES gdk_pixbuf-2.0)
else(NOT GDK_PIXBUF_FOUND AND NOT PKG_CONFIG_FOUND)
SET(GdkPixbuf_FOUND 1)
# Make paths absolute https://stackoverflow.com/a/35476270
# Important on FreeBSD because /usr/local/lib is not on /usr/bin/ld's default path
set(GDK_PIXBUF_LIBS_ABSOLUTE)
foreach(lib ${GDK_PIXBUF_LIBRARIES})
set(var_name GDK_PIXBUF_${lib}_ABS)
find_library(${var_name} ${lib} ${GDK_PIXBUF_LIBRARY_DIRS})
list(APPEND GDK_PIXBUF_LIBS_ABSOLUTE ${${var_name}})
endforeach()
set(GDK_PIXBUF_LIBRARIES ${GDK_PIXBUF_LIBS_ABSOLUTE})
endif(NOT GDK_PIXBUF_FOUND AND NOT PKG_CONFIG_FOUND)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(GDK_PIXBUF DEFAULT_MSG GDK_PIXBUF_LIBRARIES GDK_PIXBUF_INCLUDE_DIRS)
mark_as_advanced(GDK_PIXBUF_LIBRARIES GDK_PIXBUF_INCLUDE_DIRS)

View File

@ -1,29 +0,0 @@
# - Find json-c
# Find the json-c libraries
#
# This module defines the following variables:
# JSONC_FOUND - True if JSONC is found
# JSONC_LIBRARIES - JSONC libraries
# JSONC_INCLUDE_DIRS - JSONC include directories
#
find_package(PkgConfig)
if (JsonC_FIND_REQUIRED)
set(_pkgconfig_REQUIRED "REQUIRED")
else()
set(_pkgconfig_REQUIRED "")
endif()
if(JsonC_FIND_VERSION)
pkg_check_modules(PC_JSONC ${_pkgconfig_REQUIRED} json-c=${JsonC_FIND_VERSION})
else()
pkg_check_modules(PC_JSONC ${_pkgconfig_REQUIRED} json-c)
endif()
find_path(JSONC_INCLUDE_DIRS NAMES json-c/json.h HINTS ${PC_JSONC_INCLUDE_DIRS})
find_library(JSONC_LIBRARIES NAMES json-c HINTS ${PC_JSONC_LIBRARY_DIRS})
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(JSONC DEFAULT_MSG JSONC_LIBRARIES JSONC_INCLUDE_DIRS)
mark_as_advanced(JSONC_LIBRARIES JSONC_INCLUDE_DIRS)

View File

@ -1,66 +0,0 @@
#.rst:
# FindLibInput
# -------
#
# Find LibInput library
#
# Try to find LibInpu library. The following values are defined
#
# ::
#
# LIBINPUT_FOUND - True if libinput is available
# LIBINPUT_INCLUDE_DIRS - Include directories for libinput
# LIBINPUT_LIBRARIES - List of libraries for libinput
# LIBINPUT_DEFINITIONS - List of definitions for libinput
#
# and also the following more fine grained variables
#
# ::
#
# LIBINPUT_VERSION
# LIBINPUT_VERSION_MAJOR
# LIBINPUT_VERSION_MINOR
# LIBINPUT_VERSION_MICRO
#
#=============================================================================
# Copyright (c) 2015 Jari Vetoniemi
#
# Distributed under the OSI-approved BSD License (the "License");
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
include(FeatureSummary)
set_package_properties(LibInput PROPERTIES
URL "http://freedesktop.org/wiki/Software/libinput/"
DESCRIPTION "Library to handle input devices")
find_package(PkgConfig)
pkg_check_modules(PC_INPUT QUIET libinput)
find_library(LIBINPUT_LIBRARIES NAMES input HINTS ${PC_INPUT_LIBRARY_DIRS})
find_path(LIBINPUT_INCLUDE_DIRS libinput.h HINTS ${PC_INPUT_INCLUDE_DIRS})
set(LIBINPUT_VERSION ${PC_INPUT_VERSION})
string(REPLACE "." ";" VERSION_LIST "${PC_INPUT_VERSION}")
LIST(LENGTH VERSION_LIST n)
if (n EQUAL 3)
list(GET VERSION_LIST 0 LIBINPUT_VERSION_MAJOR)
list(GET VERSION_LIST 1 LIBINPUT_VERSION_MINOR)
list(GET VERSION_LIST 2 LIBINPUT_VERSION_MICRO)
endif ()
# This is compatible with libinput-version.h that exists in upstream
# but isn't in distribution (probably forgotten)
set(LIBINPUT_DEFINITIONS ${PC_INPUT_CFLAGS_OTHER}
-DLIBINPUT_VERSION=\"${LIBINPUT_VERSION}\"
-DLIBINPUT_VERSION_MAJOR=${LIBINPUT_VERSION_MAJOR}
-DLIBINPUT_VERSION_MINOR=${LIBINPUT_VERSION_MINOR}
-DLIBINPUT_VERSION_MICRO=${LIBINPUT_VERSION_MICRO})
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(LIBINPUT DEFAULT_MSG LIBINPUT_INCLUDE_DIRS LIBINPUT_LIBRARIES)
mark_as_advanced(LIBINPUT_INCLUDE_DIRS LIBINPUT_LIBRARIES LIBINPUT_DEFINITIONS
LIBINPUT_VERSION LIBINPUT_VERSION_MAJOR LIBINPUT_VERSION_MICRO LIBINPUT_VERSION_MINOR)

View File

@ -1,56 +0,0 @@
#.rst:
# FindLibcap
# -------
#
# Find Libcap library
#
# Try to find Libcap library. The following values are defined
#
# ::
#
# Libcap_FOUND - True if Libcap is available
# Libcap_INCLUDE_DIRS - Include directories for Libcap
# Libcap_LIBRARIES - List of libraries for Libcap
# Libcap_DEFINITIONS - List of definitions for Libcap
#
# and also the following more fine grained variables
#
# ::
#
# Libcap_VERSION
# Libcap_VERSION_MAJOR
# Libcap_VERSION_MINOR
#
#=============================================================================
# Copyright (c) 2017 Jerzi Kaminsky
#
# Distributed under the OSI-approved BSD License (the "License");
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
include(FeatureSummary)
set_package_properties(Libcap PROPERTIES
URL "https://www.kernel.org/pub/linux/libs/security/linux-privs/libcap2"
DESCRIPTION "Library for getting and setting POSIX.1e capabilities")
find_package(PkgConfig)
pkg_check_modules(PC_CAP QUIET Libcap)
find_library(Libcap_LIBRARIES NAMES cap HINTS ${PC_CAP_LIBRARY_DIRS})
find_path(Libcap_INCLUDE_DIRS sys/capability.h HINTS ${PC_CAP_INCLUDE_DIRS})
set(Libcap_VERSION ${PC_CAP_VERSION})
string(REPLACE "." ";" VERSION_LIST "${PC_CAP_VERSION}")
LIST(LENGTH VERSION_LIST n)
if (n EQUAL 2)
list(GET VERSION_LIST 0 Libcap_VERSION_MAJOR)
list(GET VERSION_LIST 1 Libcap_VERSION_MINOR)
endif ()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Libcap DEFAULT_MSG Libcap_INCLUDE_DIRS Libcap_LIBRARIES)
mark_as_advanced(Libcap_INCLUDE_DIRS Libcap_LIBRARIES Libcap_DEFINITIONS
Libcap_VERSION Libcap_VERSION_MAJOR Libcap_VERSION_MICRO Libcap_VERSION_MINOR)

View File

@ -1,245 +0,0 @@
# - Try to find the PAM libraries
# Once done this will define
#
# PAM_FOUND - system has pam
# PAM_INCLUDE_DIR - the pam include directory
# PAM_LIBRARIES - libpam library
if (PAM_INCLUDE_DIR AND PAM_LIBRARY)
set(PAM_FIND_QUIETLY TRUE)
endif (PAM_INCLUDE_DIR AND PAM_LIBRARY)
find_path(PAM_INCLUDE_DIR NAMES security/pam_appl.h pam/pam_appl.h)
find_library(PAM_LIBRARY pam)
find_library(DL_LIBRARY dl)
if (PAM_INCLUDE_DIR AND PAM_LIBRARY)
set(PAM_FOUND TRUE)
if (DL_LIBRARY)
set(PAM_LIBRARIES ${PAM_LIBRARY} ${DL_LIBRARY})
else (DL_LIBRARY)
set(PAM_LIBRARIES ${PAM_LIBRARY})
endif (DL_LIBRARY)
if (EXISTS ${PAM_INCLUDE_DIR}/pam/pam_appl.h)
set(HAVE_PAM_PAM_APPL_H 1)
endif (EXISTS ${PAM_INCLUDE_DIR}/pam/pam_appl.h)
endif (PAM_INCLUDE_DIR AND PAM_LIBRARY)
if (PAM_FOUND)
if (NOT PAM_FIND_QUIETLY)
message(STATUS "Found PAM: ${PAM_LIBRARIES}")
endif (NOT PAM_FIND_QUIETLY)
else (PAM_FOUND)
if (PAM_FIND_REQUIRED)
message(FATAL_ERROR "PAM was not found")
endif(PAM_FIND_REQUIRED)
endif (PAM_FOUND)
mark_as_advanced(PAM_INCLUDE_DIR PAM_LIBRARY DL_LIBRARY)
# This file taken from https://github.com/FreeRDP/FreeRDP
#
#
#
# Apache License
# Version 2.0, January 2004
# http://www.apache.org/licenses/
#
# TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
#
# 1. Definitions.
#
# "License" shall mean the terms and conditions for use, reproduction,
# and distribution as defined by Sections 1 through 9 of this document.
#
# "Licensor" shall mean the copyright owner or entity authorized by
# the copyright owner that is granting the License.
#
# "Legal Entity" shall mean the union of the acting entity and all
# other entities that control, are controlled by, or are under common
# control with that entity. For the purposes of this definition,
# "control" means (i) the power, direct or indirect, to cause the
# direction or management of such entity, whether by contract or
# otherwise, or (ii) ownership of fifty percent (50%) or more of the
# outstanding shares, or (iii) beneficial ownership of such entity.
#
# "You" (or "Your") shall mean an individual or Legal Entity
# exercising permissions granted by this License.
#
# "Source" form shall mean the preferred form for making modifications,
# including but not limited to software source code, documentation
# source, and configuration files.
#
# "Object" form shall mean any form resulting from mechanical
# transformation or translation of a Source form, including but
# not limited to compiled object code, generated documentation,
# and conversions to other media types.
#
# "Work" shall mean the work of authorship, whether in Source or
# Object form, made available under the License, as indicated by a
# copyright notice that is included in or attached to the work
# (an example is provided in the Appendix below).
#
# "Derivative Works" shall mean any work, whether in Source or Object
# form, that is based on (or derived from) the Work and for which the
# editorial revisions, annotations, elaborations, or other modifications
# represent, as a whole, an original work of authorship. For the purposes
# of this License, Derivative Works shall not include works that remain
# separable from, or merely link (or bind by name) to the interfaces of,
# the Work and Derivative Works thereof.
#
# "Contribution" shall mean any work of authorship, including
# the original version of the Work and any modifications or additions
# to that Work or Derivative Works thereof, that is intentionally
# submitted to Licensor for inclusion in the Work by the copyright owner
# or by an individual or Legal Entity authorized to submit on behalf of
# the copyright owner. For the purposes of this definition, "submitted"
# means any form of electronic, verbal, or written communication sent
# to the Licensor or its representatives, including but not limited to
# communication on electronic mailing lists, source code control systems,
# and issue tracking systems that are managed by, or on behalf of, the
# Licensor for the purpose of discussing and improving the Work, but
# excluding communication that is conspicuously marked or otherwise
# designated in writing by the copyright owner as "Not a Contribution."
#
# "Contributor" shall mean Licensor and any individual or Legal Entity
# on behalf of whom a Contribution has been received by Licensor and
# subsequently incorporated within the Work.
#
# 2. Grant of Copyright License. Subject to the terms and conditions of
# this License, each Contributor hereby grants to You a perpetual,
# worldwide, non-exclusive, no-charge, royalty-free, irrevocable
# copyright license to reproduce, prepare Derivative Works of,
# publicly display, publicly perform, sublicense, and distribute the
# Work and such Derivative Works in Source or Object form.
#
# 3. Grant of Patent License. Subject to the terms and conditions of
# this License, each Contributor hereby grants to You a perpetual,
# worldwide, non-exclusive, no-charge, royalty-free, irrevocable
# (except as stated in this section) patent license to make, have made,
# use, offer to sell, sell, import, and otherwise transfer the Work,
# where such license applies only to those patent claims licensable
# by such Contributor that are necessarily infringed by their
# Contribution(s) alone or by combination of their Contribution(s)
# with the Work to which such Contribution(s) was submitted. If You
# institute patent litigation against any entity (including a
# cross-claim or counterclaim in a lawsuit) alleging that the Work
# or a Contribution incorporated within the Work constitutes direct
# or contributory patent infringement, then any patent licenses
# granted to You under this License for that Work shall terminate
# as of the date such litigation is filed.
#
# 4. Redistribution. You may reproduce and distribute copies of the
# Work or Derivative Works thereof in any medium, with or without
# modifications, and in Source or Object form, provided that You
# meet the following conditions:
#
# (a) You must give any other recipients of the Work or
# Derivative Works a copy of this License; and
#
# (b) You must cause any modified files to carry prominent notices
# stating that You changed the files; and
#
# (c) You must retain, in the Source form of any Derivative Works
# that You distribute, all copyright, patent, trademark, and
# attribution notices from the Source form of the Work,
# excluding those notices that do not pertain to any part of
# the Derivative Works; and
#
# (d) If the Work includes a "NOTICE" text file as part of its
# distribution, then any Derivative Works that You distribute must
# include a readable copy of the attribution notices contained
# within such NOTICE file, excluding those notices that do not
# pertain to any part of the Derivative Works, in at least one
# of the following places: within a NOTICE text file distributed
# as part of the Derivative Works; within the Source form or
# documentation, if provided along with the Derivative Works; or,
# within a display generated by the Derivative Works, if and
# wherever such third-party notices normally appear. The contents
# of the NOTICE file are for informational purposes only and
# do not modify the License. You may add Your own attribution
# notices within Derivative Works that You distribute, alongside
# or as an addendum to the NOTICE text from the Work, provided
# that such additional attribution notices cannot be construed
# as modifying the License.
#
# You may add Your own copyright statement to Your modifications and
# may provide additional or different license terms and conditions
# for use, reproduction, or distribution of Your modifications, or
# for any such Derivative Works as a whole, provided Your use,
# reproduction, and distribution of the Work otherwise complies with
# the conditions stated in this License.
#
# 5. Submission of Contributions. Unless You explicitly state otherwise,
# any Contribution intentionally submitted for inclusion in the Work
# by You to the Licensor shall be under the terms and conditions of
# this License, without any additional terms or conditions.
# Notwithstanding the above, nothing herein shall supersede or modify
# the terms of any separate license agreement you may have executed
# with Licensor regarding such Contributions.
#
# 6. Trademarks. This License does not grant permission to use the trade
# names, trademarks, service marks, or product names of the Licensor,
# except as required for reasonable and customary use in describing the
# origin of the Work and reproducing the content of the NOTICE file.
#
# 7. Disclaimer of Warranty. Unless required by applicable law or
# agreed to in writing, Licensor provides the Work (and each
# Contributor provides its Contributions) on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied, including, without limitation, any warranties or conditions
# of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
# PARTICULAR PURPOSE. You are solely responsible for determining the
# appropriateness of using or redistributing the Work and assume any
# risks associated with Your exercise of permissions under this License.
#
# 8. Limitation of Liability. In no event and under no legal theory,
# whether in tort (including negligence), contract, or otherwise,
# unless required by applicable law (such as deliberate and grossly
# negligent acts) or agreed to in writing, shall any Contributor be
# liable to You for damages, including any direct, indirect, special,
# incidental, or consequential damages of any character arising as a
# result of this License or out of the use or inability to use the
# Work (including but not limited to damages for loss of goodwill,
# work stoppage, computer failure or malfunction, or any and all
# other commercial damages or losses), even if such Contributor
# has been advised of the possibility of such damages.
#
# 9. Accepting Warranty or Additional Liability. While redistributing
# the Work or Derivative Works thereof, You may choose to offer,
# and charge a fee for, acceptance of support, warranty, indemnity,
# or other liability obligations and/or rights consistent with this
# License. However, in accepting such obligations, You may act only
# on Your own behalf and on Your sole responsibility, not on behalf
# of any other Contributor, and only if You agree to indemnify,
# defend, and hold each Contributor harmless for any liability
# incurred by, or claims asserted against, such Contributor by reason
# of your accepting any such warranty or additional liability.
#
# END OF TERMS AND CONDITIONS
#
# APPENDIX: How to apply the Apache License to your work.
#
# To apply the Apache License to your work, attach the following
# boilerplate notice, with the fields enclosed by brackets "[]"
# replaced with your own identifying information. (Don't include
# the brackets!) The text should be enclosed in the appropriate
# comment syntax for the file format. We also recommend that a
# file or class name and description of purpose be included on the
# same "printed page" as the copyright notice for easier
# identification within third-party archives.
#
# Copyright [yyyy] [name of copyright owner]
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

View File

@ -1,37 +0,0 @@
# Copyright (C) 2007-2009 LuaDist.
# Created by Peter Kapec <kapecp@gmail.com>
# Redistribution and use of this file is allowed according to the terms of the MIT license.
# For details see the COPYRIGHT file distributed with LuaDist.
# Note:
# Searching headers and libraries is very simple and is NOT as powerful as scripts
# distributed with CMake, because LuaDist defines directories to search for.
# Everyone is encouraged to contact the author with improvements. Maybe this file
# becomes part of CMake distribution sometimes.
# - Find pcre
# Find the native PCRE headers and libraries.
#
# PCRE_INCLUDE_DIRS - where to find pcre.h, etc.
# PCRE_LIBRARIES - List of libraries when using pcre.
# PCRE_FOUND - True if pcre found.
# Look for the header file.
FIND_PATH(PCRE_INCLUDE_DIR NAMES pcre.h)
# Look for the library.
FIND_LIBRARY(PCRE_LIBRARY NAMES pcre)
# Handle the QUIETLY and REQUIRED arguments and set PCRE_FOUND to TRUE if all listed variables are TRUE.
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(PCRE DEFAULT_MSG PCRE_LIBRARY PCRE_INCLUDE_DIR)
# Copy the results to the output variables.
IF(PCRE_FOUND)
SET(PCRE_LIBRARIES ${PCRE_LIBRARY})
SET(PCRE_INCLUDE_DIRS ${PCRE_INCLUDE_DIR})
ELSE(PCRE_FOUND)
SET(PCRE_LIBRARIES)
SET(PCRE_INCLUDE_DIRS)
ENDIF(PCRE_FOUND)
MARK_AS_ADVANCED(PCRE_INCLUDE_DIRS PCRE_LIBRARIES)

View File

@ -1,42 +0,0 @@
# - Try to find the pango library
# Once done this will define
#
# PANGO_FOUND - system has pango
# PANGO_INCLUDE_DIRS - the pango include directory
# PANGO_LIBRARIES - Link these to use pango
#
# Define PANGO_MIN_VERSION for which version desired.
#
find_package(PkgConfig)
if(Pango_FIND_REQUIRED)
set(_pkgconfig_REQUIRED "REQUIRED")
else(Pango_FIND_REQUIRED)
set(_pkgconfig_REQUIRED "")
endif(Pango_FIND_REQUIRED)
if(PANGO_MIN_VERSION)
pkg_check_modules(PANGO ${_pkgconfig_REQUIRED} "pango>=${PANGO_MIN_VERSION}" "pangocairo>=${PANGO_MIN_VERSION}")
else(PANGO_MIN_VERSION)
pkg_check_modules(PANGO ${_pkgconfig_REQUIRED} pango pangocairo)
endif(PANGO_MIN_VERSION)
if(NOT PANGO_FOUND AND NOT PKG_CONFIG_FOUND)
find_path(PANGO_INCLUDE_DIRS pango.h)
find_library(PANGO_LIBRARIES pango pangocairo)
else(NOT PANGO_FOUND AND NOT PKG_CONFIG_FOUND)
# Make paths absolute https://stackoverflow.com/a/35476270
# Important on FreeBSD because /usr/local/lib is not on /usr/bin/ld's default path
set(PANGO_LIBS_ABSOLUTE)
foreach(lib ${PANGO_LIBRARIES})
set(var_name PANGO_${lib}_ABS)
find_library(${var_name} ${lib} ${PANGO_LIBRARY_DIRS})
list(APPEND PANGO_LIBS_ABSOLUTE ${${var_name}})
endforeach()
set(PANGO_LIBRARIES ${PANGO_LIBS_ABSOLUTE})
endif(NOT PANGO_FOUND AND NOT PKG_CONFIG_FOUND)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(PANGO DEFAULT_MSG PANGO_LIBRARIES PANGO_INCLUDE_DIRS)
mark_as_advanced(PANGO_LIBRARIES PANGO_INCLUDE_DIRS)

View File

@ -1,20 +0,0 @@
# - Find wlc
# Find the wlc libraries
#
# This module defines the following variables:
# WLC_FOUND - True if wlc is found
# WLC_LIBRARIES - wlc libraries
# WLC_INCLUDE_DIRS - wlc include directories
# WLC_DEFINITIONS - Compiler switches required for using wlc
#
find_package(PkgConfig)
pkg_check_modules(PC_WLC QUIET wlc)
find_path(WLC_INCLUDE_DIRS NAMES wlc/wlc.h HINTS ${PC_WLC_INCLUDE_DIRS})
find_library(WLC_LIBRARIES NAMES wlc HINTS ${PC_WLC_LIBRARY_DIRS})
set(WLC_DEFINITIONS ${PC_WLC_CFLAGS_OTHER})
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(wlc DEFAULT_MSG WLC_LIBRARIES WLC_INCLUDE_DIRS)
mark_as_advanced(WLC_LIBRARIES WLC_INCLUDE_DIRS)

View File

@ -1,67 +0,0 @@
# Try to find Wayland on a Unix system
#
# This will define:
#
# WAYLAND_FOUND - True if Wayland is found
# WAYLAND_LIBRARIES - Link these to use Wayland
# WAYLAND_INCLUDE_DIR - Include directory for Wayland
# WAYLAND_DEFINITIONS - Compiler flags for using Wayland
#
# In addition the following more fine grained variables will be defined:
#
# WAYLAND_CLIENT_FOUND WAYLAND_CLIENT_INCLUDE_DIR WAYLAND_CLIENT_LIBRARIES
# WAYLAND_SERVER_FOUND WAYLAND_SERVER_INCLUDE_DIR WAYLAND_SERVER_LIBRARIES
# WAYLAND_EGL_FOUND WAYLAND_EGL_INCLUDE_DIR WAYLAND_EGL_LIBRARIES
# WAYLAND_CURSOR_FOUND WAYLAND_CURSOR_INCLUDE_DIR WAYLAND_CURSOR_LIBRARIES
#
# Copyright (c) 2013 Martin Gräßlin <mgraesslin@kde.org>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
IF (NOT WIN32)
IF (WAYLAND_INCLUDE_DIR AND WAYLAND_LIBRARIES)
# In the cache already
SET(WAYLAND_FIND_QUIETLY TRUE)
ENDIF ()
# Use pkg-config to get the directories and then use these values
# in the FIND_PATH() and FIND_LIBRARY() calls
FIND_PACKAGE(PkgConfig)
PKG_CHECK_MODULES(PKG_WAYLAND QUIET wayland-client wayland-server wayland-egl wayland-cursor)
SET(WAYLAND_DEFINITIONS ${PKG_WAYLAND_CFLAGS})
FIND_PATH(WAYLAND_CLIENT_INCLUDE_DIR NAMES wayland-client.h HINTS ${PKG_WAYLAND_INCLUDE_DIRS})
FIND_PATH(WAYLAND_SERVER_INCLUDE_DIR NAMES wayland-server.h HINTS ${PKG_WAYLAND_INCLUDE_DIRS})
FIND_PATH(WAYLAND_EGL_INCLUDE_DIR NAMES wayland-egl.h HINTS ${PKG_WAYLAND_INCLUDE_DIRS})
FIND_PATH(WAYLAND_CURSOR_INCLUDE_DIR NAMES wayland-cursor.h HINTS ${PKG_WAYLAND_INCLUDE_DIRS})
FIND_LIBRARY(WAYLAND_CLIENT_LIBRARIES NAMES wayland-client HINTS ${PKG_WAYLAND_LIBRARY_DIRS})
FIND_LIBRARY(WAYLAND_SERVER_LIBRARIES NAMES wayland-server HINTS ${PKG_WAYLAND_LIBRARY_DIRS})
FIND_LIBRARY(WAYLAND_EGL_LIBRARIES NAMES wayland-egl HINTS ${PKG_WAYLAND_LIBRARY_DIRS})
FIND_LIBRARY(WAYLAND_CURSOR_LIBRARIES NAMES wayland-cursor HINTS ${PKG_WAYLAND_LIBRARY_DIRS})
set(WAYLAND_INCLUDE_DIR ${WAYLAND_CLIENT_INCLUDE_DIR} ${WAYLAND_SERVER_INCLUDE_DIR} ${WAYLAND_EGL_INCLUDE_DIR} ${WAYLAND_CURSOR_INCLUDE_DIR})
set(WAYLAND_LIBRARIES ${WAYLAND_CLIENT_LIBRARIES} ${WAYLAND_SERVER_LIBRARIES} ${WAYLAND_EGL_LIBRARIES} ${WAYLAND_CURSOR_LIBRARIES})
list(REMOVE_DUPLICATES WAYLAND_INCLUDE_DIR)
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(WAYLAND_CLIENT DEFAULT_MSG WAYLAND_CLIENT_LIBRARIES WAYLAND_CLIENT_INCLUDE_DIR)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(WAYLAND_SERVER DEFAULT_MSG WAYLAND_SERVER_LIBRARIES WAYLAND_SERVER_INCLUDE_DIR)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(WAYLAND_EGL DEFAULT_MSG WAYLAND_EGL_LIBRARIES WAYLAND_EGL_INCLUDE_DIR)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(WAYLAND_CURSOR DEFAULT_MSG WAYLAND_CURSOR_LIBRARIES WAYLAND_CURSOR_INCLUDE_DIR)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(WAYLAND DEFAULT_MSG WAYLAND_LIBRARIES WAYLAND_INCLUDE_DIR)
MARK_AS_ADVANCED(
WAYLAND_INCLUDE_DIR WAYLAND_LIBRARIES
WAYLAND_CLIENT_INCLUDE_DIR WAYLAND_CLIENT_LIBRARIES
WAYLAND_SERVER_INCLUDE_DIR WAYLAND_SERVER_LIBRARIES
WAYLAND_EGL_INCLUDE_DIR WAYLAND_EGL_LIBRARIES
WAYLAND_CURSOR_INCLUDE_DIR WAYLAND_CURSOR_LIBRARIES
)
ENDIF ()

View File

@ -1,19 +0,0 @@
# - Find XKBCommon
# Once done, this will define
#
# XKBCOMMON_FOUND - System has XKBCommon
# XKBCOMMON_INCLUDE_DIRS - The XKBCommon include directories
# XKBCOMMON_LIBRARIES - The libraries needed to use XKBCommon
# XKBCOMMON_DEFINITIONS - Compiler switches required for using XKBCommon
find_package(PkgConfig)
pkg_check_modules(PC_XKBCOMMON QUIET xkbcommon)
find_path(XKBCOMMON_INCLUDE_DIRS NAMES xkbcommon/xkbcommon.h HINTS ${PC_XKBCOMMON_INCLUDE_DIRS})
find_library(XKBCOMMON_LIBRARIES NAMES xkbcommon HINTS ${PC_XKBCOMMON_LIBRARY_DIRS})
set(XKBCOMMON_DEFINITIONS ${PC_XKBCOMMON_CFLAGS_OTHER})
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(XKBCOMMON DEFAULT_MSG XKBCOMMON_LIBRARIES XKBCOMMON_INCLUDE_DIRS)
mark_as_advanced(XKBCOMMON_LIBRARIES XKBCOMMON_INCLUDE_DIRS)

View File

@ -1,33 +0,0 @@
find_package(A2X)
if (A2X_FOUND)
add_custom_target(man ALL)
function(add_manpage name section)
add_custom_command(
OUTPUT ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${name}.${section}
COMMAND ${A2X_COMMAND}
--no-xmllint
--doctype manpage
--format manpage
-D ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
${CMAKE_CURRENT_SOURCE_DIR}/${name}.${section}.txt
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${name}.${section}.txt
COMMENT Generating manpage for ${name}.${section}
)
add_custom_target(man-${name}.${section}
DEPENDS
${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${name}.${section}
)
add_dependencies(man
man-${name}.${section}
)
install(
FILES ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${name}.${section}
DESTINATION ${CMAKE_INSTALL_FULL_MANDIR}/man${section}
COMPONENT documentation
)
endfunction()
endif()

View File

@ -1,77 +0,0 @@
#=============================================================================
# Copyright (C) 2012-2013 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# * Neither the name of Pier Luigi Fiorini nor the names of his
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#=============================================================================
find_program(WAYLAND_SCANNER_EXECUTABLE NAMES wayland-scanner)
# wayland_add_protocol_client(outfiles inputfile basename)
function(WAYLAND_ADD_PROTOCOL_CLIENT _sources _protocol _basename)
if(NOT WAYLAND_SCANNER_EXECUTABLE)
message(FATAL "The wayland-scanner executable has not been found on your system. You must install it.")
endif()
get_filename_component(_infile ${_protocol} ABSOLUTE)
set(_client_header "${CMAKE_CURRENT_BINARY_DIR}/wayland-${_basename}-client-protocol.h")
set(_code "${CMAKE_CURRENT_BINARY_DIR}/wayland-${_basename}-client-protocol.c")
add_custom_command(OUTPUT "${_client_header}"
COMMAND ${WAYLAND_SCANNER_EXECUTABLE} client-header < ${_infile} > ${_client_header}
DEPENDS ${_infile} VERBATIM)
add_custom_command(OUTPUT "${_code}"
COMMAND ${WAYLAND_SCANNER_EXECUTABLE} code < ${_infile} > ${_code}
DEPENDS ${_infile} VERBATIM)
list(APPEND ${_sources} "${_client_header}" "${_code}")
set(${_sources} ${${_sources}} PARENT_SCOPE)
endfunction()
# wayland_add_protocol_server(outfiles inputfile basename)
function(WAYLAND_ADD_PROTOCOL_SERVER _sources _protocol _basename)
if(NOT WAYLAND_SCANNER_EXECUTABLE)
message(FATAL "The wayland-scanner executable has not been found on your system. You must install it.")
endif()
get_filename_component(_infile ${_protocol} ABSOLUTE)
set(_server_header "${CMAKE_CURRENT_BINARY_DIR}/wayland-${_basename}-server-protocol.h")
set(_code "${CMAKE_CURRENT_BINARY_DIR}/wayland-${_basename}-server-protocol.c")
add_custom_command(OUTPUT "${_server_header}"
COMMAND ${WAYLAND_SCANNER_EXECUTABLE} server-header < ${_infile} > ${_server_header}
DEPENDS ${_infile} VERBATIM)
add_custom_command(OUTPUT "${_code}"
COMMAND ${WAYLAND_SCANNER_EXECUTABLE} code < ${_infile} > ${_code}
DEPENDS ${_infile} VERBATIM)
list(APPEND ${_sources} "${_server_header}" "${_code}")
set(${_sources} ${${_sources}} PARENT_SCOPE)
endfunction()

View File

@ -1,161 +0,0 @@
cmake_minimum_required(VERSION 3.1.0)
project(sway C)
add_compile_options(-g)
set(CMAKE_C_STANDARD 99)
set(CMAKE_C_EXTENSIONS OFF)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin)
add_compile_options(-Wall -Wextra -Wno-unused-parameter -Wno-unused-result -Werror)
# Add Address Sanitiezed build type
set(CMAKE_C_FLAGS_ASAN
"${CMAKE_C_FLAGS_DEBUG} -fsanitize=address -fno-omit-frame-pointer"
CACHE STRING "Flags used by the C compiler during address sanitizer builds."
FORCE )
mark_as_advanced(
CMAKE_C_FLAGS_ASAN
CMAKE_EXE_LINKER_FLAGS_DEBUG
CMAKE_SHARED_LINKER_FLAGS_DEBUG
)
list(INSERT CMAKE_MODULE_PATH 0
${CMAKE_CURRENT_SOURCE_DIR}/CMake
)
if (VERSION)
add_definitions(-DSWAY_VERSION=\"${VERSION}\")
else()
execute_process(
COMMAND git describe --always --tags
OUTPUT_VARIABLE GIT_COMMIT_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
execute_process(
COMMAND git rev-parse --abbrev-ref HEAD
OUTPUT_VARIABLE GIT_BRANCH
OUTPUT_STRIP_TRAILING_WHITESPACE
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
string(TIMESTAMP CURRENT_DATE "%Y-%m-%d" UTC)
add_definitions("-DSWAY_VERSION=\"${GIT_COMMIT_HASH} (${CURRENT_DATE}, branch \\\"${GIT_BRANCH}\\\")\"")
endif()
option(enable-swaylock "Enables the swaylock utility" YES)
option(enable-swaybg "Enables the wallpaper utility" YES)
option(enable-swaybar "Enables the swaybar utility" YES)
option(enable-swaygrab "Enables the swaygrab utility" YES)
option(enable-swaymsg "Enables the swaymsg utility" YES)
option(enable-gdk-pixbuf "Use Pixbuf to support more image formats" YES)
option(enable-tray "Enables the swaybar tray" YES)
option(zsh-completions "Zsh shell completions" NO)
option(default-wallpaper "Installs the default wallpaper" YES)
option(LD_LIBRARY_PATH "Configure sway's default LD_LIBRARY_PATH")
if (LD_LIBRARY_PATH)
add_definitions(-D_LD_LIBRARY_PATH="${LD_LIBRARY_PATH}")
endif()
find_package(JsonC 0.12.1 REQUIRED)
find_package(PCRE REQUIRED)
find_package(WLC REQUIRED)
find_package(Wayland REQUIRED)
find_package(XKBCommon REQUIRED)
find_package(Cairo REQUIRED)
find_package(Pango REQUIRED)
find_package(GdkPixbuf)
find_package(PAM)
find_package(DBus 1.10)
find_package(LibInput REQUIRED)
if (CMAKE_SYSTEM_NAME STREQUAL Linux)
find_package(Libcap REQUIRED)
endif (CMAKE_SYSTEM_NAME STREQUAL Linux)
if (CMAKE_SYSTEM_NAME STREQUAL FreeBSD)
find_package(EpollShim REQUIRED)
endif (CMAKE_SYSTEM_NAME STREQUAL FreeBSD)
include(FeatureSummary)
include(Manpage)
include(GNUInstallDirs)
if (enable-gdk-pixbuf)
if (GDK_PIXBUF_FOUND)
set(WITH_GDK_PIXBUF YES)
add_definitions(-DWITH_GDK_PIXBUF)
else()
message(WARNING "gdk-pixbuf required but not found, only png images supported.")
endif()
else()
message(STATUS "Building without gdk-pixbuf, only png images supported.")
endif()
if (enable-tray)
if (DBUS_FOUND)
set(ENABLE_TRAY TRUE)
add_definitions(-DENABLE_TRAY)
else()
message(WARNING "Tray required but DBus was not found. Tray will not be included")
endif()
else()
message(STATUS "Building without the tray.")
endif()
include_directories(include)
add_subdirectory(protocols)
add_subdirectory(common)
add_subdirectory(wayland)
add_subdirectory(sway)
if(enable-swaybg)
if(CAIRO_FOUND AND PANGO_FOUND)
add_subdirectory(swaybg)
else()
message(WARNING "Not building swaybg - cairo, and pango are required.")
endif()
endif()
if(enable-swaymsg)
add_subdirectory(swaymsg)
endif()
if(enable-swaygrab)
add_subdirectory(swaygrab)
endif()
if(enable-swaybar)
if(CAIRO_FOUND AND PANGO_FOUND)
add_subdirectory(swaybar)
else()
message(WARNING "Not building swaybar - cairo, and pango are required.")
endif()
endif()
if(enable-swaylock)
if(CAIRO_FOUND AND PANGO_FOUND AND PAM_FOUND)
add_subdirectory(swaylock)
else()
message(WARNING "Not building swaylock - cairo, pango, and PAM are required.")
endif()
endif()
if(zsh-completions)
add_subdirectory(completions/zsh)
endif()
install(
FILES ${CMAKE_CURRENT_SOURCE_DIR}/sway.desktop
DESTINATION ${CMAKE_INSTALL_FULL_DATAROOTDIR}/wayland-sessions
COMPONENT data
)
if(default-wallpaper)
install(
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/assets/
DESTINATION ${CMAKE_INSTALL_FULL_DATADIR}/backgrounds/sway
COMPONENT data
FILES_MATCHING PATTERN "*Wallpaper*"
)
endif()
feature_summary(WHAT ALL)

View File

@ -22,14 +22,3 @@ assertion fails.
Outside of the compositor (swaymsg, swaybar, etc), using `assert.h` is
permitted.
## Building against a local wlc
1. Build wlc as described [here](https://github.com/Cloudef/wlc#building)
2. Inside your sway source folder, tell `cmake` to use your local version of wlc:
```bash
cmake \
-DWLC_LIBRARIES=path/to/wlc/target/src/libwlc.so \
-DWLC_INCLUDE_DIRS=path/to/wlc/include .
```

View File

@ -1,4 +1,4 @@
# sway [![](https://api.travis-ci.org/swaywm/sway.svg)](https://travis-ci.org/swaywm/sway) [![Mit fosspay spenden](https://drewdevault.com/donate/static/donate-with-fosspay.png)](https://drewdevault.com/donate?project=4)
# sway
Der Fortschritt dieser Übersetzung kann [hier](https://github.com/swaywm/sway/issues/1318)
eingesehen werden.
@ -52,7 +52,7 @@ schau im IRC-Channel vorbei oder schreibe eine e-Mail an sir@cmpwn.com (nur engl
Abhängigkeiten:
* cmake
* meson
* [wlc](https://github.com/Cloudef/wlc)
* wayland
* xwayland
@ -60,7 +60,7 @@ Abhängigkeiten:
* libcap
* asciidoc
* pcre
* json-c <= 0.12.1
* json-c >= 0.13
* pango
* cairo
* gdk-pixbuf2 *
@ -74,11 +74,9 @@ _\*\*Nur erforderlich für swaylock_
Führe diese Befehle aus:
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_SYSCONFDIR=/etc ..
make
sudo make install
meson build
ninja -C build
sudo ninja -C build install
In Systemen mit logind musst du `sway` einige Capabilities geben:

View File

@ -1,4 +1,4 @@
# sway [![](https://api.travis-ci.org/swaywm/sway.svg)](https://travis-ci.org/swaywm/sway) [![Donate with fosspay](https://drewdevault.com/donate/static/donate-with-fosspay.png)](https://drewdevault.com/donate?project=4)
# sway
"Ο Sway (**S**irCmpwn's **Way**land) είναι ένας **υπό ανάπτυξη** [Wayland](http://wayland.freedesktop.org/) διαχειριστής παραθύρων συμβατός με τον αντίστοιχο διαχειριστή παραθύρων i3 για τον X11.
Διαβάστε τις [Συνήθεις Ερωτήσεις](https://github.com/swaywm/sway/wiki). Συνδεθείτε στο [κανάλι μας στο IRC](http://webchat.freenode.net/?channels=sway&uio=d4) (#sway στο
@ -45,7 +45,7 @@ To username μου στο Freenode είναι kon14 και θα με βρείτ
Εγκατάσταση εξαρτήσεων:
* cmake
* meson
* [wlc](https://github.com/Cloudef/wlc)
* wayland
* xwayland
@ -53,7 +53,7 @@ To username μου στο Freenode είναι kon14 και θα με βρείτ
* libcap
* asciidoc
* pcre
* json-c <= 0.12.1
* json-c >= 0.13
* pango
* cairo
* gdk-pixbuf2 *
@ -67,11 +67,9 @@ _\*\*Απαιτείται μόνο για swaylock_
Εκτελέστε αυτές τις εντολές:
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_SYSCONFDIR=/etc ..
make
sudo make install
meson build
ninja -C build
sudo ninja -C build install
Σε συστήματα με logind, χρειάζεται να ορίσετε μερικά δικαιώματα caps στο εκτελέσιμο αρχείο:

View File

@ -1,4 +1,4 @@
# sway [![](https://api.travis-ci.org/swaywm/sway.svg)](https://travis-ci.org/swaywm/sway) [![Donate with fosspay](https://drewdevault.com/donate/static/donate-with-fosspay.png)](https://drewdevault.com/donate?project=4)
# sway
"**S**irCmpwn's **Way**land compositor" est un compositeur [Wayland](http://wayland.freedesktop.org/)
compatible avec i3, **en cours de développement**.
@ -47,7 +47,7 @@ IRC ou envoyez un e-mail à sir@cmpwn.com (en anglais seulement) pour des consei
Installez les dépendances :
* cmake
* meson
* [wlc](https://github.com/Cloudef/wlc)
* wayland
* xwayland
@ -55,7 +55,7 @@ Installez les dépendances :
* libcap
* asciidoc
* pcre
* json-c <= 0.12.1
* json-c >= 0.13
* pango
* cairo
* gdk-pixbuf2 *
@ -69,11 +69,9 @@ _\*\*Uniquement requis pour swaylock_
Exécutez ces commandes :
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_SYSCONFDIR=/etc ..
make
sudo make install
meson build
ninja -C build
sudo ninja -C build install
Sur les systèmes avec logind, vous devez définir quelques caps sur le binaire :

View File

@ -1,4 +1,4 @@
# sway [![](https://api.travis-ci.org/swaywm/sway.svg)](https://travis-ci.org/swaywm/sway) [![Donate with fosspay](https://drewdevault.com/donate/static/donate-with-fosspay.png)](https://drewdevault.com/donate?project=4)
# sway
"**S**irCmpwn's **Way**land compositor" è un compositor
[Wayland](http://wayland.freedesktop.org/) **in via di sviluppo**
@ -48,7 +48,7 @@ a sir@cmpwn.com.
Installa queste dipendenze:
* cmake
* meson
* [wlc](https://github.com/Cloudef/wlc)
* wayland
* xwayland
@ -56,7 +56,7 @@ Installa queste dipendenze:
* libcap
* asciidoc
* pcre
* json-c <= 0.12.1
* json-c >= 0.13
* pango
* cairo
* gdk-pixbuf2 *
@ -70,11 +70,9 @@ _\*\*Richiesto solo per swaylock_
Esegui questi comandi:
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_SYSCONFDIR=/etc ..
make
sudo make install
meson build
ninja -C build
sudo ninja -C build install
Per i sistemi con logind, devi impostare un paio di caps sull'eseguibile:

View File

@ -1,4 +1,4 @@
# sway [![](https://api.travis-ci.org/swaywm/sway.svg)](https://travis-ci.org/swaywm/sway) [![Donate with fosspay](https://drewdevault.com/donate/static/donate-with-fosspay.png)](https://drewdevault.com/donate?project=4)
# sway
"**S**irCmpwn's **Way**land compositor"は**開発中**の
i3互換な[Wayland](http://wayland.freedesktop.org/)コンポジタです。
@ -38,7 +38,7 @@ Swayは沢山のディストリビューションで提供されています。"
次の依存パッケージをインストールしてください:
* cmake
* meson
* [wlc](https://github.com/Cloudef/wlc)
* wayland
* xwayland
@ -46,7 +46,7 @@ Swayは沢山のディストリビューションで提供されています。"
* libcap
* asciidoc
* pcre
* json-c <= 0.12.1
* json-c >= 0.13
* pango
* cairo
* gdk-pixbuf2 *
@ -60,11 +60,9 @@ _\*\*swaylockでのみ必要です_
次のコマンドを実行してください:
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_SYSCONFDIR=/etc ..
make
sudo make install
meson build
ninja -C build
sudo ninja -C build install
logindを使用しているシステムでは、バイナリにいくつかのケーパビリティを設定する必要があります:

View File

@ -1,4 +1,4 @@
# sway [![](https://api.travis-ci.org/swaywm/sway.svg)](https://travis-ci.org/swaywm/sway) [![Donate with fosspay](https://drewdevault.com/donate/static/donate-with-fosspay.png)](https://drewdevault.com/donate?project=4)
# sway
[**English**](https://github.com/swaywm/sway/blob/master/README.md#sway--) - [日本語](https://github.com/swaywm/sway/blob/master/README.ja.md#sway--) - [Deutsch](https://github.com/swaywm/sway/blob/master/README.de.md#sway--) - [Ελληνικά](https://github.com/swaywm/sway/blob/master/README.el.md#sway--) - [Français](https://github.com/swaywm/sway/blob/master/README.fr.md#sway--) - [Українська](https://github.com/swaywm/sway/blob/master/README.uk.md#sway--) - [Italiano](https://github.com/swaywm/sway/blob/master/README.it.md#sway--) - [Português](https://github.com/swaywm/sway/blob/master/README.pt.md#sway--) -
[Русский](https://github.com/swaywm/sway/blob/master/README.ru.md#sway--)
@ -53,15 +53,15 @@ channel or shoot an email to sir@cmpwn.com for advice.
Install dependencies:
* cmake
* [wlc](https://github.com/Cloudef/wlc)
* meson
* [wlroots](https://github.com/swaywm/wlroots)
* wayland
* xwayland
* libinput >= 1.6.0
* libcap
* asciidoc
* pcre
* json-c <= 0.12.1
* json-c >= 0.13
* pango
* cairo
* gdk-pixbuf2 *
@ -78,11 +78,9 @@ _\*\*\*Only required for tray support_
Run these commands:
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_SYSCONFDIR=/etc ..
make
sudo make install
meson build
ninja -C build
sudo ninja -C build install
On systems with logind, you need to set a few caps on the binary:

View File

@ -1,4 +1,4 @@
# sway [![](https://api.travis-ci.org/swaywm/sway.svg)](https://travis-ci.org/swaywm/sway) [![Doe através do fosspay](https://drewdevault.com/donate/static/donate-with-fosspay.png)](https://drewdevault.com/donate?project=4)
# sway
"**S**irCmpwn's **Way**land compositor" é um compositor [Wayland](http://wayland.freedesktop.org/)
compatível com o i3. Leia o [FAQ](https://github.com/swaywm/sway/wiki). Participe do
@ -54,7 +54,7 @@ visite o canal no IRC ou mande um email para sir@cmpwn.com (*em inglês*).
Antes de iniciar a compilação, instale as dependências:
* cmake
* meson
* [wlc](https://github.com/Cloudef/wlc)
* wayland
* xwayland
@ -62,7 +62,7 @@ Antes de iniciar a compilação, instale as dependências:
* libcap
* asciidoc
* pcre
* json-c <= 0.12.1
* json-c >= 0.13
* pango
* cairo
* gdk-pixbuf2 *
@ -76,11 +76,9 @@ _\*\*Dependência apenas de swaylock_
Para compilar, execute estes comandos:
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_SYSCONFDIR=/etc ..
make
sudo make install
meson build
ninja -C build
sudo ninja -C build install
Em sistemas com logind, configure as seguintes capacidades para o arquivo binário:

View File

@ -1,4 +1,4 @@
# sway [![](https://api.travis-ci.org/swaywm/sway.svg)](https://travis-ci.org/swaywm/sway) [![Пожертвовать через fosspay](https://drewdevault.com/donate/static/donate-with-fosspay.png)](https://drewdevault.com/donate?project=4)
# sway
"**S**irCmpwn's **Way**land compositor" на данный момент **(в разработке)**
i3-совместимый [Wayland](http://wayland.freedesktop.org/) композитор.
@ -49,7 +49,7 @@ Sway доступен во многих дистрибутивах и наход
Установите следующие пакеты:
* cmake
* meson
* [wlc](https://github.com/Cloudef/wlc)
* wayland
* xwayland
@ -57,7 +57,7 @@ Sway доступен во многих дистрибутивах и наход
* libcap
* asciidoc
* pcre
* json-c <= 0.12.1
* json-c >= 0.13
* pango
* cairo
* gdk-pixbuf2 *
@ -74,11 +74,9 @@ _\*\*\*Требуется только для tray_
Выполните следующие команды:
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_SYSCONFDIR=/etc ..
make
sudo make install
meson build
ninja -C build
sudo ninja -C build install
Если у вас logind:

View File

@ -1,4 +1,4 @@
# sway [![](https://api.travis-ci.org/swaywm/sway.svg)](https://travis-ci.org/swaywm/sway) [![Donate with fosspay](https://drewdevault.com/donate/static/donate-with-fosspay.png)](https://drewdevault.com/donate?project=4)
# sway
**Sway** ("**S**irCmpwn's **Way**land compositor") це сумісний з i3 композитор
[Wayland](http://wayland.freedesktop.org/) (**у стані розробки**).
@ -54,7 +54,7 @@ Sway доступний у багатьох дистрибутивах Linux (а
Встановіть залежності:
* cmake
* meson
* [wlc](https://github.com/Cloudef/wlc)
* wayland
* xwayland
@ -62,7 +62,7 @@ Sway доступний у багатьох дистрибутивах Linux (а
* libcap
* asciidoc
* pcre
* json-c <= 0.12.1
* json-c >= 0.13
* pango
* cairo
* gdk-pixbuf2 *
@ -76,11 +76,9 @@ _\*\*Лише для swaylock_
Виконайте ці команди:
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_SYSCONFDIR=/etc ..
make
sudo make install
meson build
ninja -C build
sudo ninja -C build install
На системах **з** logind, варто встановити декілька можливостей (caps)
на виконуваний файл sway:

16
client/meson.build Normal file
View File

@ -0,0 +1,16 @@
lib_sway_client = static_library(
'sway-client',
files(
'pool-buffer.c',
),
dependencies: [
cairo,
gdk_pixbuf,
pango,
pangocairo,
wlroots,
wayland_client,
],
link_with: [lib_sway_common],
include_directories: sway_inc
)

View File

@ -1,21 +1,20 @@
#define _XOPEN_SOURCE 500
#include <wayland-client.h>
#include <assert.h>
#include <cairo/cairo.h>
#include <pango/pangocairo.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <unistd.h>
#include <errno.h>
#include <sys/mman.h>
#include "client/buffer.h"
#include "list.h"
#include "log.h"
#include <pango/pangocairo.h>
#include <unistd.h>
#include <wayland-client.h>
#include "config.h"
#include "pool-buffer.h"
static int create_pool_file(size_t size, char **name) {
static const char template[] = "sway-client-XXXXXX";
const char *path = getenv("XDG_RUNTIME_DIR");
if (!path) {
if (!path) {
return -1;
}
@ -42,7 +41,7 @@ static int create_pool_file(size_t size, char **name) {
}
static void buffer_release(void *data, struct wl_buffer *wl_buffer) {
struct buffer *buffer = data;
struct pool_buffer *buffer = data;
buffer->busy = false;
}
@ -50,22 +49,17 @@ static const struct wl_buffer_listener buffer_listener = {
.release = buffer_release
};
static struct buffer *create_buffer(struct window *window, struct buffer *buf,
int32_t width, int32_t height, int32_t scale, uint32_t format) {
width *= scale;
height *= scale;
static struct pool_buffer *create_buffer(struct wl_shm *shm,
struct pool_buffer *buf, int32_t width, int32_t height,
uint32_t format) {
uint32_t stride = width * 4;
uint32_t size = stride * height;
char *name;
int fd = create_pool_file(size, &name);
if (fd == -1) {
sway_abort("Unable to allocate buffer");
return NULL; // never reached
}
assert(fd != -1);
void *data = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
struct wl_shm_pool *pool = wl_shm_create_pool(window->registry->shm, fd, size);
struct wl_shm_pool *pool = wl_shm_create_pool(shm, fd, size);
buf->buffer = wl_shm_pool_create_buffer(pool, 0,
width, height, stride, format);
wl_shm_pool_destroy(pool);
@ -85,7 +79,7 @@ static struct buffer *create_buffer(struct window *window, struct buffer *buf,
return buf;
}
static void destroy_buffer(struct buffer *buffer) {
void destroy_buffer(struct pool_buffer *buffer) {
if (buffer->buffer) {
wl_buffer_destroy(buffer->buffer);
}
@ -98,37 +92,33 @@ static void destroy_buffer(struct buffer *buffer) {
if (buffer->pango) {
g_object_unref(buffer->pango);
}
memset(buffer, 0, sizeof(struct buffer));
memset(buffer, 0, sizeof(struct pool_buffer));
}
struct buffer *get_next_buffer(struct window *window) {
struct buffer *buffer = NULL;
struct pool_buffer *get_next_buffer(struct wl_shm *shm,
struct pool_buffer pool[static 2], uint32_t width, uint32_t height) {
struct pool_buffer *buffer = NULL;
int i;
for (i = 0; i < 2; ++i) {
if (window->buffers[i].busy) {
for (size_t i = 0; i < 2; ++i) {
if (pool[i].busy) {
continue;
}
buffer = &window->buffers[i];
buffer = &pool[i];
}
if (!buffer) {
return NULL;
}
if (buffer->width != window->width || buffer->height != window->height) {
if (buffer->width != width || buffer->height != height) {
destroy_buffer(buffer);
}
if (!buffer->buffer) {
if (!create_buffer(window, buffer,
window->width, window->height, window->scale,
if (!create_buffer(shm, buffer, width, height,
WL_SHM_FORMAT_ARGB8888)) {
return NULL;
}
}
window->cairo = buffer->cairo;
window->buffer = buffer;
return buffer;
}

View File

@ -1,15 +0,0 @@
include_directories(
${WLC_INCLUDE_DIRS}
${XKBCOMMON_INCLUDE_DIRS}
)
add_library(sway-common STATIC
ipc-client.c
list.c
log.c
util.c
readline.c
stringop.c
)
target_link_libraries(sway-common m)

119
common/background-image.c Normal file
View File

@ -0,0 +1,119 @@
#include <assert.h>
#include <stdbool.h>
#include <wlr/util/log.h>
#include "background-image.h"
#include "cairo.h"
enum background_mode parse_background_mode(const char *mode) {
if (strcmp(mode, "stretch") == 0) {
return BACKGROUND_MODE_STRETCH;
} else if (strcmp(mode, "fill") == 0) {
return BACKGROUND_MODE_FILL;
} else if (strcmp(mode, "fit") == 0) {
return BACKGROUND_MODE_FIT;
} else if (strcmp(mode, "center") == 0) {
return BACKGROUND_MODE_CENTER;
} else if (strcmp(mode, "tile") == 0) {
return BACKGROUND_MODE_TILE;
} else if (strcmp(mode, "solid_color") == 0) {
return BACKGROUND_MODE_SOLID_COLOR;
}
wlr_log(L_ERROR, "Unsupported background mode: %s", mode);
return BACKGROUND_MODE_INVALID;
}
cairo_surface_t *load_background_image(const char *path) {
cairo_surface_t *image;
#ifdef HAVE_GDK_PIXBUF
GError *err = NULL;
GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file(path, &err);
if (!pixbuf) {
wlr_log(L_ERROR, "Failed to load background image (%s).",
err->message);
return false;
}
image = gdk_cairo_image_surface_create_from_pixbuf(pixbuf);
g_object_unref(pixbuf);
#else
image = cairo_image_surface_create_from_png(path);
#endif //HAVE_GDK_PIXBUF
if (!image) {
wlr_log(L_ERROR, "Failed to read background image.");
return NULL;
}
if (cairo_surface_status(image) != CAIRO_STATUS_SUCCESS) {
wlr_log(L_ERROR, "Failed to read background image: %s."
#ifndef HAVE_GDK_PIXBUF
"\nSway was compiled without gdk_pixbuf support, so only"
"\nPNG images can be loaded. This is the likely cause."
#endif //HAVE_GDK_PIXBUF
, cairo_status_to_string(cairo_surface_status(image)));
return NULL;
}
return image;
}
void render_background_image(cairo_t *cairo, cairo_surface_t *image,
enum background_mode mode, int buffer_width, int buffer_height) {
double width = cairo_image_surface_get_width(image);
double height = cairo_image_surface_get_height(image);
switch (mode) {
case BACKGROUND_MODE_STRETCH:
cairo_scale(cairo,
(double)buffer_width / width,
(double)buffer_height / height);
cairo_set_source_surface(cairo, image, 0, 0);
break;
case BACKGROUND_MODE_FILL: {
double window_ratio = (double)buffer_width / buffer_height;
double bg_ratio = width / height;
if (window_ratio > bg_ratio) {
double scale = (double)buffer_width / width;
cairo_scale(cairo, scale, scale);
cairo_set_source_surface(cairo, image,
0, (double)buffer_height / 2 / scale - height / 2);
} else {
double scale = (double)buffer_height / height;
cairo_scale(cairo, scale, scale);
cairo_set_source_surface(cairo, image,
(double)buffer_width / 2 / scale - width / 2, 0);
}
break;
}
case BACKGROUND_MODE_FIT: {
double window_ratio = (double)buffer_width / buffer_height;
double bg_ratio = width / height;
if (window_ratio > bg_ratio) {
double scale = (double)buffer_height / height;
cairo_scale(cairo, scale, scale);
cairo_set_source_surface(cairo, image,
(double)buffer_width / 2 / scale - width / 2, 0);
} else {
double scale = (double)buffer_width / width;
cairo_scale(cairo, scale, scale);
cairo_set_source_surface(cairo, image,
0, (double)buffer_height / 2 / scale - height / 2);
}
break;
}
case BACKGROUND_MODE_CENTER:
cairo_set_source_surface(cairo, image,
(double)buffer_width / 2 - width / 2,
(double)buffer_height / 2 - height / 2);
break;
case BACKGROUND_MODE_TILE: {
cairo_pattern_t *pattern = cairo_pattern_create_for_surface(image);
cairo_pattern_set_extend(pattern, CAIRO_EXTEND_REPEAT);
cairo_set_source(cairo, pattern);
break;
}
case BACKGROUND_MODE_SOLID_COLOR:
case BACKGROUND_MODE_INVALID:
assert(0);
break;
}
cairo_paint(cairo);
}

View File

@ -1,4 +1,9 @@
#include "client/cairo.h"
#include <stdint.h>
#include <cairo/cairo.h>
#include "cairo.h"
#ifdef HAVE_GDK_PIXBUF
#include <gdk-pixbuf/gdk-pixbuf.h>
#endif
void cairo_set_source_u32(cairo_t *cairo, uint32_t color) {
cairo_set_source_rgba(cairo,
@ -8,45 +13,31 @@ void cairo_set_source_u32(cairo_t *cairo, uint32_t color) {
(color >> (0*8) & 0xFF) / 255.0);
}
cairo_surface_t *cairo_image_surface_scale(cairo_surface_t *image, int width, int height) {
cairo_surface_t *cairo_image_surface_scale(cairo_surface_t *image,
int width, int height) {
int image_width = cairo_image_surface_get_width(image);
int image_height = cairo_image_surface_get_height(image);
cairo_surface_t *new =
cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height);
cairo_t *cairo = cairo_create(new);
cairo_scale(cairo, (double) width / image_width, (double) height / image_height);
cairo_scale(cairo, (double)width / image_width,
(double)height / image_height);
cairo_set_source_surface(cairo, image, 0, 0);
cairo_paint(cairo);
cairo_destroy(cairo);
return new;
}
#ifdef WITH_GDK_PIXBUF
#include <gdk-pixbuf/gdk-pixbuf.h>
#ifndef GDK_PIXBUF_CHECK_VERSION
#define GDK_PIXBUF_CHECK_VERSION(major,minor,micro) \
(GDK_PIXBUF_MAJOR > (major) || \
(GDK_PIXBUF_MAJOR == (major) && GDK_PIXBUF_MINOR > (minor)) || \
(GDK_PIXBUF_MAJOR == (major) && GDK_PIXBUF_MINOR == (minor) && \
GDK_PIXBUF_MICRO >= (micro)))
#endif
#ifdef HAVE_GDK_PIXBUF
cairo_surface_t* gdk_cairo_image_surface_create_from_pixbuf(const GdkPixbuf *gdkbuf) {
int chan = gdk_pixbuf_get_n_channels(gdkbuf);
if (chan < 3) return NULL;
if (chan < 3) {
return NULL;
}
#if GDK_PIXBUF_CHECK_VERSION(2,32,0)
const guint8* gdkpix = gdk_pixbuf_read_pixels(gdkbuf);
#else
const guint8* gdkpix = gdk_pixbuf_get_pixels(gdkbuf);
#endif
if (!gdkpix) {
return NULL;
}
@ -101,7 +92,9 @@ cairo_surface_t* gdk_cairo_image_surface_create_from_pixbuf(const GdkPixbuf *gdk
* ------
* tested as equal to lround(z/255.0) for uint z in [0..0xfe02]
*/
#define PREMUL_ALPHA(x,a,b,z) G_STMT_START { z = a * b + 0x80; x = (z + (z >> 8)) >> 8; } G_STMT_END
#define PREMUL_ALPHA(x,a,b,z) \
G_STMT_START { z = a * b + 0x80; x = (z + (z >> 8)) >> 8; } \
G_STMT_END
int i;
for (i = h; i; --i) {
const guint8 *gp = gdkpix;
@ -131,4 +124,4 @@ cairo_surface_t* gdk_cairo_image_surface_create_from_pixbuf(const GdkPixbuf *gdk
cairo_surface_mark_dirty(cs);
return cs;
}
#endif //WITH_GDK_PIXBUF
#endif //HAVE_GDK_PIXBUF

View File

@ -1,4 +1,4 @@
#define _POSIX_C_SOURCE 2
#define _POSIX_C_SOURCE 200809L
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
@ -14,13 +14,31 @@ static const char ipc_magic[] = {'i', '3', '-', 'i', 'p', 'c'};
static const size_t ipc_header_size = sizeof(ipc_magic)+8;
char *get_socketpath(void) {
FILE *fp = popen("sway --get-socketpath", "r");
if (!fp) {
return NULL;
const char *swaysock = getenv("SWAYSOCK");
if (swaysock) {
return strdup(swaysock);
}
char *line = read_line(fp);
pclose(fp);
return line;
FILE *fp = popen("sway --get-socketpath 2>/dev/null", "r");
if (fp) {
char *line = read_line(fp);
pclose(fp);
if (line && *line) {
return line;
}
}
const char *i3sock = getenv("I3SOCK");
if (i3sock) {
return strdup(i3sock);
}
fp = popen("i3 --get-socketpath 2>/dev/null", "r");
if (fp) {
char *line = read_line(fp);
pclose(fp);
if (line && *line) {
return line;
}
}
return NULL;
}
int ipc_open_socket(const char *socket_path) {
@ -79,7 +97,7 @@ struct ipc_response *ipc_recv_response(int socketfd) {
error_2:
free(response);
error_1:
sway_log(L_ERROR, "Unable to allocate memory for IPC response");
wlr_log(L_ERROR, "Unable to allocate memory for IPC response");
return NULL;
}

View File

@ -1,167 +1,26 @@
#define _POSIX_C_SOURCE 199506L
#include <errno.h>
#include <libgen.h>
#include <signal.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <time.h>
#include "log.h"
#include "sway.h"
#include "readline.h"
static int colored = 1;
static log_importance_t loglevel_default = L_ERROR;
static log_importance_t v = L_SILENT;
void sway_terminate(int code);
static const char *verbosity_colors[] = {
[L_SILENT] = "",
[L_ERROR ] = "\x1B[1;31m",
[L_INFO ] = "\x1B[1;34m",
[L_DEBUG ] = "\x1B[1;30m",
};
static const char verbosity_chars[] = {
[L_SILENT] = '\0',
[L_ERROR ] = 'E',
[L_INFO ] = 'I',
[L_DEBUG ] = 'D',
};
void init_log(log_importance_t verbosity) {
if (verbosity != L_DEBUG) {
// command "debuglog" needs to know the user specified log level when
// turning off debug logging.
loglevel_default = verbosity;
}
v = verbosity;
}
void set_log_level(log_importance_t verbosity) {
v = verbosity;
}
log_importance_t get_log_level(void) {
return v;
}
void reset_log_level(void) {
v = loglevel_default;
}
bool toggle_debug_logging(void) {
v = (v == L_DEBUG) ? loglevel_default : L_DEBUG;
return (v == L_DEBUG);
}
void sway_log_colors(int mode) {
colored = (mode == 1) ? 1 : 0;
}
void _sway_vlog(const char *filename, int line, log_importance_t verbosity,
const char *format, va_list args) {
if (verbosity <= v) {
// prefix the time to the log message
static struct tm result;
static time_t t;
static struct tm *tm_info;
char buffer[26];
unsigned int c = verbosity;
if (c > sizeof(verbosity_colors) / sizeof(char *) - 1) {
c = sizeof(verbosity_colors) / sizeof(char *) - 1;
}
// First, if not printing color, show the log level
if (!(colored && isatty(STDERR_FILENO)) && c != L_SILENT) {
fprintf(stderr, "%c: ", verbosity_chars[c]);
}
// get current time
t = time(NULL);
// convert time to local time (determined by the locale)
tm_info = localtime_r(&t, &result);
// generate time prefix
strftime(buffer, sizeof(buffer), "%x %X - ", tm_info);
fprintf(stderr, "%s", buffer);
if (colored && isatty(STDERR_FILENO)) {
fprintf(stderr, "%s", verbosity_colors[c]);
}
if (filename && line) {
const char *file = filename + strlen(filename);
while (file != filename && *file != '/') {
--file;
}
if (*file == '/') {
++file;
}
fprintf(stderr, "[%s:%d] ", file, line);
}
vfprintf(stderr, format, args);
if (colored && isatty(STDERR_FILENO)) {
fprintf(stderr, "\x1B[0m");
}
fprintf(stderr, "\n");
}
}
void _sway_log(const char *filename, int line, log_importance_t verbosity, const char* format, ...) {
void _sway_abort(const char *format, ...) {
va_list args;
va_start(args, format);
_sway_vlog(filename, line, verbosity, format, args);
va_end(args);
}
void _sway_abort(const char *filename, int line, const char* format, ...) {
va_list args;
va_start(args, format);
_sway_vlog(filename, line, L_ERROR, format, args);
_wlr_vlog(L_ERROR, format, args);
va_end(args);
sway_terminate(EXIT_FAILURE);
}
void sway_log_errno(log_importance_t verbosity, char* format, ...) {
if (verbosity <= v) {
unsigned int c = verbosity;
if (c > sizeof(verbosity_colors) / sizeof(char *) - 1) {
c = sizeof(verbosity_colors) / sizeof(char *) - 1;
}
if (colored && isatty(STDERR_FILENO)) {
fprintf(stderr, "%s", verbosity_colors[c]);
} else if (c != L_SILENT) {
fprintf(stderr, "%c: ", verbosity_chars[c]);
}
va_list args;
va_start(args, format);
vfprintf(stderr, format, args);
va_end(args);
fprintf(stderr, ": ");
fprintf(stderr, "%s", strerror(errno));
if (colored && isatty(STDERR_FILENO)) {
fprintf(stderr, "\x1B[0m");
}
fprintf(stderr, "\n");
}
}
bool _sway_assert(bool condition, const char *filename, int line, const char* format, ...) {
bool _sway_assert(bool condition, const char *format, ...) {
if (condition) {
return true;
}
va_list args;
va_start(args, format);
_sway_vlog(filename, line, L_ERROR, format, args);
_wlr_vlog(L_ERROR, format, args);
va_end(args);
#ifndef NDEBUG

23
common/meson.build Normal file
View File

@ -0,0 +1,23 @@
lib_sway_common = static_library(
'sway-common',
files(
'background-image.c',
'cairo.c',
'ipc-client.c',
'log.c',
'list.c',
'pango.c',
'readline.c',
'stringop.c',
'unicode.c',
'util.c'
),
dependencies: [
cairo,
gdk_pixbuf,
pango,
pangocairo,
wlroots
],
include_directories: sway_inc
)

View File

@ -1,20 +1,26 @@
#include <cairo/cairo.h>
#include <pango/pangocairo.h>
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "log.h"
PangoLayout *get_pango_layout(cairo_t *cairo, const char *font, const char *text,
int32_t scale, bool markup) {
PangoLayout *get_pango_layout(cairo_t *cairo, const char *font,
const char *text, int32_t scale, bool markup) {
PangoLayout *layout = pango_cairo_create_layout(cairo);
PangoAttrList *attrs;
if (markup) {
char *buf;
pango_parse_markup(text, -1, 0, &attrs, &buf, NULL, NULL);
GError *error = NULL;
if (!sway_assert(pango_parse_markup(
text, -1, 0, &attrs, &buf, NULL, &error),
"pango_parse_markup '%s' -> error %s", text,
error ? error->message : NULL)) {
return NULL;
}
pango_layout_set_markup(layout, buf, -1);
free(buf);
} else {
@ -33,7 +39,7 @@ PangoLayout *get_pango_layout(cairo_t *cairo, const char *font, const char *text
void get_text_size(cairo_t *cairo, const char *font, int *width, int *height,
int32_t scale, bool markup, const char *fmt, ...) {
char *buf = malloc(2048);
static char buf[2048];
va_list args;
va_start(args, fmt);
@ -44,16 +50,13 @@ void get_text_size(cairo_t *cairo, const char *font, int *width, int *height,
PangoLayout *layout = get_pango_layout(cairo, font, buf, scale, markup);
pango_cairo_update_layout(cairo, layout);
pango_layout_get_pixel_size(layout, width, height);
g_object_unref(layout);
free(buf);
}
void pango_printf(cairo_t *cairo, const char *font, int32_t scale, bool markup, const char *fmt, ...) {
char *buf = malloc(2048);
void pango_printf(cairo_t *cairo, const char *font,
int32_t scale, bool markup, const char *fmt, ...) {
static char buf[2048];
va_list args;
va_start(args, fmt);
@ -64,10 +67,6 @@ void pango_printf(cairo_t *cairo, const char *font, int32_t scale, bool markup,
PangoLayout *layout = get_pango_layout(cairo, font, buf, scale, markup);
pango_cairo_update_layout(cairo, layout);
pango_cairo_show_layout(cairo, layout);
g_object_unref(layout);
free(buf);
}

View File

@ -8,7 +8,7 @@ char *read_line(FILE *file) {
char *string = malloc(size);
char lastChar = '\0';
if (!string) {
sway_log(L_ERROR, "Unable to allocate memory for read_line");
wlr_log(L_ERROR, "Unable to allocate memory for read_line");
return NULL;
}
while (1) {
@ -29,7 +29,7 @@ char *read_line(FILE *file) {
char *new_string = realloc(string, size *= 2);
if (!new_string) {
free(string);
sway_log(L_ERROR, "Unable to allocate memory for read_line");
wlr_log(L_ERROR, "Unable to allocate memory for read_line");
return NULL;
}
string = new_string;

101
common/unicode.c Normal file
View File

@ -0,0 +1,101 @@
#include <stdint.h>
#include <stddef.h>
#include "unicode.h"
size_t utf8_chsize(uint32_t ch) {
if (ch < 0x80) {
return 1;
} else if (ch < 0x800) {
return 2;
} else if (ch < 0x10000) {
return 3;
}
return 4;
}
static const uint8_t masks[] = {
0x7F,
0x1F,
0x0F,
0x07,
0x03,
0x01
};
uint32_t utf8_decode(const char **char_str) {
uint8_t **s = (uint8_t **)char_str;
uint32_t cp = 0;
if (**s < 128) {
// shortcut
cp = **s;
++*s;
return cp;
}
int size = utf8_size((char *)*s);
if (size == -1) {
++*s;
return UTF8_INVALID;
}
uint8_t mask = masks[size - 1];
cp = **s & mask;
++*s;
while (--size) {
cp <<= 6;
cp |= **s & 0x3f;
++*s;
}
return cp;
}
size_t utf8_encode(char *str, uint32_t ch) {
size_t len = 0;
uint8_t first;
if (ch < 0x80) {
first = 0;
len = 1;
} else if (ch < 0x800) {
first = 0xc0;
len = 2;
} else if (ch < 0x10000) {
first = 0xe0;
len = 3;
} else {
first = 0xf0;
len = 4;
}
for (size_t i = len - 1; i > 0; --i) {
str[i] = (ch & 0x3f) | 0x80;
ch >>= 6;
}
str[0] = ch | first;
return len;
}
static const struct {
uint8_t mask;
uint8_t result;
int octets;
} sizes[] = {
{ 0x80, 0x00, 1 },
{ 0xE0, 0xC0, 2 },
{ 0xF0, 0xE0, 3 },
{ 0xF8, 0xF0, 4 },
{ 0xFC, 0xF8, 5 },
{ 0xFE, 0xF8, 6 },
{ 0x80, 0x80, -1 },
};
int utf8_size(const char *s) {
uint8_t c = (uint8_t)*s;
for (size_t i = 0; i < sizeof(sizes) / 2; ++i) {
if ((c & sizes[i].mask) == sizes[i].result) {
return sizes[i].octets;
}
}
return -1;
}

View File

@ -8,8 +8,8 @@
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <wlc/wlc.h>
#include <xkbcommon/xkbcommon-names.h>
#include <wlr/types/wlr_keyboard.h>
#include "log.h"
#include "readline.h"
#include "util.h"
@ -29,16 +29,16 @@ static struct modifier_key {
char *name;
uint32_t mod;
} modifiers[] = {
{ XKB_MOD_NAME_SHIFT, WLC_BIT_MOD_SHIFT },
{ XKB_MOD_NAME_CAPS, WLC_BIT_MOD_CAPS },
{ XKB_MOD_NAME_CTRL, WLC_BIT_MOD_CTRL },
{ "Ctrl", WLC_BIT_MOD_CTRL },
{ XKB_MOD_NAME_ALT, WLC_BIT_MOD_ALT },
{ "Alt", WLC_BIT_MOD_ALT },
{ XKB_MOD_NAME_NUM, WLC_BIT_MOD_MOD2 },
{ "Mod3", WLC_BIT_MOD_MOD3 },
{ XKB_MOD_NAME_LOGO, WLC_BIT_MOD_LOGO },
{ "Mod5", WLC_BIT_MOD_MOD5 },
{ XKB_MOD_NAME_SHIFT, WLR_MODIFIER_SHIFT },
{ XKB_MOD_NAME_CAPS, WLR_MODIFIER_CAPS },
{ XKB_MOD_NAME_CTRL, WLR_MODIFIER_CTRL },
{ "Ctrl", WLR_MODIFIER_CTRL },
{ XKB_MOD_NAME_ALT, WLR_MODIFIER_ALT },
{ "Alt", WLR_MODIFIER_ALT },
{ XKB_MOD_NAME_NUM, WLR_MODIFIER_MOD2 },
{ "Mod3", WLR_MODIFIER_MOD3 },
{ XKB_MOD_NAME_LOGO, WLR_MODIFIER_LOGO },
{ "Mod5", WLR_MODIFIER_MOD5 },
};
uint32_t get_modifier_mask_by_name(const char *name) {
@ -113,7 +113,7 @@ uint32_t parse_color(const char *color) {
int len = strlen(color);
if (len != 6 && len != 8) {
sway_log(L_DEBUG, "Invalid color %s, defaulting to color 0xFFFFFFFF", color);
wlr_log(L_DEBUG, "Invalid color %s, defaulting to color 0xFFFFFFFF", color);
return 0xFFFFFFFF;
}
uint32_t res = (uint32_t)strtoul(color, NULL, 16);

View File

@ -1,4 +0,0 @@
install(
FILES _sway _swaymsg _swaygrab _swaylock
DESTINATION ${CMAKE_INSTALL_FULL_DATAROOTDIR}/zsh/site-functions/
)

View File

@ -21,7 +21,7 @@ set $menu dmenu_run
### Output configuration
#
# Default wallpaper (more resolutions are available in __DATADIR__/backgrounds/sway/)
output * bg __DATADIR__/backgrounds/sway/Sway_Wallpaper_Blue_1920x1080.png fill
output * bg @datadir@/backgrounds/sway/Sway_Wallpaper_Blue_1920x1080.png fill
#
# Example configuration:
#
@ -164,16 +164,16 @@ mode "resize" {
# right will grow the containers width
# up will shrink the containers height
# down will grow the containers height
bindsym $left resize shrink width 10 px or 10 ppt
bindsym $down resize grow height 10 px or 10 ppt
bindsym $up resize shrink height 10 px or 10 ppt
bindsym $right resize grow width 10 px or 10 ppt
bindsym $left resize shrink width 10px
bindsym $down resize grow height 10px
bindsym $up resize shrink height 10px
bindsym $right resize grow width 10px
# ditto, with arrow keys
bindsym Left resize shrink width 10 px or 10 ppt
bindsym Down resize grow height 10 px or 10 ppt
bindsym Up resize shrink height 10 px or 10 ppt
bindsym Right resize grow width 10 px or 10 ppt
bindsym Left resize shrink width 10px
bindsym Down resize grow height 10px
bindsym Up resize shrink height 10px
bindsym Right resize grow width 10px
# return to default mode
bindsym Return mode "default"
@ -194,4 +194,4 @@ bar {
}
}
include __SYSCONFDIR__/sway/config.d/*
include @sysconfdir@/sway/config.d/*

View File

@ -0,0 +1,20 @@
#ifndef _SWAY_BACKGROUND_IMAGE_H
#define _SWAY_BACKGROUND_IMAGE_H
#include "cairo.h"
enum background_mode {
BACKGROUND_MODE_STRETCH,
BACKGROUND_MODE_FILL,
BACKGROUND_MODE_FIT,
BACKGROUND_MODE_CENTER,
BACKGROUND_MODE_TILE,
BACKGROUND_MODE_SOLID_COLOR,
BACKGROUND_MODE_INVALID,
};
enum background_mode parse_background_mode(const char *mode);
cairo_surface_t *load_background_image(const char *path);
void render_background_image(cairo_t *cairo, cairo_surface_t *image,
enum background_mode mode, int buffer_width, int buffer_height);
#endif

View File

@ -1,17 +1,19 @@
#ifndef _SWAY_CAIRO_H
#define _SWAY_CAIRO_H
#include <stdint.h>
#include <cairo/cairo.h>
void cairo_set_source_u32(cairo_t *cairo, uint32_t color);
cairo_surface_t *cairo_image_surface_scale(cairo_surface_t *image, int width, int height);
cairo_surface_t *cairo_image_surface_scale(cairo_surface_t *image,
int width, int height);
#ifdef WITH_GDK_PIXBUF
#include "config.h"
#ifdef HAVE_GDK_PIXBUF
#include <gdk-pixbuf/gdk-pixbuf.h>
cairo_surface_t* gdk_cairo_image_surface_create_from_pixbuf(const GdkPixbuf *gdkbuf);
cairo_surface_t* gdk_cairo_image_surface_create_from_pixbuf(
const GdkPixbuf *gdkbuf);
#endif //WITH_GDK_PIXBUF
#endif

View File

@ -1,8 +0,0 @@
#ifndef _BUFFER_H
#define _BUFFER_H
#include "client/window.h"
struct buffer *get_next_buffer(struct window *state);
#endif

View File

@ -1,16 +0,0 @@
#ifndef _SWAY_CLIENT_PANGO_H
#define _SWAY_CLIENT_PANGO_H
#include <cairo/cairo.h>
#include <pango/pangocairo.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
PangoLayout *get_pango_layout(cairo_t *cairo, const char *font, const char *text,
int32_t scale, bool markup);
void get_text_size(cairo_t *cairo, const char *font, int *width, int *height,
int32_t scale, bool markup, const char *fmt, ...);
void pango_printf(cairo_t *cairo, const char *font, int32_t scale, bool markup, const char *fmt, ...);
#endif

View File

@ -1,75 +0,0 @@
#ifndef _SWAY_CLIENT_REGISTRY_H
#define _SWAY_CLIENT_REGISTRY_H
#include <wayland-client.h>
#include <xkbcommon/xkbcommon.h>
#include "wayland-desktop-shell-client-protocol.h"
#include "wayland-swaylock-client-protocol.h"
#include "list.h"
enum mod_bit {
MOD_SHIFT = 1<<0,
MOD_CAPS = 1<<1,
MOD_CTRL = 1<<2,
MOD_ALT = 1<<3,
MOD_MOD2 = 1<<4,
MOD_MOD3 = 1<<5,
MOD_LOGO = 1<<6,
MOD_MOD5 = 1<<7,
};
enum mask {
MASK_SHIFT,
MASK_CAPS,
MASK_CTRL,
MASK_ALT,
MASK_MOD2,
MASK_MOD3,
MASK_LOGO,
MASK_MOD5,
MASK_LAST
};
struct output_state {
struct wl_output *output;
uint32_t flags;
uint32_t width, height;
uint32_t scale;
};
struct xkb {
struct xkb_state *state;
struct xkb_context *context;
struct xkb_keymap *keymap;
xkb_mod_mask_t masks[MASK_LAST];
};
struct input {
struct xkb xkb;
xkb_keysym_t sym;
uint32_t code;
uint32_t last_code;
uint32_t modifiers;
void (*notify)(enum wl_keyboard_key_state state, xkb_keysym_t sym, uint32_t code, uint32_t codepoint);
};
struct registry {
struct wl_compositor *compositor;
struct wl_display *display;
struct wl_pointer *pointer;
struct wl_keyboard *keyboard;
struct wl_seat *seat;
struct wl_shell *shell;
struct wl_shm *shm;
struct desktop_shell *desktop_shell;
struct lock *swaylock;
struct input *input;
list_t *outputs;
};
struct registry *registry_poll(void);
void registry_teardown(struct registry *registry);
#endif

View File

@ -1,67 +0,0 @@
#ifndef _CLIENT_H
#define _CLIENT_H
#include <wayland-client.h>
#include "wayland-desktop-shell-client-protocol.h"
#include <cairo/cairo.h>
#include <pango/pangocairo.h>
#include <stdbool.h>
#include "list.h"
#include "client/registry.h"
struct window;
struct buffer {
struct wl_buffer *buffer;
cairo_surface_t *surface;
cairo_t *cairo;
PangoContext *pango;
uint32_t width, height;
bool busy;
};
struct cursor {
struct wl_surface *surface;
struct wl_cursor_theme *cursor_theme;
struct wl_cursor *cursor;
struct wl_pointer *pointer;
};
enum scroll_direction {
SCROLL_UP,
SCROLL_DOWN,
SCROLL_LEFT,
SCROLL_RIGHT,
};
struct pointer_input {
int last_x;
int last_y;
void (*notify_button)(struct window *window, int x, int y, uint32_t button, uint32_t state_w);
void (*notify_scroll)(struct window *window, enum scroll_direction direction);
};
struct window {
struct registry *registry;
struct buffer buffers[2];
struct buffer *buffer;
struct wl_surface *surface;
struct wl_shell_surface *shell_surface;
struct wl_callback *frame_cb;
struct cursor cursor;
uint32_t width, height;
int32_t scale;
char *font;
cairo_t *cairo;
struct pointer_input pointer_input;
};
struct window *window_setup(struct registry *registry, uint32_t width, uint32_t height,
int32_t scale, bool shell_surface);
void window_teardown(struct window *state);
int window_prerender(struct window *state);
int window_render(struct window *state);
void window_make_shell(struct window *window);
#endif

View File

@ -23,7 +23,6 @@ enum ipc_command_type {
IPC_EVENT_BINDING = ((1<<31) | 5),
IPC_EVENT_MODIFIER = ((1<<31) | 6),
IPC_EVENT_INPUT = ((1<<31) | 7),
IPC_SWAY_GET_PIXELS = 0x81
};
#endif

View File

@ -1,38 +1,15 @@
#ifndef _SWAY_LOG_H
#define _SWAY_LOG_H
#include <stdbool.h>
#include <wlr/util/log.h>
typedef enum {
L_SILENT = 0,
L_ERROR = 1,
L_INFO = 2,
L_DEBUG = 3,
} log_importance_t;
void init_log(log_importance_t verbosity);
void set_log_level(log_importance_t verbosity);
log_importance_t get_log_level(void);
void reset_log_level(void);
// returns whether debug logging is on after switching.
bool toggle_debug_logging(void);
void sway_log_colors(int mode);
void sway_log_errno(log_importance_t verbosity, char* format, ...) __attribute__((format(printf,2,3)));
void _sway_abort(const char *filename, int line, const char* format, ...) __attribute__((format(printf,3,4)));
void _sway_abort(const char *filename, ...) ATTRIB_PRINTF(1, 2);
#define sway_abort(FMT, ...) \
_sway_abort(__FILE__, __LINE__, FMT, ##__VA_ARGS__)
_sway_abort("[%s:%d] " FMT, wlr_strip_path(__FILE__), __LINE__, ##__VA_ARGS__)
bool _sway_assert(bool condition, const char *filename, int line, const char* format, ...) __attribute__((format(printf,4,5)));
bool _sway_assert(bool condition, const char* format, ...) ATTRIB_PRINTF(2, 3);
#define sway_assert(COND, FMT, ...) \
_sway_assert(COND, __FILE__, __LINE__, "%s:" FMT, __PRETTY_FUNCTION__, ##__VA_ARGS__)
void _sway_log(const char *filename, int line, log_importance_t verbosity, const char* format, ...) __attribute__((format(printf,4,5)));
#define sway_log(VERBOSITY, FMT, ...) \
_sway_log(__FILE__, __LINE__, VERBOSITY, FMT, ##__VA_ARGS__)
#define sway_vlog(VERBOSITY, FMT, VA_ARGS) \
_sway_vlog(__FILE__, __LINE__, VERBOSITY, FMT, VA_ARGS)
_sway_assert(COND, "[%s:%d] %s:" FMT, wlr_strip_path(__FILE__), __LINE__, __PRETTY_FUNCTION__, ##__VA_ARGS__)
void error_handler(int sig);

1
include/meson.build Normal file
View File

@ -0,0 +1 @@
configure_file(output: 'config.h', configuration: conf_data)

16
include/pango.h Normal file
View File

@ -0,0 +1,16 @@
#ifndef _SWAY_PANGO_H
#define _SWAY_PANGO_H
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <cairo/cairo.h>
#include <pango/pangocairo.h>
PangoLayout *get_pango_layout(cairo_t *cairo, const char *font,
const char *text, int32_t scale, bool markup);
void get_text_size(cairo_t *cairo, const char *font, int *width, int *height,
int32_t scale, bool markup, const char *fmt, ...);
void pango_printf(cairo_t *cairo, const char *font,
int32_t scale, bool markup, const char *fmt, ...);
#endif

22
include/pool-buffer.h Normal file
View File

@ -0,0 +1,22 @@
#ifndef _SWAY_BUFFERS_H
#define _SWAY_BUFFERS_H
#include <cairo/cairo.h>
#include <pango/pangocairo.h>
#include <stdbool.h>
#include <stdint.h>
#include <wayland-client.h>
struct pool_buffer {
struct wl_buffer *buffer;
cairo_surface_t *surface;
cairo_t *cairo;
PangoContext *pango;
uint32_t width, height;
bool busy;
};
struct pool_buffer *get_next_buffer(struct wl_shm *shm,
struct pool_buffer pool[static 2], uint32_t width, uint32_t height);
void destroy_buffer(struct pool_buffer *buffer);
#endif

View File

@ -1,6 +0,0 @@
#ifndef _SWAY_SWAY_H
#define _SWAY_SWAY_H
void sway_terminate(int exit_code);
#endif

View File

@ -1,28 +0,0 @@
#ifndef _SWAY_BORDER_H
#define _SWAY_BORDER_H
#include <wlc/wlc.h>
#include "container.h"
/**
* Border pixel buffer and corresponding geometry.
*/
struct border {
unsigned char *buffer;
struct wlc_geometry geometry;
};
/**
* Clear border buffer.
*/
void border_clear(struct border *border);
/**
* Recursively update all of the borders within a container.
*/
void update_container_border(swayc_t *container);
void render_view_borders(wlc_handle view);
int get_font_text_height(const char *font);
bool should_hide_top_border(swayc_t *con, double y);
#endif

View File

@ -1,12 +1,7 @@
#ifndef _SWAY_COMMANDS_H
#define _SWAY_COMMANDS_H
#include <stdbool.h>
#include <json-c/json.h>
#include <wlc/wlc.h>
#include "config.h"
// Container that a called command should act upon. Only valid in command functions.
extern swayc_t *current_container;
#include "config.h"
/**
* Indicates the result of a command's execution.
@ -22,6 +17,7 @@ enum cmd_status {
CMD_BLOCK_BAR,
CMD_BLOCK_BAR_COLORS,
CMD_BLOCK_INPUT,
CMD_BLOCK_SEAT,
CMD_BLOCK_COMMANDS,
CMD_BLOCK_IPC,
CMD_BLOCK_IPC_EVENTS,
@ -46,18 +42,13 @@ enum expected_args {
EXPECTED_EQUAL_TO
};
struct cmd_results *checkarg(int argc, const char *name, enum expected_args type, int val);
struct cmd_results *add_color(const char*, char*, const char*);
void input_cmd_apply(struct input_config *input);
void hide_view_in_scratchpad(swayc_t *sp_view);
swayc_t *sp_view;
int sp_index;
struct cmd_results *checkarg(int argc, const char *name,
enum expected_args type, int val);
/**
* Parse and handles a command.
* Parse and executes a command.
*/
struct cmd_results *handle_command(char *command, enum command_context context);
struct cmd_results *execute_command(char *command, struct sway_seat *seat);
/**
* Parse and handles a command during config file loading.
*
@ -68,7 +59,6 @@ struct cmd_results *config_command(char *command, enum cmd_status block);
* Parses a command policy rule.
*/
struct cmd_results *config_commands_command(char *exec);
/**
* Allocates a cmd_results object.
*/
@ -84,11 +74,8 @@ void free_cmd_results(struct cmd_results *results);
*/
const char *cmd_results_to_json(struct cmd_results *results);
void remove_view_from_scratchpad(swayc_t *);
/**
* Actual command function signatures for individual .c files in commands/ directory.
*/
struct cmd_results *add_color(const char *name,
char *buffer, const char *color);
typedef struct cmd_results *sway_cmd(int argc, char **argv);
@ -108,6 +95,7 @@ sway_cmd cmd_commands;
sway_cmd cmd_debuglog;
sway_cmd cmd_default_border;
sway_cmd cmd_default_floating_border;
sway_cmd cmd_default_orientation;
sway_cmd cmd_exec;
sway_cmd cmd_exec_always;
sway_cmd cmd_exit;
@ -126,6 +114,7 @@ sway_cmd cmd_gaps;
sway_cmd cmd_hide_edge_borders;
sway_cmd cmd_include;
sway_cmd cmd_input;
sway_cmd cmd_seat;
sway_cmd cmd_ipc;
sway_cmd cmd_kill;
sway_cmd cmd_layout;
@ -134,10 +123,10 @@ sway_cmd cmd_mark;
sway_cmd cmd_mode;
sway_cmd cmd_mouse_warping;
sway_cmd cmd_move;
sway_cmd cmd_opacity;
sway_cmd cmd_new_float;
sway_cmd cmd_new_window;
sway_cmd cmd_no_focus;
sway_cmd cmd_orientation;
sway_cmd cmd_output;
sway_cmd cmd_permit;
sway_cmd cmd_reject;
@ -153,6 +142,7 @@ sway_cmd cmd_splith;
sway_cmd cmd_splitt;
sway_cmd cmd_splitv;
sway_cmd cmd_sticky;
sway_cmd cmd_swaybg_command;
sway_cmd cmd_unmark;
sway_cmd cmd_workspace;
sway_cmd cmd_ws_auto_back_and_forth;
@ -195,17 +185,28 @@ sway_cmd bar_colors_cmd_statusline;
sway_cmd bar_colors_cmd_focused_statusline;
sway_cmd bar_colors_cmd_urgent_workspace;
sway_cmd input_cmd_seat;
sway_cmd input_cmd_accel_profile;
sway_cmd input_cmd_click_method;
sway_cmd input_cmd_drag_lock;
sway_cmd input_cmd_dwt;
sway_cmd input_cmd_events;
sway_cmd input_cmd_left_handed;
sway_cmd input_cmd_map_to_output;
sway_cmd input_cmd_middle_emulation;
sway_cmd input_cmd_natural_scroll;
sway_cmd input_cmd_pointer_accel;
sway_cmd input_cmd_scroll_method;
sway_cmd input_cmd_tap;
sway_cmd input_cmd_xkb_layout;
sway_cmd input_cmd_xkb_model;
sway_cmd input_cmd_xkb_options;
sway_cmd input_cmd_xkb_rules;
sway_cmd input_cmd_xkb_variant;
sway_cmd seat_cmd_attach;
sway_cmd seat_cmd_fallback;
sway_cmd seat_cmd_cursor;
sway_cmd cmd_ipc_cmd;
sway_cmd cmd_ipc_events;

View File

@ -1,18 +1,18 @@
#ifndef _SWAY_CONFIG_H
#define _SWAY_CONFIG_H
#define PID_WORKSPACE_TIMEOUT 60
#include <libinput.h>
#include <stdint.h>
#include <wlc/geometry.h>
#include <wlc/wlc.h>
#include <xkbcommon/xkbcommon.h>
#include <string.h>
#include <time.h>
#include "wayland-desktop-shell-server-protocol.h"
#include <wlr/types/wlr_box.h>
#include <xkbcommon/xkbcommon.h>
#include "list.h"
#include "layout.h"
#include "container.h"
#include "tree/layout.h"
#include "tree/container.h"
#include "wlr-layer-shell-unstable-v1-protocol.h"
// TODO: Refactor this shit
/**
* Describes a variable created via the `set` command.
@ -47,11 +47,12 @@ struct sway_mouse_binding {
*/
struct sway_mode {
char *name;
list_t *bindings;
list_t *keysym_bindings;
list_t *keycode_bindings;
};
/**
* libinput options for input devices
* options for input devices
*/
struct input_config {
char *identifier;
@ -68,8 +69,33 @@ struct input_config {
int send_events;
int tap;
char *xkb_layout;
char *xkb_model;
char *xkb_options;
char *xkb_rules;
char *xkb_variant;
char *mapped_output;
bool capturable;
struct wlc_geometry region;
struct wlr_box region;
};
/**
* Options for misc device configurations that happen in the seat block
*/
struct seat_attachment_config {
char *identifier;
// TODO other things are configured here for some reason
};
/**
* Options for multiseat and other misc device configurations
*/
struct seat_config {
char *name;
int fallback; // -1 means not set
list_t *attachments; // list of seat_attachment configs
};
/**
@ -81,8 +107,11 @@ struct output_config {
char *name;
int enabled;
int width, height;
float refresh_rate;
int x, y;
int scale;
float scale;
int32_t transform;
char *background;
char *background_option;
};
@ -126,24 +155,13 @@ struct bar_config {
char *id;
uint32_t modifier;
list_t *outputs;
enum desktop_shell_panel_position position;
char *position;
list_t *bindings;
char *status_command;
bool pango_markup;
char *swaybar_command;
char *font;
int height; // -1 not defined
#ifdef ENABLE_TRAY
// Tray
char *tray_output;
char *icon_theme;
uint32_t tray_padding;
uint32_t activate_button;
uint32_t context_button;
uint32_t secondary_button;
#endif
bool workspace_buttons;
bool wrap_scroll;
char *separator_symbol;
@ -260,11 +278,13 @@ struct sway_config {
list_t *pid_workspaces;
list_t *output_configs;
list_t *input_configs;
list_t *seat_configs;
list_t *criteria;
list_t *no_focus;
list_t *active_bar_modifiers;
struct sway_mode *current_mode;
struct bar_config *current_bar;
char *swaybg_command;
uint32_t floating_mod;
uint32_t dragging_key;
uint32_t resizing_key;
@ -272,8 +292,8 @@ struct sway_config {
char *floating_scroll_down_cmd;
char *floating_scroll_left_cmd;
char *floating_scroll_right_cmd;
enum swayc_layouts default_orientation;
enum swayc_layouts default_layout;
enum sway_container_layout default_orientation;
enum sway_container_layout default_layout;
char *font;
int font_height;
@ -286,7 +306,6 @@ struct sway_config {
bool reloading;
bool reading;
bool auto_back_and_forth;
bool seamless_mouse;
bool show_marks;
bool edge_gaps;
@ -297,8 +316,8 @@ struct sway_config {
list_t *config_chain;
const char *current_config;
enum swayc_border_types border;
enum swayc_border_types floating_border;
enum sway_container_border border;
enum sway_container_border floating_border;
int border_thickness;
int floating_border_thickness;
enum edge_border_types hide_edge_borders;
@ -323,6 +342,14 @@ struct sway_config {
list_t *command_policies;
list_t *feature_policies;
list_t *ipc_policies;
// Context for command handlers
struct {
struct input_config *input_config;
struct seat_config *seat_config;
struct sway_seat *seat;
struct sway_container *current_container;
} handler_context;
};
void pid_workspace_add(struct pid_workspace *pw);
@ -348,6 +375,11 @@ bool read_config(FILE *file, struct sway_config *config);
* Free config struct
*/
void free_config(struct sway_config *config);
void config_clear_handler_context(struct sway_config *config);
void free_sway_variable(struct sway_variable *var);
/**
* Does variable replacement for a string based on the config's currently loaded variables.
*/
@ -356,51 +388,74 @@ char *do_var_replacement(char *str);
struct cmd_results *check_security_config();
int input_identifier_cmp(const void *item, const void *data);
struct input_config *new_input_config(const char* identifier);
void merge_input_config(struct input_config *dst, struct input_config *src);
void apply_input_config(struct input_config *ic, struct libinput_device *dev);
struct input_config *copy_input_config(struct input_config *ic);
void free_input_config(struct input_config *ic);
int output_name_cmp(const void *item, const void *data);
void merge_output_config(struct output_config *dst, struct output_config *src);
/** Sets up a WLC output handle based on a given output_config.
*/
void apply_output_config(struct output_config *oc, swayc_t *output);
void free_output_config(struct output_config *oc);
void apply_input_config(struct input_config *input);
/**
* Updates the list of active bar modifiers
*/
void update_active_bar_modifiers(void);
int seat_name_cmp(const void *item, const void *data);
struct seat_config *new_seat_config(const char* name);
void merge_seat_config(struct seat_config *dst, struct seat_config *src);
struct seat_config *copy_seat_config(struct seat_config *seat);
void free_seat_config(struct seat_config *ic);
struct seat_attachment_config *seat_attachment_config_new();
struct seat_attachment_config *seat_config_get_attachment(
struct seat_config *seat_config, char *identifier);
void apply_seat_config(struct seat_config *seat);
int output_name_cmp(const void *item, const void *data);
void output_get_identifier(char *identifier, size_t len,
struct sway_output *output);
struct output_config *new_output_config(const char *name);
void merge_output_config(struct output_config *dst, struct output_config *src);
void apply_output_config(struct output_config *oc,
struct sway_container *output);
void free_output_config(struct output_config *oc);
int workspace_output_cmp_workspace(const void *a, const void *b);
int sway_binding_cmp(const void *a, const void *b);
int sway_binding_cmp_qsort(const void *a, const void *b);
int sway_binding_cmp_keys(const void *a, const void *b);
void free_sway_binding(struct sway_binding *sb);
struct sway_binding *sway_binding_dup(struct sway_binding *sb);
int sway_mouse_binding_cmp(const void *a, const void *b);
int sway_mouse_binding_cmp_qsort(const void *a, const void *b);
int sway_mouse_binding_cmp_buttons(const void *a, const void *b);
void free_sway_mouse_binding(struct sway_mouse_binding *smb);
void load_swaybars();
void invoke_swaybar(struct bar_config *bar);
void terminate_swaybg(pid_t pid);
/**
* Allocate and initialize default bar configuration.
*/
struct bar_config *default_bar_config(void);
/**
* Global config singleton.
*/
void free_bar_config(struct bar_config *bar);
/* Global config singleton. */
extern struct sway_config *config;
/**
* Config file currently being read.
*/
/* Config file currently being read */
extern const char *current_config_path;
#endif

View File

@ -1,357 +0,0 @@
#ifndef _SWAY_CONTAINER_H
#define _SWAY_CONTAINER_H
#include <sys/types.h>
#include <wlc/wlc.h>
#include <stdint.h>
#include "list.h"
typedef struct sway_container swayc_t;
extern swayc_t root_container;
extern swayc_t *current_focus;
/**
* Different kinds of containers.
*
* This enum is in order. A container will never be inside of a container below
* it on this list.
*/
enum swayc_types {
C_ROOT, /**< The root container. Only one of these ever exists. */
C_OUTPUT, /**< An output (aka monitor, head, etc). */
C_WORKSPACE, /**< A workspace. */
C_CONTAINER, /**< A manually created container. */
C_VIEW, /**< A view (aka window). */
// Keep last
C_TYPES,
};
/**
* Different ways to arrange a container.
*/
enum swayc_layouts {
L_NONE, /**< Used for containers that have no layout (views, root) */
L_HORIZ,
L_VERT,
L_STACKED,
L_TABBED,
L_FLOATING, /**< A psuedo-container, removed from the tree, to hold floating windows */
/* Awesome/Monad style auto layouts */
L_AUTO_LEFT,
L_AUTO_RIGHT,
L_AUTO_TOP,
L_AUTO_BOTTOM,
L_AUTO_FIRST = L_AUTO_LEFT,
L_AUTO_LAST = L_AUTO_BOTTOM,
// Keep last
L_LAYOUTS,
};
enum swayc_border_types {
B_NONE, /**< No border */
B_PIXEL, /**< 1px border */
B_NORMAL /**< Normal border with title bar */
};
/**
* Stores information about a container.
*
* The tree is made of these. Views are containers that cannot have children.
*/
struct sway_container {
/**
* If this container maps to a WLC object, this is set to that object's
* handle. Otherwise, NULL.
*/
wlc_handle handle;
/**
* A unique ID to identify this container. Primarily used in the
* get_tree JSON output.
*/
size_t id;
enum swayc_types type;
enum swayc_layouts layout;
enum swayc_layouts prev_layout;
enum swayc_layouts workspace_layout;
/**
* Width and height of this container, without borders or gaps.
*/
double width, height;
/**
* Views may request geometry, which is stored in this and ignored until
* the views are floated.
*/
int desired_width, desired_height;
/**
* The coordinates that this view appear at, relative to the output they
* are located on (output containers have absolute coordinates).
*/
double x, y;
/**
* Cached geometry used to store view/container geometry when switching
* between tabbed/stacked and horizontal/vertical layouts.
*/
struct wlc_geometry cached_geometry;
/**
* False if this view is invisible. It could be in the scratchpad or on a
* workspace that is not shown.
*/
bool visible;
bool is_floating;
bool is_focused;
bool sticky; // floating view always visible on its output
// Attributes that mostly views have.
char *name;
char *class;
char *instance;
char *app_id;
// Used by output containers to keep track of swaybg child processes.
pid_t bg_pid;
int gaps;
list_t *children;
/**
* Children of this container that are floated.
*/
list_t *floating;
/**
* Unmanaged view handles in this container.
*/
list_t *unmanaged;
/**
* The parent of this container. NULL for the root container.
*/
struct sway_container *parent;
/**
* Which of this container's children has focus.
*/
struct sway_container *focused;
/**
* If this container's children include a fullscreen view, this is that view.
*/
struct sway_container *fullscreen;
/**
* If this container is a view, this may be set to the window's decoration
* buffer (or NULL).
*/
struct border *border;
enum swayc_border_types border_type;
struct wlc_geometry border_geometry;
struct wlc_geometry title_bar_geometry;
struct wlc_geometry actual_geometry;
int border_thickness;
/**
* Number of master views in auto layouts.
*/
size_t nb_master;
/**
* Number of slave groups (e.g. columns) in auto layouts.
*/
size_t nb_slave_groups;
/**
* Marks applied to the container, list_t of char*.
*/
list_t *marks;
};
enum visibility_mask {
VISIBLE = true
} visible;
/**
* Allocates a new output container.
*/
swayc_t *new_output(wlc_handle handle);
/**
* Allocates a new workspace container.
*/
swayc_t *new_workspace(swayc_t *output, const char *name);
/**
* Allocates a new container and places a child into it.
*
* This is used from the split command, which creates a new container with the
* requested layout and replaces the focused container in the tree with the new
* one. Then the removed container is added as a child of the new container.
*/
swayc_t *new_container(swayc_t *child, enum swayc_layouts layout);
/**
* Allocates a new view container.
*
* Pass in a sibling view, or a workspace to become this container's parent.
*/
swayc_t *new_view(swayc_t *sibling, wlc_handle handle);
/**
* Allocates a new floating view in the active workspace.
*/
swayc_t *new_floating_view(wlc_handle handle);
void floating_view_sane_size(swayc_t *view);
/**
* Frees an output's container.
*/
swayc_t *destroy_output(swayc_t *output);
/**
* Destroys a workspace container and returns the parent pointer, or NULL.
*/
swayc_t *destroy_workspace(swayc_t *workspace);
/**
* Destroys a container and all empty parents. Returns the topmost non-empty
* parent container, or NULL.
*/
swayc_t *destroy_container(swayc_t *container);
/**
* Destroys a view container and all empty parents. Returns the topmost
* non-empty parent container, or NULL.
*/
swayc_t *destroy_view(swayc_t *view);
/**
* Finds a container based on test criteria. Returns the first container that
* passes the test.
*/
swayc_t *swayc_by_test(swayc_t *container, bool (*test)(swayc_t *view, void *data), void *data);
/**
* Finds a parent container with the given swayc_type.
*/
swayc_t *swayc_parent_by_type(swayc_t *container, enum swayc_types);
/**
* Finds a parent with the given swayc_layout.
*/
swayc_t *swayc_parent_by_layout(swayc_t *container, enum swayc_layouts);
/**
* Finds the bottom-most focused container of a type.
*/
swayc_t *swayc_focus_by_type(swayc_t *container, enum swayc_types);
/**
* Finds the bottom-most focused container of a layout.
*/
swayc_t *swayc_focus_by_layout(swayc_t *container, enum swayc_layouts);
/**
* Gets the swayc_t associated with a wlc_handle.
*/
swayc_t *swayc_by_handle(wlc_handle handle);
/**
* Gets the named swayc_t.
*/
swayc_t *swayc_by_name(const char *name);
/**
* Gets the active output's container.
*/
swayc_t *swayc_active_output(void);
/**
* Gets the active workspace's container.
*/
swayc_t *swayc_active_workspace(void);
/**
* Gets the workspace for the given view container.
*/
swayc_t *swayc_active_workspace_for(swayc_t *view);
/**
* Finds the container currently underneath the pointer.
*/
swayc_t *container_under_pointer(void);
/**
* Finds the first container following a callback.
*/
swayc_t *container_find(swayc_t *container, bool (*f)(swayc_t *, const void *), const void *data);
/**
* Returns true if a container is fullscreen.
*/
bool swayc_is_fullscreen(swayc_t *view);
/**
* Returns true if this view is focused.
*/
bool swayc_is_active(swayc_t *view);
/**
* Returns true if the parent is an ancestor of the child.
*/
bool swayc_is_parent_of(swayc_t *parent, swayc_t *child);
/**
* Returns true if the child is a desecendant of the parent.
*/
bool swayc_is_child_of(swayc_t *child, swayc_t *parent);
/**
* Returns true if this container is an empty workspace.
*/
bool swayc_is_empty_workspace(swayc_t *container);
/**
* Returns the top most tabbed or stacked parent container. Returns NULL if
* view is not in a tabbed/stacked layout.
*/
swayc_t *swayc_tabbed_stacked_ancestor(swayc_t *view);
/**
* Returns the immediate tabbed or stacked parent container. Returns NULL if
* view is not directly in a tabbed/stacked layout.
*/
swayc_t *swayc_tabbed_stacked_parent(swayc_t *view);
/**
* Returns the gap (padding) of the container.
*
* This returns the inner gaps for a view, the outer gaps for a workspace, and
* 0 otherwise.
*/
int swayc_gap(swayc_t *container);
/**
* Maps a container's children over a function.
*/
void container_map(swayc_t *, void (*f)(swayc_t *, void *), void *);
/**
* Set a view as visible or invisible.
*
* This will perform the required wlc calls as well; it is not sufficient to
* simply toggle the boolean in swayc_t.
*/
void set_view_visibility(swayc_t *view, void *data);
/**
* Set the gaps value for a view.
*/
void set_gaps(swayc_t *view, void *amount);
/**
* Add to the gaps value for a view.
*/
void add_gaps(swayc_t *view, void *amount);
/**
* Issue wlc calls to make the visibility of a container consistent.
*/
void update_visibility(swayc_t *container);
/**
* Close all child views of container
*/
void close_views(swayc_t *container);
/**
* Assign layout to a container. Needed due to workspace container specifics.
* Workspace should always have either L_VERT or L_HORIZ layout.
*/
swayc_t *swayc_change_layout(swayc_t *container, enum swayc_layouts layout);
#endif

View File

@ -1,7 +1,7 @@
#ifndef _SWAY_CRITERIA_H
#define _SWAY_CRITERIA_H
#include "container.h"
#include "tree/container.h"
#include "list.h"
/**
@ -31,12 +31,12 @@ char *extract_crit_tokens(list_t *tokens, const char *criteria);
// Returns list of criteria that match given container. These criteria have
// been set with `for_window` commands and have an associated cmdlist.
list_t *criteria_for(swayc_t *cont);
list_t *criteria_for(struct sway_container *cont);
// Returns a list of all containers that match the given list of tokens.
list_t *container_for(list_t *tokens);
list_t *container_for_crit_tokens(list_t *tokens);
// Returns true if any criteria in the given list matches this container
bool criteria_any(swayc_t *cont, list_t *criteria);
bool criteria_any(struct sway_container *cont, list_t *criteria);
#endif

7
include/sway/debug.h Normal file
View File

@ -0,0 +1,7 @@
#ifndef SWAY_DEBUG_H
#define SWAY_DEBUG_H
extern bool enable_debug_tree;
void update_debug_tree();
#endif

4
include/sway/desktop.h Normal file
View File

@ -0,0 +1,4 @@
#include <wlr/types/wlr_surface.h>
void desktop_damage_surface(struct wlr_surface *surface, double lx, double ly,
bool whole);

View File

@ -1,56 +0,0 @@
#ifndef _SWAY_EXTENSIONS_H
#define _SWAY_EXTENSIONS_H
#include <wayland-server.h>
#include <wlc/wlc-wayland.h>
#include "wayland-desktop-shell-server-protocol.h"
#include "list.h"
struct background_config {
wlc_handle output;
wlc_resource surface;
// we need the wl_resource of the surface in the destructor
struct wl_resource *wl_surface_res;
struct wl_client *client;
wlc_handle handle;
};
struct panel_config {
// wayland resource used in callbacks, is used to track this panel
struct wl_resource *wl_resource;
wlc_handle output;
wlc_resource surface;
// we need the wl_resource of the surface in the destructor
struct wl_resource *wl_surface_res;
enum desktop_shell_panel_position panel_position;
// used to determine if client is a panel
struct wl_client *client;
// wlc handle for this panel's surface, not set until panel is created
wlc_handle handle;
};
struct desktop_shell_state {
list_t *backgrounds;
list_t *panels;
list_t *lock_surfaces;
bool is_locked;
};
struct swaylock_state {
bool active;
wlc_handle output;
wlc_resource surface;
};
struct decoration_state {
list_t *csd_resources;
};
extern struct desktop_shell_state desktop_shell;
extern struct decoration_state decoration_state;
void register_extensions(void);
void server_decoration_enable_csd(wlc_handle handle);
#endif

View File

@ -1,45 +0,0 @@
#ifndef _SWAY_FOCUS_H
#define _SWAY_FOCUS_H
enum movement_direction {
MOVE_LEFT,
MOVE_RIGHT,
MOVE_UP,
MOVE_DOWN,
MOVE_PARENT,
MOVE_CHILD,
MOVE_NEXT,
MOVE_PREV,
MOVE_FIRST
};
#include "container.h"
// focused_container - the container found by following the `focused` pointer
// from a given container to a container with `is_focused` boolean set
// ---
// focused_view - the container found by following the `focused` pointer from a
// given container to a view.
// ---
swayc_t *get_focused_container(swayc_t *parent);
swayc_t *get_focused_view(swayc_t *parent);
swayc_t *get_focused_float(swayc_t *ws);
// a special-case function to get the focused view, regardless
// of whether it's tiled or floating
swayc_t *get_focused_view_include_floating(swayc_t *parent);
bool set_focused_container(swayc_t *container);
bool set_focused_container_for(swayc_t *ancestor, swayc_t *container);
// lock focused container/view. locked by windows with OVERRIDE attribute
// and unlocked when they are destroyed
extern bool locked_container_focus;
// Prevents wss from being destroyed on focus switch
extern bool suspend_workspace_cleanup;
bool move_focus(enum movement_direction direction);
#endif

View File

@ -1,11 +0,0 @@
#ifndef _SWAY_HANDLERS_H
#define _SWAY_HANDLERS_H
#include "container.h"
#include <stdbool.h>
#include <wlc/wlc.h>
void register_wlc_handlers();
extern uint32_t keys_pressed[32];
#endif

View File

@ -1,23 +0,0 @@
#ifndef _SWAY_INPUT_H
#define _SWAY_INPUT_H
#include <libinput.h>
#include "config.h"
#include "list.h"
struct input_config *new_input_config(const char* identifier);
char* libinput_dev_unique_id(struct libinput_device *dev);
/**
* Global input device list.
*/
extern list_t *input_devices;
/**
* Pointer used when reading input blocked.
* Shared so that it can be cleared from commands.c when closing the block
*/
extern struct input_config *current_input_config;
#endif

View File

@ -0,0 +1,36 @@
#ifndef _SWAY_INPUT_CURSOR_H
#define _SWAY_INPUT_CURSOR_H
#include <stdint.h>
#include "sway/input/seat.h"
struct sway_cursor {
struct sway_seat *seat;
struct wlr_cursor *cursor;
struct wlr_xcursor_manager *xcursor_manager;
struct wl_client *image_client;
struct wl_listener motion;
struct wl_listener motion_absolute;
struct wl_listener button;
struct wl_listener axis;
struct wl_listener touch_down;
struct wl_listener touch_up;
struct wl_listener touch_motion;
struct wl_listener tool_axis;
struct wl_listener tool_tip;
struct wl_listener tool_button;
uint32_t tool_buttons;
struct wl_listener request_set_cursor;
};
void sway_cursor_destroy(struct sway_cursor *cursor);
struct sway_cursor *sway_cursor_create(struct sway_seat *seat);
void cursor_send_pointer_motion(struct sway_cursor *cursor, uint32_t time);
void dispatch_cursor_button(struct sway_cursor *cursor, uint32_t time_msec,
uint32_t button, enum wlr_button_state state);
#endif

View File

@ -0,0 +1,64 @@
#ifndef _SWAY_INPUT_INPUT_MANAGER_H
#define _SWAY_INPUT_INPUT_MANAGER_H
#include <libinput.h>
#include <wlr/types/wlr_input_inhibitor.h>
#include "sway/server.h"
#include "sway/config.h"
#include "list.h"
/**
* The global singleton input manager
* TODO: make me not a global
*/
extern struct sway_input_manager *input_manager;
struct sway_input_device {
char *identifier;
struct wlr_input_device *wlr_device;
struct wl_list link;
struct wl_listener device_destroy;
};
struct sway_input_manager {
struct sway_server *server;
struct wl_list devices;
struct wl_list seats;
struct wlr_input_inhibit_manager *inhibit;
struct wl_listener new_input;
struct wl_listener inhibit_activate;
struct wl_listener inhibit_deactivate;
};
struct sway_input_manager *input_manager_create(struct sway_server *server);
bool input_manager_has_focus(struct sway_input_manager *input,
struct sway_container *container);
void input_manager_set_focus(struct sway_input_manager *input,
struct sway_container *container);
void input_manager_configure_xcursor(struct sway_input_manager *input);
void input_manager_apply_input_config(struct sway_input_manager *input,
struct input_config *input_config);
void input_manager_apply_seat_config(struct sway_input_manager *input,
struct seat_config *seat_config);
struct sway_seat *input_manager_get_default_seat(
struct sway_input_manager *input);
struct sway_seat *input_manager_get_seat(struct sway_input_manager *input,
const char *seat_name);
/**
* Gets the last seat the user interacted with
*/
struct sway_seat *input_manager_current_seat(struct sway_input_manager *input);
struct input_config *input_device_get_config(struct sway_input_device *device);
#endif

View File

@ -0,0 +1,30 @@
#ifndef _SWAY_INPUT_KEYBOARD_H
#define _SWAY_INPUT_KEYBOARD_H
#include "sway/input/seat.h"
#define SWAY_KEYBOARD_PRESSED_KEYSYMS_CAP 32
struct sway_keyboard {
struct sway_seat_device *seat_device;
struct xkb_keymap *keymap;
struct wl_listener keyboard_key;
struct wl_listener keyboard_modifiers;
xkb_keysym_t pressed_keysyms_translated[SWAY_KEYBOARD_PRESSED_KEYSYMS_CAP];
uint32_t modifiers_translated;
xkb_keysym_t pressed_keysyms_raw[SWAY_KEYBOARD_PRESSED_KEYSYMS_CAP];
uint32_t modifiers_raw;
};
struct sway_keyboard *sway_keyboard_create(struct sway_seat *seat,
struct sway_seat_device *device);
void sway_keyboard_configure(struct sway_keyboard *keyboard);
void sway_keyboard_destroy(struct sway_keyboard *keyboard);
#endif

111
include/sway/input/seat.h Normal file
View File

@ -0,0 +1,111 @@
#ifndef _SWAY_INPUT_SEAT_H
#define _SWAY_INPUT_SEAT_H
#include <wlr/types/wlr_layer_shell.h>
#include <wlr/types/wlr_seat.h>
#include "sway/input/input-manager.h"
struct sway_seat_device {
struct sway_seat *sway_seat;
struct sway_input_device *input_device;
struct sway_keyboard *keyboard;
struct wl_list link; // sway_seat::devices
};
struct sway_seat_container {
struct sway_seat *seat;
struct sway_container *container;
struct wl_list link; // sway_seat::focus_stack
struct wl_listener destroy;
};
struct sway_seat {
struct wlr_seat *wlr_seat;
struct sway_cursor *cursor;
struct sway_input_manager *input;
bool has_focus;
struct wl_list focus_stack; // list of containers in focus order
// If the focused layer is set, views cannot receive keyboard focus
struct wlr_layer_surface *focused_layer;
// If exclusive_client is set, no other clients will receive input events
struct wl_client *exclusive_client;
struct wl_listener focus_destroy;
struct wl_listener new_container;
struct wl_list devices; // sway_seat_device::link
struct wl_list link; // input_manager::seats
};
struct sway_seat *seat_create(struct sway_input_manager *input,
const char *seat_name);
void seat_destroy(struct sway_seat *seat);
void seat_add_device(struct sway_seat *seat,
struct sway_input_device *device);
void seat_configure_device(struct sway_seat *seat,
struct sway_input_device *device);
void seat_remove_device(struct sway_seat *seat,
struct sway_input_device *device);
void seat_configure_xcursor(struct sway_seat *seat);
void seat_set_focus(struct sway_seat *seat, struct sway_container *container);
void seat_set_focus_warp(struct sway_seat *seat,
struct sway_container *container, bool warp);
void seat_set_focus_surface(struct sway_seat *seat,
struct wlr_surface *surface);
void seat_set_focus_layer(struct sway_seat *seat,
struct wlr_layer_surface *layer);
void seat_set_exclusive_client(struct sway_seat *seat,
struct wl_client *client);
struct sway_container *seat_get_focus(struct sway_seat *seat);
/**
* Return the last container to be focused for the seat (or the most recently
* opened if no container has received focused) that is a child of the given
* container. The focus-inactive container of the root window is the focused
* container for the seat (if the seat does have focus). This function can be
* used to determine what container gets focused next if the focused container
* is destroyed, or focus moves to a container with children and we need to
* descend into the next leaf in focus order.
*/
struct sway_container *seat_get_focus_inactive(struct sway_seat *seat,
struct sway_container *container);
/**
* Descend into the focus stack to find the focus-inactive view. Useful for
* container placement when they change position in the tree.
*/
struct sway_container *seat_get_focus_inactive_view(struct sway_seat *seat,
struct sway_container *container);
/**
* Iterate over the focus-inactive children of the container calling the
* function on each.
*/
void seat_focus_inactive_children_for_each(struct sway_seat *seat,
struct sway_container *container,
void (*f)(struct sway_container *container, void *data), void *data);
void seat_apply_config(struct sway_seat *seat, struct seat_config *seat_config);
struct seat_config *seat_get_config(struct sway_seat *seat);
bool seat_is_input_allowed(struct sway_seat *seat, struct wlr_surface *surface);
#endif

View File

@ -1,102 +0,0 @@
#ifndef _SWAY_KEY_STATE_H
#define _SWAY_KEY_STATE_H
#include <stdbool.h>
#include <stdint.h>
#include "container.h"
/* Keyboard state */
// returns true if key has been pressed, otherwise false
bool check_key(uint32_t key_sym, uint32_t key_code);
// returns true if key_sym matches latest released key.
bool check_released_key(uint32_t key_sym);
// sets a key as pressed
void press_key(uint32_t key_sym, uint32_t key_code);
// unsets a key as pressed
void release_key(uint32_t key_sym, uint32_t key_code);
/* Pointer state */
enum pointer_values {
M_LEFT_CLICK = 272,
M_RIGHT_CLICK = 273,
M_SCROLL_CLICK = 274,
M_SCROLL_UP = 275,
M_SCROLL_DOWN = 276,
};
enum pointer_mode {
// Target
M_FLOATING = 1,
M_TILING = 2,
// Action
M_DRAGGING = 4,
M_RESIZING = 8,
};
struct pointer_button_state {
bool held;
// state at the point it was pressed
int x, y;
swayc_t *view;
};
extern struct pointer_state {
// mouse clicks
struct pointer_button_state left;
struct pointer_button_state right;
struct pointer_button_state scroll;
// change in pointer position
struct {
int x, y;
} delta;
// view pointer is currently over
swayc_t *view;
// Pointer mode
int mode;
} pointer_state;
enum modifier_state {
MOD_STATE_UNCHANGED = 0,
MOD_STATE_PRESSED = 1,
MOD_STATE_RELEASED = 2
};
void pointer_position_set(double new_x, double new_y, bool force_focus);
void center_pointer_on(swayc_t *view);
// on button release unset mode depending on the button.
// on button press set mode conditionally depending on the button
void pointer_mode_set(uint32_t button, bool condition);
// Update mode in mouse motion
void pointer_mode_update(void);
// Reset mode on any keypress;
void pointer_mode_reset(void);
void input_init(void);
/**
* Check if state of mod changed from current state to new_state.
*
* Returns MOD_STATE_UNCHANGED if the state didn't change, MOD_STATE_PRESSED if
* the state changed to pressed and MOD_STATE_RELEASED if the state changed to
* released.
*/
uint32_t modifier_state_changed(uint32_t new_state, uint32_t mod);
/**
* Update the current modifiers state to new_state.
*/
void modifiers_state_update(uint32_t new_state);
#endif

View File

@ -1,15 +1,14 @@
#ifndef _SWAY_IPC_JSON_H
#define _SWAY_IPC_JSON_H
#include <json-c/json.h>
#include "config.h"
#include "container.h"
#include "sway/tree/container.h"
#include "sway/input/input-manager.h"
json_object *ipc_json_get_version();
json_object *ipc_json_describe_container(struct sway_container *c);
json_object *ipc_json_describe_container_recursive(struct sway_container *c);
json_object *ipc_json_describe_input(struct sway_input_device *device);
json_object *ipc_json_describe_bar_config(struct bar_config *bar);
json_object *ipc_json_describe_container(swayc_t *c);
json_object *ipc_json_describe_container_recursive(swayc_t *c);
json_object *ipc_json_describe_window(swayc_t *c);
json_object *ipc_json_describe_input(struct libinput_device *device);
#endif

View File

@ -1,41 +1,21 @@
#ifndef _SWAY_IPC_SERVER_H
#define _SWAY_IPC_SERVER_H
#include <wlc/wlc.h>
#include "container.h"
#include "config.h"
#include <sys/socket.h>
#include "sway/tree/container.h"
#include "ipc.h"
void ipc_init(void);
struct sway_server;
void ipc_init(struct sway_server *server);
void ipc_terminate(void);
struct sockaddr_un *ipc_user_sockaddr(void);
void ipc_event_workspace(swayc_t *old, swayc_t *new, const char *change);
void ipc_event_workspace(struct sway_container *old,
struct sway_container *new, const char *change);
void ipc_event_window(struct sway_container *window, const char *change);
void ipc_event_barconfig_update(struct bar_config *bar);
/**
* Send IPC mode event to all listening clients
*/
void ipc_event_mode(const char *mode);
/**
* Send IPC window change event
*/
void ipc_event_window(swayc_t *window, const char *change);
/**
* Sends an IPC modifier event to all listening clients. The modifier event
* includes a key 'change' with the value of state and a key 'modifier' with
* the name of that modifier.
*/
void ipc_event_modifier(uint32_t modifier, const char *state);
/**
* Send IPC keyboard binding event.
*/
void ipc_event_binding_keyboard(struct sway_binding *sb);
const char *swayc_type_string(enum swayc_types type);
/**
* Send pixel data to registered clients.
*/
void ipc_get_pixels(wlc_handle output);
#endif

25
include/sway/layers.h Normal file
View File

@ -0,0 +1,25 @@
#ifndef _SWAY_LAYERS_H
#define _SWAY_LAYERS_H
#include <stdbool.h>
#include <wlr/types/wlr_box.h>
#include <wlr/types/wlr_surface.h>
#include <wlr/types/wlr_layer_shell.h>
struct sway_layer_surface {
struct wlr_layer_surface *layer_surface;
struct wl_list link;
struct wl_listener destroy;
struct wl_listener map;
struct wl_listener unmap;
struct wl_listener surface_commit;
struct wl_listener output_destroy;
bool configured;
struct wlr_box geo;
};
struct sway_output;
void arrange_layers(struct sway_output *output);
#endif

View File

@ -1,85 +0,0 @@
#ifndef _SWAY_LAYOUT_H
#define _SWAY_LAYOUT_H
#include <wlc/wlc.h>
#include "log.h"
#include "list.h"
#include "container.h"
#include "focus.h"
extern list_t *scratchpad;
extern int min_sane_w;
extern int min_sane_h;
// Set initial values for root_container
void init_layout(void);
// Returns the index of child for its parent
int index_child(const swayc_t *child);
// Adds child to parent, if parent has no focus, it is set to child
// parent must be of type C_WORKSPACE or C_CONTAINER
void add_child(swayc_t *parent, swayc_t *child);
// Adds child to parent at index, if parent has no focus, it is set to child
// parent must be of type C_WORKSPACE or C_CONTAINER
void insert_child(swayc_t *parent, swayc_t *child, int index);
// Adds child as floating window to ws, if there is no focus it is set to child.
// ws must be of type C_WORKSPACE
void add_floating(swayc_t *ws, swayc_t *child);
// insert child after sibling in parents children.
swayc_t *add_sibling(swayc_t *sibling, swayc_t *child);
// Replace child with new_child in parents children
// new_child will inherit childs geometry, childs geometry will be reset
// if parents focus is on child, it will be changed to new_child
swayc_t *replace_child(swayc_t *child, swayc_t *new_child);
// Remove child from its parent, if focus is on child, focus will be changed to
// a sibling, or to a floating window, or NULL
swayc_t *remove_child(swayc_t *child);
// 2 containers are swapped, they inherit eachothers focus
void swap_container(swayc_t *a, swayc_t *b);
// 2 Containers geometry are swapped, used with `swap_container`
void swap_geometry(swayc_t *a, swayc_t *b);
void move_container(swayc_t* container, enum movement_direction direction, int move_amt);
void move_container_to(swayc_t* container, swayc_t* destination);
void move_workspace_to(swayc_t* workspace, swayc_t* destination);
// Layout
/**
* Update child container geometries when switching between layouts.
*/
void update_layout_geometry(swayc_t *parent, enum swayc_layouts prev_layout);
void update_geometry(swayc_t *view);
void arrange_windows(swayc_t *container, double width, double height);
void arrange_backgrounds(void);
swayc_t *get_focused_container(swayc_t *parent);
swayc_t *get_swayc_in_direction(swayc_t *container, enum movement_direction dir);
swayc_t *get_swayc_in_direction_under(swayc_t *container, enum movement_direction dir, swayc_t *limit);
void recursive_resize(swayc_t *container, double amount, enum wlc_resize_edge edge);
void layout_log(const swayc_t *c, int depth);
void swayc_log(log_importance_t verbosity, swayc_t *cont, const char* format, ...) __attribute__((format(printf,3,4)));
/**
* Get default layout.
*/
enum swayc_layouts default_layout(swayc_t *output);
bool is_auto_layout(enum swayc_layouts layout);
int auto_group_start_index(const swayc_t *container, int index);
int auto_group_end_index(const swayc_t *container, int index);
size_t auto_group_count(const swayc_t *container);
size_t auto_group_index(const swayc_t *container, int index);
bool auto_group_bounds(const swayc_t *container, size_t group_index, int *start, int *end);
#endif

View File

@ -1,25 +1,48 @@
#ifndef _SWAY_OUTPUT_H
#define _SWAY_OUTPUT_H
#include <time.h>
#include <unistd.h>
#include <wayland-server.h>
#include <wlr/types/wlr_box.h>
#include <wlr/types/wlr_output.h>
#include "sway/tree/view.h"
#include "container.h"
#include "focus.h"
struct sway_server;
struct sway_container;
// Position is absolute coordinates on the edge where the adjacent output
// should be searched for.
swayc_t *output_by_name(const char* name, const struct wlc_point *abs_pos);
swayc_t *swayc_opposite_output(enum movement_direction dir, const struct wlc_point *abs_pos);
swayc_t *swayc_adjacent_output(swayc_t *output, enum movement_direction dir, const struct wlc_point *abs_pos, bool pick_closest);
struct sway_output {
struct wlr_output *wlr_output;
struct sway_container *swayc;
struct sway_server *server;
// Place absolute coordinates for given container into given wlc_point.
void get_absolute_position(swayc_t *container, struct wlc_point *point);
struct wl_list layers[4]; // sway_layer_surface::link
struct wlr_box usable_area;
// Place absolute coordinates for the center point of given container into
// given wlc_point.
void get_absolute_center_position(swayc_t *container, struct wlc_point *point);
struct timespec last_frame;
struct wlr_output_damage *damage;
// stable sort workspaces on this output
void sort_workspaces(swayc_t *output);
struct wl_listener destroy;
struct wl_listener mode;
struct wl_listener transform;
struct wl_listener scale;
void output_get_scaled_size(wlc_handle handle, struct wlc_size *size);
struct wl_listener damage_destroy;
struct wl_listener damage_frame;
pid_t bg_pid;
};
void output_damage_whole(struct sway_output *output);
void output_damage_surface(struct sway_output *output, double ox, double oy,
struct wlr_surface *surface, bool whole);
void output_damage_view(struct sway_output *output, struct sway_view *view,
bool whole);
void output_damage_whole_container(struct sway_output *output,
struct sway_container *con);
struct sway_container *output_by_name(const char *name);
#endif

57
include/sway/server.h Normal file
View File

@ -0,0 +1,57 @@
#ifndef _SWAY_SERVER_H
#define _SWAY_SERVER_H
#include <stdbool.h>
#include <wayland-server.h>
#include <wlr/backend.h>
#include <wlr/backend/session.h>
#include <wlr/types/wlr_compositor.h>
#include <wlr/types/wlr_data_device.h>
#include <wlr/types/wlr_layer_shell.h>
#include <wlr/types/wlr_xdg_shell_v6.h>
#include <wlr/render/wlr_renderer.h>
// TODO WLR: make Xwayland optional
#include <wlr/xwayland.h>
struct sway_server {
struct wl_display *wl_display;
struct wl_event_loop *wl_event_loop;
const char *socket;
struct wlr_backend *backend;
struct wlr_compositor *compositor;
struct wlr_data_device_manager *data_device_manager;
struct sway_input_manager *input;
struct wl_listener new_output;
struct wlr_layer_shell *layer_shell;
struct wl_listener layer_shell_surface;
struct wlr_xdg_shell_v6 *xdg_shell_v6;
struct wl_listener xdg_shell_v6_surface;
struct wlr_xwayland *xwayland;
struct wlr_xcursor_manager *xcursor_manager;
struct wl_listener xwayland_surface;
struct wl_listener xwayland_ready;
struct wlr_wl_shell *wl_shell;
struct wl_listener wl_shell_surface;
};
struct sway_server server;
bool server_init(struct sway_server *server);
void server_fini(struct sway_server *server);
void server_run(struct sway_server *server);
void handle_new_output(struct wl_listener *listener, void *data);
void handle_layer_shell_surface(struct wl_listener *listener, void *data);
void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data);
void handle_xwayland_surface(struct wl_listener *listener, void *data);
void handle_wl_shell_surface(struct wl_listener *listener, void *data);
#endif

View File

@ -0,0 +1,192 @@
#ifndef _SWAY_CONTAINER_H
#define _SWAY_CONTAINER_H
#include <stdint.h>
#include <sys/types.h>
#include <wlr/types/wlr_box.h>
#include <wlr/types/wlr_surface.h>
#include "list.h"
extern struct sway_container root_container;
struct sway_view;
struct sway_seat;
/**
* Different kinds of containers.
*
* This enum is in order. A container will never be inside of a container below
* it on this list.
*/
enum sway_container_type {
C_ROOT,
C_OUTPUT,
C_WORKSPACE,
C_CONTAINER,
C_VIEW,
// Keep last
C_TYPES,
};
enum sway_container_layout {
L_NONE,
L_HORIZ,
L_VERT,
L_STACKED,
L_TABBED,
L_FLOATING,
};
enum sway_container_border {
B_NONE,
B_PIXEL,
B_NORMAL,
};
struct sway_root;
struct sway_output;
struct sway_view;
struct sway_container {
union {
// TODO: Encapsulate state for other node types as well like C_CONTAINER
struct sway_root *sway_root;
struct sway_output *sway_output;
struct sway_view *sway_view;
};
/**
* A unique ID to identify this container. Primarily used in the
* get_tree JSON output.
*/
size_t id;
char *name;
enum sway_container_type type;
enum sway_container_layout layout;
enum sway_container_layout prev_layout;
enum sway_container_layout workspace_layout;
// For C_ROOT, this has no meaning
// For C_OUTPUT, this is the output position in layout coordinates
// For other types, this is the position in output-local coordinates
double x, y;
// does not include borders or gaps.
double width, height;
list_t *children;
struct sway_container *parent;
list_t *marks; // list of char*
float alpha;
struct {
struct wl_signal destroy;
// Raised after the tree updates, but before arrange_windows
// Passed the previous parent
struct wl_signal reparent;
} events;
};
struct sway_container *container_create(enum sway_container_type type);
const char *container_type_to_str(enum sway_container_type type);
struct sway_container *output_create(struct sway_output *sway_output);
/**
* Create a new container container. A container container can be a a child of
* a workspace container or another container container.
*/
struct sway_container *container_container_create();
/**
* Create a new output. Outputs are children of the root container and have no
* order in the tree structure.
*/
struct sway_container *output_create(struct sway_output *sway_output);
/**
* Create a new workspace container. Workspaces are children of an output
* container and are ordered alphabetically by name.
*/
struct sway_container *workspace_create(struct sway_container *output,
const char *name);
/*
* Create a new view container. A view can be a child of a workspace container
* or a container container and are rendered in the order and structure of
* how they are attached to the tree.
*/
struct sway_container *container_view_create(
struct sway_container *sibling, struct sway_view *sway_view);
struct sway_container *container_destroy(struct sway_container *container);
struct sway_container *container_close(struct sway_container *container);
void container_descendants(struct sway_container *root,
enum sway_container_type type,
void (*func)(struct sway_container *item, void *data), void *data);
/**
* Search a container's descendants a container based on test criteria. Returns
* the first container that passes the test.
*/
struct sway_container *container_find(struct sway_container *container,
bool (*test)(struct sway_container *view, void *data), void *data);
/**
* Finds a parent container with the given struct sway_containerype.
*/
struct sway_container *container_parent(struct sway_container *container,
enum sway_container_type type);
/**
* Find a container at the given coordinates. Returns the the surface and
* surface-local coordinates of the given layout coordinates if the container
* is a view and the view contains a surface at those coordinates.
*/
struct sway_container *container_at(struct sway_container *container,
double lx, double ly, struct wlr_surface **surface,
double *sx, double *sy);
/**
* Apply the function for each descendant of the container breadth first.
*/
void container_for_each_descendant_bfs(struct sway_container *container,
void (*f)(struct sway_container *container, void *data), void *data);
/**
* Apply the function for each child of the container depth first.
*/
void container_for_each_descendant_dfs(struct sway_container *container,
void (*f)(struct sway_container *container, void *data), void *data);
/**
* Returns true if the given container is an ancestor of this container.
*/
bool container_has_anscestor(struct sway_container *container,
struct sway_container *anscestor);
/**
* Returns true if the given container is a child descendant of this container.
*/
bool container_has_child(struct sway_container *con,
struct sway_container *child);
void container_create_notify(struct sway_container *container);
void container_damage_whole(struct sway_container *container);
bool container_reap_empty(struct sway_container *con);
struct sway_container *container_reap_empty_recursive(
struct sway_container *con);
struct sway_container *container_flatten(struct sway_container *container);
#endif

View File

@ -0,0 +1,78 @@
#ifndef _SWAY_LAYOUT_H
#define _SWAY_LAYOUT_H
#include <wlr/types/wlr_output_layout.h>
#include <wlr/render/wlr_texture.h>
#include "sway/tree/container.h"
enum movement_direction {
MOVE_LEFT,
MOVE_RIGHT,
MOVE_UP,
MOVE_DOWN,
MOVE_PARENT,
MOVE_CHILD,
};
enum resize_edge {
RESIZE_EDGE_LEFT,
RESIZE_EDGE_RIGHT,
RESIZE_EDGE_TOP,
RESIZE_EDGE_BOTTOM,
};
struct sway_container;
struct sway_root {
struct wlr_output_layout *output_layout;
struct wl_listener output_layout_change;
struct wl_list xwayland_unmanaged; // sway_xwayland_unmanaged::link
struct wlr_texture *debug_tree;
struct {
struct wl_signal new_container;
} events;
};
void layout_init(void);
void container_add_child(struct sway_container *parent,
struct sway_container *child);
struct sway_container *container_add_sibling(struct sway_container *parent,
struct sway_container *child);
struct sway_container *container_remove_child(struct sway_container *child);
struct sway_container *container_replace_child(struct sway_container *child,
struct sway_container *new_child);
struct sway_container *container_set_layout(struct sway_container *container,
enum sway_container_layout layout);
void container_move_to(struct sway_container* container,
struct sway_container* destination);
void container_move(struct sway_container *container,
enum movement_direction dir, int move_amt);
enum sway_container_layout container_get_default_layout(
struct sway_container *con);
void container_sort_workspaces(struct sway_container *output);
void arrange_windows(struct sway_container *container,
double width, double height);
struct sway_container *container_get_in_direction(struct sway_container
*container, struct sway_seat *seat, enum movement_direction dir);
struct sway_container *container_split(struct sway_container *child,
enum sway_container_layout layout);
void container_recursive_resize(struct sway_container *container,
double amount, enum resize_edge edge);
#endif

View File

186
include/sway/tree/view.h Normal file
View File

@ -0,0 +1,186 @@
#ifndef _SWAY_VIEW_H
#define _SWAY_VIEW_H
#include <wayland-server.h>
#include <wlr/types/wlr_surface.h>
#include <wlr/types/wlr_xdg_shell_v6.h>
#include <wlr/xwayland.h>
#include "sway/input/input-manager.h"
#include "sway/input/seat.h"
struct sway_container;
enum sway_view_type {
SWAY_VIEW_WL_SHELL,
SWAY_VIEW_XDG_SHELL_V6,
SWAY_VIEW_XWAYLAND,
};
enum sway_view_prop {
VIEW_PROP_TITLE,
VIEW_PROP_APP_ID,
VIEW_PROP_CLASS,
VIEW_PROP_INSTANCE,
};
struct sway_view_impl {
const char *(*get_prop)(struct sway_view *view,
enum sway_view_prop prop);
void (*configure)(struct sway_view *view, double ox, double oy, int width,
int height);
void (*set_activated)(struct sway_view *view, bool activated);
void (*for_each_surface)(struct sway_view *view,
wlr_surface_iterator_func_t iterator, void *user_data);
void (*close)(struct sway_view *view);
void (*destroy)(struct sway_view *view);
};
struct sway_view {
enum sway_view_type type;
const struct sway_view_impl *impl;
struct sway_container *swayc; // NULL for unmanaged views
struct wlr_surface *surface; // NULL for unmapped views
int width, height;
union {
struct wlr_xdg_surface_v6 *wlr_xdg_surface_v6;
struct wlr_xwayland_surface *wlr_xwayland_surface;
struct wlr_wl_shell_surface *wlr_wl_shell_surface;
};
struct {
struct wl_signal unmap;
} events;
struct wl_listener surface_new_subsurface;
struct wl_listener container_reparent;
};
struct sway_xdg_shell_v6_view {
struct sway_view view;
struct wl_listener commit;
struct wl_listener request_move;
struct wl_listener request_resize;
struct wl_listener request_maximize;
struct wl_listener new_popup;
struct wl_listener map;
struct wl_listener unmap;
struct wl_listener destroy;
int pending_width, pending_height;
};
struct sway_xwayland_view {
struct sway_view view;
struct wl_listener commit;
struct wl_listener request_move;
struct wl_listener request_resize;
struct wl_listener request_maximize;
struct wl_listener request_configure;
struct wl_listener map;
struct wl_listener unmap;
struct wl_listener destroy;
int pending_width, pending_height;
};
struct sway_xwayland_unmanaged {
struct wlr_xwayland_surface *wlr_xwayland_surface;
struct wl_list link;
int lx, ly;
struct wl_listener request_configure;
struct wl_listener commit;
struct wl_listener map;
struct wl_listener unmap;
struct wl_listener destroy;
};
struct sway_wl_shell_view {
struct sway_view view;
struct wl_listener commit;
struct wl_listener request_move;
struct wl_listener request_resize;
struct wl_listener request_maximize;
struct wl_listener destroy;
int pending_width, pending_height;
};
struct sway_view_child;
struct sway_view_child_impl {
void (*destroy)(struct sway_view_child *child);
};
/**
* A view child is a surface in the view tree, such as a subsurface or a popup.
*/
struct sway_view_child {
const struct sway_view_child_impl *impl;
struct sway_view *view;
struct wlr_surface *surface;
struct wl_listener surface_commit;
struct wl_listener surface_new_subsurface;
struct wl_listener surface_destroy;
struct wl_listener view_unmap;
};
struct sway_xdg_popup_v6 {
struct sway_view_child child;
struct wlr_xdg_surface_v6 *wlr_xdg_surface_v6;
struct wl_listener new_popup;
struct wl_listener unmap;
struct wl_listener destroy;
};
const char *view_get_title(struct sway_view *view);
const char *view_get_app_id(struct sway_view *view);
const char *view_get_class(struct sway_view *view);
const char *view_get_instance(struct sway_view *view);
void view_configure(struct sway_view *view, double ox, double oy, int width,
int height);
void view_set_activated(struct sway_view *view, bool activated);
void view_close(struct sway_view *view);
void view_damage(struct sway_view *view, bool whole);
void view_for_each_surface(struct sway_view *view,
wlr_surface_iterator_func_t iterator, void *user_data);
// view implementation
void view_init(struct sway_view *view, enum sway_view_type type,
const struct sway_view_impl *impl);
void view_destroy(struct sway_view *view);
void view_map(struct sway_view *view, struct wlr_surface *wlr_surface);
void view_unmap(struct sway_view *view);
void view_update_position(struct sway_view *view, double ox, double oy);
void view_update_size(struct sway_view *view, int width, int height);
void view_child_init(struct sway_view_child *child,
const struct sway_view_child_impl *impl, struct sway_view *view,
struct wlr_surface *surface);
void view_child_destroy(struct sway_view_child *child);
#endif

View File

@ -0,0 +1,26 @@
#ifndef _SWAY_WORKSPACE_H
#define _SWAY_WORKSPACE_H
#include "sway/tree/container.h"
extern char *prev_workspace_name;
char *workspace_next_name(const char *output_name);
bool workspace_switch(struct sway_container *workspace);
struct sway_container *workspace_by_number(const char* name);
struct sway_container *workspace_by_name(const char*);
struct sway_container *workspace_output_next(struct sway_container *current);
struct sway_container *workspace_next(struct sway_container *current);
struct sway_container *workspace_output_prev(struct sway_container *current);
struct sway_container *workspace_prev(struct sway_container *current);
bool workspace_is_visible(struct sway_container *ws);
#endif

View File

@ -1,22 +0,0 @@
#ifndef _SWAY_WORKSPACE_H
#define _SWAY_WORKSPACE_H
#include <wlc/wlc.h>
#include <unistd.h>
#include "list.h"
#include "layout.h"
extern char *prev_workspace_name;
char *workspace_next_name(const char *output_name);
swayc_t *workspace_create(const char*);
swayc_t *workspace_by_name(const char*);
swayc_t *workspace_by_number(const char*);
bool workspace_switch(swayc_t*);
swayc_t *workspace_output_next();
swayc_t *workspace_next();
swayc_t *workspace_output_prev();
swayc_t *workspace_prev();
swayc_t *workspace_for_pid(pid_t pid);
#endif

View File

@ -1,36 +1,71 @@
#ifndef _SWAYBAR_BAR_H
#define _SWAYBAR_BAR_H
#include <wayland-client.h>
#include "pool-buffer.h"
#include "client/registry.h"
#include "client/window.h"
#include "list.h"
struct swaybar_config;
struct swaybar_output;
struct swaybar_workspace;
struct bar {
struct config *config;
struct swaybar_pointer {
struct wl_pointer *pointer;
struct wl_cursor_theme *cursor_theme;
struct wl_cursor_image *cursor_image;
struct wl_surface *cursor_surface;
struct swaybar_output *current;
int x, y;
};
struct swaybar_hotspot {
struct wl_list link;
int x, y, width, height;
void (*callback)(struct swaybar_output *output,
int x, int y, uint32_t button, void *data);
void (*destroy)(void *data);
void *data;
};
struct swaybar {
struct wl_display *display;
struct wl_compositor *compositor;
struct zwlr_layer_shell_v1 *layer_shell;
struct wl_shm *shm;
struct wl_seat *seat;
struct swaybar_config *config;
struct swaybar_output *focused_output;
struct swaybar_pointer pointer;
struct status_line *status;
list_t *outputs;
struct output *focused_output;
int ipc_event_socketfd;
int ipc_socketfd;
int status_read_fd;
int status_write_fd;
pid_t status_command_pid;
struct wl_list outputs;
};
struct output {
struct window *window;
struct registry *registry;
list_t *workspaces;
#ifdef ENABLE_TRAY
list_t *items;
#endif
struct swaybar_output {
struct wl_list link;
struct swaybar *bar;
struct wl_output *output;
struct wl_surface *surface;
struct zwlr_layer_surface_v1 *layer_surface;
uint32_t wl_name;
struct wl_list workspaces;
struct wl_list hotspots;
char *name;
int idx;
size_t index;
bool focused;
uint32_t width, height;
int32_t scale;
struct pool_buffer buffers[2];
struct pool_buffer *current_buffer;
};
struct workspace {
struct swaybar_workspace {
struct wl_list link;
int num;
char *name;
bool focused;
@ -38,35 +73,10 @@ struct workspace {
bool urgent;
};
/** Global bar state */
extern struct bar swaybar;
void bar_setup(struct swaybar *bar,
const char *socket_path,
const char *bar_id);
void bar_run(struct swaybar *bar);
void bar_teardown(struct swaybar *bar);
/** True if sway needs to render */
extern bool dirty;
/**
* Setup bar.
*/
void bar_setup(struct bar *bar, const char *socket_path, const char *bar_id);
/**
* Create new output struct from name.
*/
struct output *new_output(const char *name);
/**
* Bar mainloop.
*/
void bar_run(struct bar *bar);
/**
* free workspace list.
*/
void free_workspaces(list_t *workspaces);
/**
* Teardown bar.
*/
void bar_teardown(struct bar *bar);
#endif /* _SWAYBAR_BAR_H */
#endif

View File

@ -1,49 +1,36 @@
#ifndef _SWAYBAR_CONFIG_H
#define _SWAYBAR_CONFIG_H
#include <stdint.h>
#include <stdbool.h>
#include "list.h"
#include <stdint.h>
#include <wayland-client.h>
#include "util.h"
/**
* Colors for a box with background, border and text colors.
*/
struct box_colors {
uint32_t border;
uint32_t background;
uint32_t text;
};
/**
* Swaybar config.
*/
struct config {
struct config_output {
struct wl_list link;
char *name;
size_t index;
};
struct swaybar_config {
char *status_command;
bool pango_markup;
uint32_t position;
uint32_t position; // zwlr_layer_surface_v1_anchor
char *font;
char *sep_symbol;
char *mode;
bool mode_pango_markup;
bool strip_workspace_numbers;
bool binding_mode_indicator;
bool wrap_scroll;
bool workspace_buttons;
struct wl_list outputs;
bool all_outputs;
list_t *outputs;
#ifdef ENABLE_TRAY
// Tray
char *tray_output;
char *icon_theme;
uint32_t tray_padding;
uint32_t activate_button;
uint32_t context_button;
uint32_t secondary_button;
#endif
int height;
struct {
@ -63,24 +50,8 @@ struct config {
} colors;
};
/**
* Parse position top|bottom|left|right.
*/
struct swaybar_config *init_config();
void free_config(struct swaybar_config *config);
uint32_t parse_position(const char *position);
/**
* Parse font.
*/
char *parse_font(const char *font);
/**
* Initialize default sway config.
*/
struct config *init_config();
/**
* Free config struct.
*/
void free_config(struct config *config);
#endif /* _SWAYBAR_CONFIG_H */
#endif

View File

@ -1,6 +1,5 @@
#ifndef _SWAYBAR_EVENT_LOOP_H
#define _SWAYBAR_EVENT_LOOP_H
#include <stdbool.h>
#include <time.h>
@ -23,4 +22,5 @@ bool remove_timer(timer_t timer);
void event_loop_poll();
void init_event_loop();
#endif /*_SWAYBAR_EVENT_LOOP_H */
#endif

View File

@ -1,23 +1,11 @@
#ifndef _SWAYBAR_IPC_H
#define _SWAYBAR_IPC_H
#include <stdbool.h>
#include "swaybar/bar.h"
#include "bar.h"
/**
* Initialize ipc connection to sway and get sway state, outputs, bar_config.
*/
void ipc_bar_init(struct bar *bar, const char *bar_id);
/**
* Handle ipc event from sway.
*/
bool handle_ipc_event(struct bar *bar);
/**
* Send workspace command to sway
*/
void ipc_send_workspace_command(const char *workspace_name);
#endif /* _SWAYBAR_IPC_H */
void ipc_initialize(struct swaybar *bar, const char *bar_id);
bool handle_ipc_readable(struct swaybar *bar);
void ipc_get_workspaces(struct swaybar *bar);
void ipc_send_workspace_command(struct swaybar *bar, const char *ws);
#endif

View File

@ -1,22 +1,10 @@
#ifndef _SWAYBAR_RENDER_H
#define _SWAYBAR_RENDER_H
#include "config.h"
#include "bar.h"
struct swaybar;
struct swaybar_output;
struct swaybar_config;
/**
* Render swaybar.
*/
void render(struct output *output, struct config *config, struct status_line *line);
void render_frame(struct swaybar *bar, struct swaybar_output *output);
/**
* Set window height and modify internal spacing accordingly.
*/
void set_window_height(struct window *window, int height);
/**
* Compute the size of a workspace name
*/
void workspace_button_size(struct window *window, const char *workspace_name, int *width, int *height);
#endif /* _SWAYBAR_RENDER_H */
#endif

View File

@ -1,25 +1,44 @@
#ifndef _SWAYBAR_STATUS_LINE_H
#define _SWAYBAR_STATUS_LINE_H
#include <stdint.h>
#include <stdio.h>
#include <stdbool.h>
#include "list.h"
#include "bar.h"
typedef enum {UNDEF, TEXT, I3BAR} command_protocol;
struct status_line {
list_t *block_line;
const char *text_line;
command_protocol protocol;
bool click_events;
enum status_protocol {
PROTOCOL_UNDEF,
PROTOCOL_ERROR,
PROTOCOL_TEXT,
PROTOCOL_I3BAR,
};
struct status_block {
struct text_protocol_state {
char *buffer;
size_t buffer_size;
};
enum json_node_type {
JSON_NODE_UNKNOWN,
JSON_NODE_ARRAY,
JSON_NODE_STRING,
};
struct i3bar_protocol_state {
bool click_events;
char *buffer;
size_t buffer_size;
size_t buffer_index;
const char *current_node;
bool escape;
size_t depth;
enum json_node_type nodes[16];
};
struct i3bar_block {
struct wl_list link;
char *full_text, *short_text, *align;
bool urgent;
uint32_t color;
uint32_t *color;
int min_width;
char *name, *instance;
bool separator;
@ -32,30 +51,27 @@ struct status_block {
int border_bottom;
int border_left;
int border_right;
// Set during rendering
int x;
int width;
};
/**
* Initialize status line struct.
*/
struct status_line *init_status_line();
struct status_line {
pid_t pid;
int read_fd, write_fd;
FILE *read, *write;
/**
* handle status line activity.
*/
bool handle_status_line(struct bar *bar);
enum status_protocol protocol;
const char *text;
struct wl_list blocks; // i3bar_block::link
/**
* Handle mouse clicks.
*/
bool status_line_mouse_event(struct bar *bar, int x, int y, uint32_t button);
struct text_protocol_state text_state;
struct i3bar_protocol_state i3bar_state;
};
/**
* Free status line struct.
*/
void free_status_line(struct status_line *line);
struct status_line *status_line_init(char *cmd);
void status_error(struct status_line *status, const char *text);
bool status_handle_readable(struct status_line *status);
void status_line_free(struct status_line *status);
bool i3bar_handle_readable(struct status_line *status);
void i3bar_block_send_click(struct status_line *status,
struct i3bar_block *block, int x, int y, uint32_t button);
#endif /* _SWAYBAR_STATUS_LINE_H */
#endif

38
include/swaylock/seat.h Normal file
View File

@ -0,0 +1,38 @@
#ifndef _SWAYLOCK_SEAT_H
#define _SWAYLOCK_SEAT_H
#include <xkbcommon/xkbcommon.h>
enum mod_bit {
MOD_SHIFT = 1<<0,
MOD_CAPS = 1<<1,
MOD_CTRL = 1<<2,
MOD_ALT = 1<<3,
MOD_MOD2 = 1<<4,
MOD_MOD3 = 1<<5,
MOD_LOGO = 1<<6,
MOD_MOD5 = 1<<7,
};
enum mask {
MASK_SHIFT,
MASK_CAPS,
MASK_CTRL,
MASK_ALT,
MASK_MOD2,
MASK_MOD3,
MASK_LOGO,
MASK_MOD5,
MASK_LAST
};
struct swaylock_xkb {
uint32_t modifiers;
struct xkb_state *state;
struct xkb_context *context;
struct xkb_keymap *keymap;
xkb_mod_mask_t masks[MASK_LAST];
};
extern const struct wl_seat_listener seat_listener;
#endif

View File

@ -1,66 +1,64 @@
#ifndef _SWAYLOCK_H
#define _SWAYLOCK_H
#include "client/cairo.h"
enum scaling_mode {
SCALING_MODE_STRETCH,
SCALING_MODE_FILL,
SCALING_MODE_FIT,
SCALING_MODE_CENTER,
SCALING_MODE_TILE,
};
#include <stdbool.h>
#include <stdint.h>
#include <wayland-client.h>
#include "background-image.h"
#include "cairo.h"
#include "pool-buffer.h"
#include "swaylock/seat.h"
#include "wlr-layer-shell-unstable-v1-client-protocol.h"
enum auth_state {
AUTH_STATE_IDLE,
AUTH_STATE_INPUT,
AUTH_STATE_BACKSPACE,
AUTH_STATE_VALIDATING,
AUTH_STATE_INVALID,
AUTH_STATE_IDLE,
AUTH_STATE_INPUT,
AUTH_STATE_BACKSPACE,
AUTH_STATE_VALIDATING,
AUTH_STATE_INVALID,
};
enum line_source {
LINE_SOURCE_DEFAULT,
LINE_SOURCE_RING,
LINE_SOURCE_INSIDE,
};
struct render_data {
list_t *surfaces;
// Output specific images
cairo_surface_t **images;
// OR one image for all outputs:
cairo_surface_t *image;
int num_images;
int color_set;
struct swaylock_args {
uint32_t color;
enum scaling_mode scaling_mode;
enum background_mode mode;
bool show_indicator;
};
struct swaylock_password {
size_t size;
size_t len;
char *buffer;
};
struct swaylock_state {
struct wl_display *display;
struct wl_compositor *compositor;
struct zwlr_layer_shell_v1 *layer_shell;
struct zwlr_input_inhibit_manager_v1 *input_inhibit_manager;
struct wl_shm *shm;
struct wl_list surfaces;
struct swaylock_args args;
struct swaylock_password password;
struct swaylock_xkb xkb;
enum auth_state auth_state;
bool run_display;
};
struct lock_colors {
uint32_t inner_ring;
uint32_t outer_ring;
struct swaylock_surface {
cairo_surface_t *image;
struct swaylock_state *state;
struct wl_output *output;
struct wl_surface *surface;
struct zwlr_layer_surface_v1 *layer_surface;
struct pool_buffer buffers[2];
struct pool_buffer *current_buffer;
uint32_t width, height;
int32_t scale;
struct wl_list link;
};
struct lock_config {
char *font;
struct {
uint32_t text;
uint32_t line;
uint32_t separator;
uint32_t input_cursor;
uint32_t backspace_cursor;
struct lock_colors normal;
struct lock_colors validating;
struct lock_colors invalid;
} colors;
int radius;
int thickness;
};
void render(struct render_data* render_data, struct lock_config *config);
void swaylock_handle_key(struct swaylock_state *state,
xkb_keysym_t keysym, uint32_t codepoint);
void render_frame(struct swaylock_surface *surface);
void render_frames(struct swaylock_state *state);
#endif

33
include/unicode.h Normal file
View File

@ -0,0 +1,33 @@
#ifndef _SWAY_UNICODE_H
#define _SWAY_UNICODE_H
#include <stddef.h>
#include <stdint.h>
// Technically UTF-8 supports up to 6 byte codepoints, but Unicode itself
// doesn't really bother with more than 4.
#define UTF8_MAX_SIZE 4
#define UTF8_INVALID 0x80
/**
* Grabs the next UTF-8 character and advances the string pointer
*/
uint32_t utf8_decode(const char **str);
/**
* Encodes a character as UTF-8 and returns the length of that character.
*/
size_t utf8_encode(char *str, uint32_t ch);
/**
* Returns the size of the next UTF-8 character
*/
int utf8_size(const char *str);
/**
* Returns the size of a UTF-8 character
*/
size_t utf8_chsize(uint32_t ch);
#endif

171
meson.build Normal file
View File

@ -0,0 +1,171 @@
project(
'sway',
'c',
license: 'MIT',
default_options: [
'c_std=c11',
'warning_level=2',
'werror=true',
],
)
add_project_arguments('-Wno-unused-parameter', language: 'c')
add_project_arguments('-Wno-unused-function', language: 'c')
add_project_arguments('-Wno-unused-result', language: 'c')
cc = meson.get_compiler('c')
is_freebsd = host_machine.system().startswith('freebsd')
datadir = get_option('datadir')
sysconfdir = get_option('sysconfdir')
prefix = get_option('prefix')
jsonc = dependency('json-c', version: '>=0.13')
pcre = dependency('libpcre')
wlroots = dependency('wlroots', fallback: ['wlroots', 'wlroots'])
wayland_server = dependency('wayland-server')
wayland_client = dependency('wayland-client')
wayland_cursor = dependency('wayland-cursor')
wayland_egl = dependency('wayland-egl')
wayland_protos = dependency('wayland-protocols')
xkbcommon = dependency('xkbcommon')
cairo = dependency('cairo')
pango = dependency('pango')
pangocairo = dependency('pangocairo')
gdk_pixbuf = dependency('gdk-pixbuf-2.0', required: false)
pixman = dependency('pixman-1')
libcap = dependency('libcap')
libinput = dependency('libinput', version: '>=1.6.0')
libpam = cc.find_library('libpam')
math = cc.find_library('m')
rt = cc.find_library('rt')
git = find_program('git', required: false)
a2x = find_program('a2x', required: false)
conf_data = configuration_data()
if gdk_pixbuf.found()
conf_data.set('HAVE_GDK_PIXBUF', true)
endif
if a2x.found()
mandir = get_option('mandir')
man_files = [
'sway/sway.1.txt',
'sway/sway.5.txt',
'sway/sway-bar.5.txt',
'sway/sway-input.5.txt',
'sway/sway-security.7.txt',
'swaymsg/swaymsg.1.txt',
]
foreach filename : man_files
topic = filename.split('.')[-3].split('/')[-1]
section = filename.split('.')[-2]
custom_target(
'man-@0@-@1@'.format(topic, section),
input: filename,
output: '@BASENAME@',
command: [
a2x,
'--no-xmllint',
'--doctype', 'manpage',
'--format', 'manpage',
'--destination-dir', meson.current_build_dir(),
'@INPUT@'
],
install: true,
install_dir: '@0@/man@1@'.format(mandir, section)
)
endforeach
endif
add_project_arguments('-DSYSCONFDIR="/@0@"'.format(sysconfdir), language : 'c')
version = get_option('sway_version')
if version != ''
version = '"@0@"'.format(version)
else
if not git.found()
error('git is required to make the version string')
endif
git_commit_hash = run_command([git.path(), 'describe', '--always', '--tags']).stdout().strip()
git_branch = run_command([git.path(), 'rev-parse', '--abbrev-ref', 'HEAD']).stdout().strip()
version = '"@0@ (" __DATE__ ", branch \'@1@\')"'.format(git_commit_hash, git_branch)
endif
add_project_arguments('-DSWAY_VERSION=@0@'.format(version), language: 'c')
sway_inc = include_directories('include')
subdir('include')
subdir('protocols')
subdir('common')
subdir('sway')
subdir('swaymsg')
subdir('client')
subdir('swaybg')
subdir('swaybar')
subdir('swaylock')
config = configuration_data()
config.set('sysconfdir', join_paths(prefix, sysconfdir))
config.set('datadir', join_paths(prefix, datadir))
config.set('prefix', prefix)
configure_file(
configuration: config,
input: 'config.in',
output: '@BASENAME@',
install_dir: sysconfdir + '/sway'
)
if is_freebsd
configure_file(
configuration: config,
input: 'security.d/10-freebsd.in',
output: '@BASENAME@',
install_dir: sysconfdir + '/sway/security.d'
)
else
configure_file(
configuration: config,
input: 'security.d/00-defaults.in',
output: '@BASENAME@',
install_dir: sysconfdir + '/sway/security.d'
)
endif
install_data(
'sway.desktop',
install_dir: datadir + '/wayland-sessions'
)
if (get_option('default_wallpaper'))
wallpaper_files = files(
'assets/Sway_Wallpaper_Blue_768x1024.png',
'assets/Sway_Wallpaper_Blue_768x1024_Portrait.png',
'assets/Sway_Wallpaper_Blue_1136x640.png',
'assets/Sway_Wallpaper_Blue_1136x640_Portrait.png',
'assets/Sway_Wallpaper_Blue_1366x768.png',
'assets/Sway_Wallpaper_Blue_1920x1080.png',
'assets/Sway_Wallpaper_Blue_2048x1536.png',
'assets/Sway_Wallpaper_Blue_2048x1536_Portrait.png',
)
wallpaper_install_dir = datadir + '/backgrounds/sway'
install_data(wallpaper_files, install_dir: wallpaper_install_dir)
endif
if (get_option('zsh_completions'))
zsh_files = files(
'completions/zsh/_sway',
'completions/zsh/_swaygrab',
'completions/zsh/_swaylock',
'completions/zsh/_swaymsg',
)
zsh_install_dir = datadir + '/zsh/site-functions'
install_data(zsh_files, install_dir: zsh_install_dir)
endif

3
meson_options.txt Normal file
View File

@ -0,0 +1,3 @@
option('sway_version', type : 'string', description: 'The version string reported in `sway --version`.')
option('default_wallpaper', type: 'boolean', value: true, description: 'Install the default wallpaper.')
option('zsh_completions', type: 'boolean', value: true, description: 'Install zsh shell completions.')

View File

@ -1,46 +0,0 @@
include(Wayland)
WAYLAND_ADD_PROTOCOL_CLIENT(proto-client-xdg-shell
xdg-shell.xml
xdg-shell
)
WAYLAND_ADD_PROTOCOL_CLIENT(proto-client-desktop-shell
desktop-shell.xml
desktop-shell
)
WAYLAND_ADD_PROTOCOL_SERVER(proto-server-desktop-shell
desktop-shell.xml
desktop-shell
)
WAYLAND_ADD_PROTOCOL_CLIENT(proto-client-swaylock
swaylock.xml
swaylock
)
WAYLAND_ADD_PROTOCOL_SERVER(proto-server-swaylock
swaylock.xml
swaylock
)
WAYLAND_ADD_PROTOCOL_SERVER(proto-server-gamma-control
gamma-control.xml
gamma-control
)
WAYLAND_ADD_PROTOCOL_SERVER(proto-server-server-decoration
server-decoration.xml
server-decoration
)
add_library(sway-protocols STATIC
${proto-client-xdg-shell}
${proto-client-desktop-shell}
${proto-server-desktop-shell}
${proto-client-swaylock}
${proto-server-swaylock}
${proto-server-gamma-control}
${proto-server-server-decoration}
)
set(PROTOCOLS_INCLUDE_DIRS ${CMAKE_BINARY_DIR}/protocols PARENT_SCOPE)
INCLUDE_DIRECTORIES(${WAYLAND_INCLUDE_DIR} ${XKBCOMMON_INCLUDE_DIRS})

View File

@ -1,138 +0,0 @@
<protocol name="desktop">
<interface name="desktop_shell" version="3">
<description summary="create desktop widgets and helpers">
Traditional user interfaces can rely on this interface to define the
foundations of typical desktops. Currently it's possible to set up
background, panels and locking surfaces.
</description>
<request name="set_background">
<arg name="output" type="object" interface="wl_output"/>
<arg name="surface" type="object" interface="wl_surface"/>
</request>
<request name="set_panel">
<arg name="output" type="object" interface="wl_output"/>
<arg name="surface" type="object" interface="wl_surface"/>
</request>
<request name="set_lock_surface">
<arg name="surface" type="object" interface="wl_surface"/>
</request>
<request name="unlock"/>
<request name="set_grab_surface">
<description summary="set grab surface">
The surface set by this request will receive a fake
pointer.enter event during grabs at position 0, 0 and is
expected to set an appropriate cursor image as described by
the grab_cursor event sent just before the enter event.
</description>
<arg name="surface" type="object" interface="wl_surface"/>
</request>
<!-- We'll fold most of wl_shell into this interface and then
they'll share the configure event. -->
<event name="configure">
<arg name="edges" type="uint"/>
<arg name="surface" type="object" interface="wl_surface"/>
<arg name="width" type="int"/>
<arg name="height" type="int"/>
</event>
<event name="prepare_lock_surface">
<description summary="tell the client to create, set the lock surface">
Tell the client we want it to create and set the lock surface, which is
a GUI asking the user to unlock the screen. The lock surface is
announced with 'set_lock_surface'. Whether or not the client actually
implements locking, it MUST send 'unlock' request to let the normal
desktop resume.
</description>
</event>
<event name="grab_cursor">
<description summary="tell client what cursor to show during a grab">
This event will be sent immediately before a fake enter event on the
grab surface.
</description>
<arg name="cursor" type="uint"/>
</event>
<enum name="cursor">
<entry name="none" value="0"/>
<entry name="resize_top" value="1"/>
<entry name="resize_bottom" value="2"/>
<entry name="arrow" value="3"/>
<entry name="resize_left" value="4"/>
<entry name="resize_top_left" value="5"/>
<entry name="resize_bottom_left" value="6"/>
<entry name="move" value="7"/>
<entry name="resize_right" value="8"/>
<entry name="resize_top_right" value="9"/>
<entry name="resize_bottom_right" value="10"/>
<entry name="busy" value="11"/>
</enum>
<!-- Version 2 additions -->
<request name="desktop_ready" since="2">
<description summary="desktop is ready to be shown">
Tell the server, that enough desktop elements have been drawn
to make the desktop look ready for use. During start-up, the
server can wait for this request with a black screen before
starting to fade in the desktop, for instance. If the client
parts of a desktop take a long time to initialize, we avoid
showing temporary garbage.
</description>
</request>
<!-- Version 3 additions -->
<enum name="panel_position">
<entry name="top" value="0"/>
<entry name="bottom" value="1"/>
<entry name="left" value="2"/>
<entry name="right" value="3"/>
</enum>
<enum name="error">
<entry name="invalid_argument" value="0"
summary="an invalid argument was provided in a request"/>
</enum>
<request name="set_panel_position" since="3">
<description summary="set panel position">
Tell the shell which side of the screen the panel is
located. This is so that new windows do not overlap the panel
and maximized windows maximize properly.
</description>
<arg name="position" type="uint"/>
</request>
</interface>
<interface name="screensaver" version="1">
<description summary="interface for implementing screensavers">
Only one client can bind this interface at a time.
</description>
<request name="set_surface">
<description summary="set the surface type as a screensaver">
A screensaver surface is normally hidden, and only visible after an
idle timeout.
</description>
<arg name="surface" type="object" interface="wl_surface"/>
<arg name="output" type="object" interface="wl_output"/>
</request>
</interface>
</protocol>

View File

@ -1,57 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<protocol name="gamma_control">
<copyright>
Copyright © 2015 Giulio camuffo
Permission to use, copy, modify, distribute, and sell this
software and its documentation for any purpose is hereby granted
without fee, provided that the above copyright notice appear in
all copies and that both that copyright notice and this permission
notice appear in supporting documentation, and that the name of
the copyright holders not be used in advertising or publicity
pertaining to distribution of the software without specific,
written prior permission. The copyright holders make no
representations about the suitability of this software for any
purpose. It is provided "as is" without express or implied
warranty.
THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
THIS SOFTWARE.
</copyright>
<interface name="gamma_control_manager" version="1">
<request name="destroy" type="destructor"/>
<request name="get_gamma_control">
<arg name="id" type="new_id" interface="gamma_control"/>
<arg name="output" type="object" interface="wl_output"/>
</request>
</interface>
<interface name="gamma_control" version="1">
<enum name="error">
<entry name="invalid_gamma" value="0"/>
</enum>
<request name="destroy" type="destructor"/>
<request name="set_gamma">
<arg name="red" type="array"/>
<arg name="green" type="array"/>
<arg name="blue" type="array"/>
</request>
<request name="reset_gamma"/>
<event name="gamma_size">
<arg name="size" type="uint"/>
</event>
</interface>
</protocol>

73
protocols/meson.build Normal file
View File

@ -0,0 +1,73 @@
wl_protocol_dir = wayland_protos.get_pkgconfig_variable('pkgdatadir')
wayland_scanner = find_program('wayland-scanner')
wayland_scanner_code = generator(
wayland_scanner,
output: '@BASENAME@-protocol.c',
arguments: ['code', '@INPUT@', '@OUTPUT@'],
)
wayland_scanner_client = generator(
wayland_scanner,
output: '@BASENAME@-client-protocol.h',
arguments: ['client-header', '@INPUT@', '@OUTPUT@'],
)
wayland_scanner_server = generator(
wayland_scanner,
output: '@BASENAME@-protocol.h',
arguments: ['server-header', '@INPUT@', '@OUTPUT@'],
)
client_protocols = [
[wl_protocol_dir, 'stable/xdg-shell/xdg-shell.xml'],
['wlr-layer-shell-unstable-v1.xml'],
['wlr-input-inhibitor-unstable-v1.xml']
]
server_protocols = [
[wl_protocol_dir, 'unstable/xdg-shell/xdg-shell-unstable-v6.xml'],
['wlr-layer-shell-unstable-v1.xml'],
['wlr-input-inhibitor-unstable-v1.xml']
]
client_protos_src = []
client_protos_headers = []
server_protos_src = []
server_protos_headers = []
foreach p : client_protocols
xml = join_paths(p)
client_protos_src += wayland_scanner_code.process(xml)
client_protos_headers += wayland_scanner_client.process(xml)
endforeach
foreach p : server_protocols
xml = join_paths(p)
server_protos_src += wayland_scanner_code.process(xml)
server_protos_headers += wayland_scanner_server.process(xml)
endforeach
lib_client_protos = static_library(
'client_protos',
client_protos_src + client_protos_headers,
dependencies: [wayland_client]
) # for the include directory
client_protos = declare_dependency(
link_with: lib_client_protos,
sources: client_protos_headers,
)
lib_server_protos = static_library(
'server_protos',
server_protos_src + server_protos_headers,
dependencies: [wayland_client]
) # for the include directory
server_protos = declare_dependency(
link_with: lib_server_protos,
sources: server_protos_headers,
)

View File

@ -1,94 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<protocol name="server_decoration">
<copyright><![CDATA[
Copyright (C) 2015 Martin Gräßlin
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 2.1 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
]]></copyright>
<interface name="org_kde_kwin_server_decoration_manager" version="1">
<description summary="Server side window decoration manager">
This interface allows to coordinate whether the server should create
a server-side window decoration around a wl_surface representing a
shell surface (wl_shell_surface or similar). By announcing support
for this interface the server indicates that it supports server
side decorations.
</description>
<request name="create">
<description summary="Create a server-side decoration object for a given surface">
When a client creates a server-side decoration object it indicates
that it supports the protocol. The client is supposed to tell the
server whether it wants server-side decorations or will provide
client-side decorations.
If the client does not create a server-side decoration object for
a surface the server interprets this as lack of support for this
protocol and considers it as client-side decorated. Nevertheless a
client-side decorated surface should use this protocol to indicate
to the server that it does not want a server-side deco.
</description>
<arg name="id" type="new_id" interface="org_kde_kwin_server_decoration"/>
<arg name="surface" type="object" interface="wl_surface"/>
</request>
<enum name="mode">
<description summary="Possible values to use in request_mode and the event mode."/>
<entry name="None" value="0" summary="Undecorated: The surface is not decorated at all, neither server nor client-side. An example is a popup surface which should not be decorated."/>
<entry name="Client" value="1" summary="Client-side decoration: The decoration is part of the surface and the client."/>
<entry name="Server" value="2" summary="Server-side decoration: The server embeds the surface into a decoration frame."/>
</enum>
<event name="default_mode">
<description summary="The default mode used on the server">
This event is emitted directly after binding the interface. It contains
the default mode for the decoration. When a new server decoration object
is created this new object will be in the default mode until the first
request_mode is requested.
The server may change the default mode at any time.
</description>
<arg name="mode" type="uint" summary="The default decoration mode applied to newly created server decorations."/>
</event>
</interface>
<interface name="org_kde_kwin_server_decoration" version="1">
<request name="release" type="destructor">
<description summary="release the server decoration object"/>
</request>
<enum name="mode">
<description summary="Possible values to use in request_mode and the event mode."/>
<entry name="None" value="0" summary="Undecorated: The surface is not decorated at all, neither server nor client-side. An example is a popup surface which should not be decorated."/>
<entry name="Client" value="1" summary="Client-side decoration: The decoration is part of the surface and the client."/>
<entry name="Server" value="2" summary="Server-side decoration: The server embeds the surface into a decoration frame."/>
</enum>
<request name="request_mode">
<description summary="The decoration mode the surface wants to use."/>
<arg name="mode" type="uint" summary="The mode this surface wants to use."/>
</request>
<event name="mode">
<description summary="The new decoration mode applied by the server">
This event is emitted directly after the decoration is created and
represents the base decoration policy by the server. E.g. a server
which wants all surfaces to be client-side decorated will send Client,
a server which wants server-side decoration will send Server.
The client can request a different mode through the decoration request.
The server will acknowledge this by another event with the same mode. So
even if a server prefers server-side decoration it's possible to force a
client-side decoration.
The server may emit this event at any time. In this case the client can
again request a different mode. It's the responsibility of the server to
prevent a feedback loop.
</description>
<arg name="mode" type="uint" summary="The decoration mode applied to the surface by the server."/>
</event>
</interface>
</protocol>

Some files were not shown because too many files have changed in this diff Show More