Commit Graph

48 Commits

Author SHA1 Message Date
Peter Hutterer b1bc4a68b0 Add zalloc(size_t) allocator function
Same as calloc(1, len).
2013-08-08 13:46:13 -07:00
Kristian Høgsberg c0bf8173dd shared: Add out-of-memory handling to theme_create() 2013-07-25 15:54:20 -07:00
Quentin Glidic d2d70f2aeb tests: Move config-parser.test to tests/
Signed-off-by: Quentin Glidic <sardemff7+git@sardemff7.net>
2013-07-08 18:14:04 -04:00
Quentin Glidic 6e2c12496b shared: Export configuration functions
Signed-off-by: Quentin Glidic <sardemff7+git@sardemff7.net>
2013-07-03 18:28:59 -04:00
Pekka Paalanen d7bc6351f8 shared: build fix for config-parser test
One more wayland-util.h not found issue, triggered by having libwayland
installed to a custom prefix.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2012-02-07 17:47:01 -05:00
Daniel Stone c228e23b05 configure.ac: Enable AC_USE_SYSTEM_EXTENSIONS
AC_USE_SYSTEM_EXTENSIONS enables _XOPEN_SOURCE, _GNU_SOURCE and similar
macros to expose the largest extent of functionality supported by the
underlying system.  This is required since these macros are often
limiting rather than merely additive, e.g. _XOPEN_SOURCE will actually
on some systems hide declarations which are not part of the X/Open spec.

Since this goes into config.h rather than the command line, ensure all
source is consistently including config.h before anything else,
including system libraries.  This doesn't need to be guarded by a
HAVE_CONFIG_H ifdef, which was only ever a hangover from the X.Org
modular transition.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>

[pq: rebased and converted more files]
2013-06-05 01:16:34 -04:00
Pekka Paalanen ab5dd94c93 shared: fix build of libshared-cairo
Another case of missing wayland-util.h, as we didn't pass any libwayland
CFLAGS. This is triggerable on a system, where libwayland is installed
in a custom prefix, and pixman, cairo, libpng, and webp are either
not installed or are installed in the standard path.

COMPOSITOR_CFLAGS contains more than just the libwayland CFLAGS, though.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2013-06-04 23:16:49 -04:00
Kristian Høgsberg 82189f7abd config-parser: Add tests for expect behavuor on NULL configs and sections 2013-05-28 15:34:46 -04:00
Mun Gwan-gyeong 7732540f71 config-parser: Avoid null dereference when exiting. (case: weston starts without config file.)
backtrace:
 (gdb) bt
 #0  0xb7704424 in __kernel_vsyscall ()
 #1  0xb757ddde in raise (sig=5) at ../nptl/sysdeps/unix/sysv/linux/pt-raise.c:42
 #2  <signal handler called>
 #3  weston_config_destroy (config=0x0) at config-parser.c:508
 #4  0xb75cbc0e in x11_destroy (ec=0x93506b0) at compositor-x11.c:1473
 #5  0x0804e0e9 in main (argc=1, argv=0xbffe5354) at compositor.c:3337
2013-05-28 15:30:27 -04:00
Mun Gwan-gyeong 151a52834e config-parser: Avoid null dereference when handling config-parser ( when weston starts without config file. )
backtrace:
 (gdb) bt
 #0  weston_config_next_section (config=0x0, section=0xbfb2b608, name=0xbfb2b618) at config-parser.c:485
 #1  0xb75b1371 in x11_compositor_create (config=0x1, argv=0xbfb2ba44, argc=<optimized out>, use_pixman=0, no_input=0, fullscreen=0, display=0xb75b55f9)
    at compositor-x11.c:1582
 #2  backend_init (display=0x8354490, argc=0xbfb2b9b0, argv=0xbfb2ba44, config=0x0) at compositor-x11.c:1674
 #3  0x0804df7b in main (argc=1, argv=0xbfb2ba44) at compositor.c:3289
2013-05-28 15:30:14 -04:00
Kristian Høgsberg f73f316248 config-parser: Add section iterator API
The X backend needs to iterate through all outputs.
2013-05-26 20:50:53 -04:00
Mun Gwan-gyeong 72a3ab7b85 config-parser: Avoid null dereference when handling config-parser
backtrace:
 (gdb) bt
 #0  weston_config_get_section (config=0x0, section=0x8062f31 "keyboard", key=0x0, value=0x0)
     at config-parser.c:265
 #1  0x080535a1 in weston_compositor_init (ec=0x905b690, display=0x9056490, argc=0xbf8bd2f0,
     argv=0xbf8bd384, config_fd=-1) at compositor.c:2819
 #2  0xb75d72bb in x11_compositor_create (config_fd=-1, argv=0xbf8bd384, argc=<optimized out>,
     use_pixman=0, no_input=0, fullscreen=0, display=0x9056490) at compositor-x11.c:1527
 #3  backend_init (display=0x9056490, argc=0xbf8bd2f0, argv=0xbf8bd384, config_fd=-1)
     at compositor-x11.c:1746
2013-05-26 20:07:47 -04:00
Mun Gwan-gyeong d664196cfb config-parser-test: fix compile error
Add COMPOSITOR_CFLAGS to Makefile.am
2013-05-26 20:04:28 -04:00
Kristian Høgsberg 732747114a Add new config parser
The current config parser, parses the ini file and pulls out the values
specified by the struct config_section passed to parse_config_file() and
then throw the rest away.  This means that every place we want to get
info out of the ini file, we have to parse the whole thing again.  It's not
a big overhead, but it's also not a convenient API.

This patch adds a parser that parses the ini file to a data structure and
puts that in weston_compositor->config along with API to query comfig
keys from the data structure.  The old parser is still available, but
we'll transition to the new approach over the next few commits.
2013-05-23 21:25:42 -04:00
Ossama Othman a50e6e4c50 config-parser: Honor XDG_CONFIG_DIRS
This set of changes adds support for searching for a given config file
in the directories listed in $XDG_CONFIG_DIRS if it wasn't found in
$XDG_CONFIG_HOME or ~/.config.  This allows packages to install custom
config files in /etc/xdg/weston, for example, thus allowing them to
avoid dealing with home directories.

To avoid a TOCTOU race the config file is actually open()ed during the
search.  Its file descriptor is returned and stored in the compositor
for later use when performing subsequent config file parses.

Signed-off-by: Ossama Othman <ossama.othman@intel.com>
2013-05-14 14:36:37 -04:00
Armin K eb3c73f288 Fix compiler warnings
This prevents compiler warnings when using libpng 1.6 and GCC 4.8
2013-04-03 20:40:44 -04:00
Giulio Camuffo 7fe01b18d8 sdk: be C++ friendly
This renames the weston_surface's private member to configure_private
and externs "C" the headers of the SDK.
2013-03-28 14:03:58 -04:00
Kristian Høgsberg 4172f668e7 Pass argc pointer to parse_options()
This lets us keep argc up to date as the backend picks out arguments
from the argv array.
2013-02-20 15:27:49 -05:00
Vasily Khoruzhick 1bbf372e31 matrix: track transform type
Introduce several matrix transform types and track type for matrix.
Could be usefull for activating some fastpath that depends on some
transform type.

Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com>
2013-01-28 16:10:03 -05:00
Kristian Høgsberg 3c2360ff9d Add new shared/image-loader.h to separate include dependencies
Before, cairo-util.h would combine pixman and cairo includes.  X11 and
Wayland compositors uses this to load an image as a pixman_image_t but are
forced to include cairo headers.  Clients use load_cairo_surface to
load images as cairo_surface_t's, but are forced to include pixman.h.

We move the load_image pixman prototype to its own header, so compositors
can get at the pixman prototype without including cairo.h and clients
can include the cairo based function without including pixman.h.
2013-01-28 16:02:04 -05:00
Kristian Høgsberg 3a8d3f2e98 Link matrix.c into weston again
We want to make sure that the matrix symbols are exported from weston and
that modules get them from there.  To do that, we pull matrix.[ch] out of
libshared and back into weston.  calibrator now also links to matrix.[ch]
and we add a IN_WESTON define to enable the WL_EXPORT macro when compiled
inside weston.
2012-12-07 15:00:36 -05:00
Rob Bradford 4a822495fa Move matrix.[ch] to shared
This means it can be used for the calibration tool.
2012-12-06 15:53:03 -05:00
Pekka Paalanen 4fbb65372e Fix build warnings from image_loader
Fix the following build warnings, and the build failures due to the
warning fixes:

  CC     libshared_cairo_la-image-loader.lo
image-loader.c:369:1: warning: no previous prototype for 'load_image'

  CC     x11_backend_la-compositor-x11.lo
compositor-x11.c: In function 'x11_output_set_icon':
compositor-x11.c:396:2: warning: implicit declaration of function 'load_image'
compositor-x11.c:396:8: warning: assignment makes pointer from integer without a cast

  CC     wayland_backend_la-compositor-wayland.lo
compositor-wayland.c: In function 'create_border':
compositor-wayland.c:97:2: warning: implicit declaration of function 'load_image'
compositor-wayland.c:97:8: warning: assignment makes pointer from integer without a cast

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-11-30 14:24:00 -05:00
Kristian Høgsberg 6006ecb497 configure.ac: Don't link weston to cairo or image libraries
We were pulling in cairo and the image loading libraries through libshared.
Split out libshared into a core libshared and a libshared-cairo that
pulls in the extra libraries.
2012-11-29 13:32:11 -05:00
Scott Moreau c6a7e4b277 toytoolkit: Don't draw shadows for maximized windows.
Add THEME_FRAME_MAXIMIZED flag so the theming system can know not to draw
shadows for maximized windows. This allows maximized surfaces' content to be
sized and placed in a more expectable fashion.
2012-10-10 11:23:41 -04:00
Kristian Høgsberg 3d89049546 config-parser: Handle lines that don't end in \n
If the last line in a config file doesn't have a newline
we end up chopping off the last character from that line.
2012-08-03 21:56:41 -04:00
Kristian Høgsberg c234fb819f image-loader: Use pixman_image_t, not struct pixman_image_t 2012-07-11 15:45:59 -04:00
Rafal Mielniczuk 9d4ddefcce image-loader: don't leak pixman_image bits data
Set the pixman_image destroy function to free bits data
2012-07-11 15:42:51 -04:00
Martin Olsson 712f5f405e shared: Don't leak file descriptor in shared/image-loader.c 2012-07-09 17:50:44 -04:00
Martin Minarik 5f3eddc07a weston: Clip window title text to the frame
Fixes an issue with text overflowing the available frame space.
2012-07-09 17:28:09 -04:00
Pekka Paalanen b7a9498a8e compositor: add fallback strchrnul()
Android does not have this function.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-06-12 12:29:13 -04:00
Pekka Paalanen 1da1b8f3f1 Rewrite shm buffer file allocation v2
We had duplicated code in many places, using hardcoded paths for
temporary files into more than one path. Some cases did not bother with
O_CLOEXEC, and all hardcoded paths that might not exist.

Add an OS helper function for creating a unique anonymous file with
close-on-exec semantics. The helper uses $XDG_RUNTIME_DIR as the
directory for a file.

This patch unifies the buffer file creation in both Weston and the
clients.

As simple clients are better not linking to libshared, as it would
require e.g. Cairo, they pull the OS compatibility code directly.

Android does not have mkostemp(), so a configure test is added for it,
and a fallback used if it is not available.

Changes in v2:
	remove all the alternate possible directory definitions and use
	XDG_RUNTIME_DIR only, and fail is it is not set.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-06-06 13:26:30 -04:00
Pekka Paalanen 647f2bfd2a window: add wrapper for EPOLL_CLOEXEC
Android does not have EPOLL_CLOEXEC, so add a fallback.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-05-31 13:53:51 -04:00
Pekka Paalanen 200019c0c6 compositor: check for execinfo.h
Some systems may not have execinfo.h. Add a configure test for it, and
if it is not found, make the backtrace() call a no-operation.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-05-31 13:52:24 -04:00
Pekka Paalanen 51aaf646db compositor: work around missing SOCK_CLOEXEC
Android does not have SOCK_CLOEXEC, so implement a wrapper that falls
back.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-05-31 13:52:20 -04:00
Kristian Høgsberg f96e6c00d9 Share code to to classify pointer location in frame 2012-05-22 16:38:53 -04:00
Kristian Høgsberg 20d0028a56 Rename libconfig-parser to libshared
Still a bad name.
2012-05-15 22:37:26 -04:00
Kristian Høgsberg 5a315bc72d Move cairo-util to shared/ 2012-05-15 22:33:43 -04:00
Kristian Høgsberg b71302e1db Fix a few -pedantic warnings
We're not enabling -pedantic by default, but a quick test brought up a few
issues that we should fix.
2012-05-10 14:11:44 -04:00
Pekka Paalanen 4ea4d1bb39 config-parser: add missing return for an error case
Fixes
config-parser.c: In function 'handle_key':
config-parser.c:81: error: control reaches end of non-void function

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-04-17 14:33:30 +03:00
Kristian Høgsberg ee4b4cb933 shared: Use $(GCC_CFLAGS), fix warnings 2012-04-11 09:46:51 -04:00
Jonas Ådahl 3685c3abf6 Fix `unused-result' warnings.
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2012-04-03 14:50:15 -04:00
Kristian Høgsberg f02a649a3c Consolidate image loading code and move to shared/ 2012-03-12 01:40:59 -04:00
Kristian Høgsberg bcacef19b0 Add an option parser
On one hand, getopt (in particular the -o suboption syntax) sucks on the
server side, and on the client side we would like to avoid the glib
dependency.  We can roll out own option parser and solve both problems
and save a few lines of code total.
2012-03-12 01:28:50 -04:00
Scott Moreau fa1de69203 Implement CONFIG_KEY_UNSIGNED_INTEGER
strtol() does not work when trying to assign 32 bits of data into a
regular signed int on 32 bit systems. Use corresponding strtoul()
instead.
2012-01-27 15:34:27 -05:00
Kristian Høgsberg 9b935c8239 Use '-' to separate words in file names
Eventually we will want more functionality in the shared library and we
will rename it at that point.  Perhaps we'll name it libnih, but for now
let's stick with libconfig-parser.
2011-12-08 12:44:27 -05:00
Pekka Paalanen 28a20707a2 configparser: rename BOOL, document types
Rename CONFIG_KEY_BOOL to CONFIG_KEY_BOOLEAN, just like
CONFIG_KEY_INTEGER is not CONFIG_KEY_INT, for consistency.

Document the types expected for the void* and name the enum in the
header, so it is clear what config_key::type means.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-12-08 10:25:54 +02:00
Pekka Paalanen c1765c67b3 move config parser to a convenience library
Create a new directory for convenience librariers that can be shared
between compositor components and clients.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-12-08 10:25:12 +02:00