diff options
author | Jeremy Huddleston <jeremyhu@apple.com> | 2012-03-21 11:31:23 -0700 |
---|---|---|
committer | Jeremy Huddleston <jeremyhu@apple.com> | 2012-03-21 13:27:22 -0700 |
commit | 11b4cbc941f1ad308c3d5bf418aacc2b3e4f2f38 (patch) | |
tree | 36ad77e8458db989924554fada30f5f344dec716 | |
parent | a47d5b43c3270f255fe3f6b5fc4ea3b5eb62a393 (diff) |
API: Begin obfuscation of private types
xtoq no longer pulls in private headers
xtoq_event_t is now obfuscated (the other types need to be similarly changed)
Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
-rw-r--r-- | include/xcwm/event.h | 87 | ||||
-rw-r--r-- | include/xcwm/xcwm.h | 36 | ||||
-rw-r--r-- | include/xcwm/xtoq.h | 72 | ||||
-rw-r--r-- | src/libcompositewm/data.h | 46 | ||||
-rw-r--r-- | src/libcompositewm/event_loop.c | 11 | ||||
-rw-r--r-- | src/libcompositewm/input.c | 4 | ||||
-rw-r--r-- | src/libcompositewm/window.c | 2 | ||||
-rw-r--r-- | src/libcompositewm/xtoq.c | 2 | ||||
-rw-r--r-- | src/libcompositewm/xtoq_internal.h | 4 | ||||
-rw-r--r-- | src/xtoq/Makefile.am | 2 | ||||
-rw-r--r-- | src/xtoq/XtoqController.h | 2 | ||||
-rw-r--r-- | src/xtoq/XtoqController.m | 8 | ||||
-rw-r--r-- | src/xtoq/XtoqImageRep.h | 2 | ||||
-rw-r--r-- | src/xtoq/XtoqView.h | 2 | ||||
-rw-r--r-- | src/xtoq/XtoqWindow.h | 2 |
15 files changed, 192 insertions, 90 deletions
diff --git a/include/xcwm/event.h b/include/xcwm/event.h new file mode 100644 index 0000000..d9d2b00 --- /dev/null +++ b/include/xcwm/event.h @@ -0,0 +1,87 @@ +/* Copyright (c) 2012 Apple Inc + * + * xcwm/event.h + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, copy, + * modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + + +#ifndef _XCWM_EVENT_H_ +#define _XCWM_EVENT_H_ + +#ifndef __XCWM_INDIRECT__ +#error "Please #include <xcwm/xcwm.h> instead of this file directly." +#endif + +/* Abstract types for xcwm data types */ +struct xcwm_event_t; +typedef struct xcwm_event_t xcwm_event_t; + +typedef void (*xcwm_event_cb_t) (xcwm_event_t const *event); + +/* Event types */ +#define XTOQ_DAMAGE 0 +#define XTOQ_EXPOSE 1 +#define XTOQ_CREATE 2 +#define XTOQ_DESTROY 3 + +/** + * Return the event type for the given event. + */ +int xcwm_event_get_type(xcwm_event_t const *event); + +/** + * Return the context for the given event. + */ +xcwm_context_t * xcwm_event_get_context(xcwm_event_t const *event); + +/** + * Starts the event loop and listens on the connection specified in + * the given xcwm_context_t. Uses callback as the function to call + * when an event of interest is received. Callback must be able to + * take an xcwm_event_t as its one and only parameter. + * @param context The context containing the connection to listen + * for events on. + * @param callback The function to call when an event of interest is + * received. + * @return Uses the return value of the call to pthread_create as + * the return value. + */ +int +xcwm_start_event_loop (xcwm_context_t *context, xcwm_event_cb_t callback); + +/** + * Request a lock on the mutex for the event loop thread. Blocks + * until lock is aquired, or error occurs. + * @return 0 if successful, otherwise non-zero + */ +int +xcwm_get_event_thread_lock (void); + +/** + * Release the lock on the mutex for the event loop thread. + * @return 0 if successsful, otherwise non-zero + */ +int +xcwm_release_event_thread_lock(void); + + +#endif /* _XCWM_EVENT_H_ */ diff --git a/include/xcwm/xcwm.h b/include/xcwm/xcwm.h new file mode 100644 index 0000000..bdafbcd --- /dev/null +++ b/include/xcwm/xcwm.h @@ -0,0 +1,36 @@ +/* Copyright (c) 2012 Apple Inc + * + * xcwm/xcwm.h + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, copy, + * modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#ifndef _XCWM_XCWM_H_ +#define _XCWM_XWCM_H_ + +#ifndef __XCWM_INDIRECT__ +#define __XCWM_INDIRECT__ +#endif + +#include <xcwm/xtoq.h> +#include <xcwm/event.h> + +#endif /* _XCWM_XCWM_H_ */ diff --git a/include/xcwm/xtoq.h b/include/xcwm/xtoq.h index ac03678..bfede6e 100644 --- a/include/xcwm/xtoq.h +++ b/include/xcwm/xtoq.h @@ -37,12 +37,50 @@ #include <xcb/composite.h> #include <xcb/xtest.h> #include <xcb/xfixes.h> -#include "data.h" #include <xcb/xcb_keysyms.h> -#include "xtoq_internal.h" + +/* Abstract types for xtoq data types */ + +/* FIXME: Obfuscate these */ +struct xtoq_context_t { + xcb_connection_t *conn; + xcb_drawable_t window; + xcb_window_t parent; + xcb_damage_damage_t damage; + int x; + int y; + int width; + int height; + int damaged_x; + int damaged_y; + int damaged_width; + int damaged_height; + char *name; /* The name of the window */ + int wm_delete_set; /* Flag for WM_DELETE_WINDOW, 1 if set */ + void *local_data; /* Area for data client cares about */ +}; +typedef struct xtoq_context_t xtoq_context_t; + +struct image_data_t { + uint8_t *data; + int length; +}; +typedef struct image_data_t image_data_t; + +struct xtoq_image_t { + xcb_image_t *image; + int x; + int y; + int width; + int height; +}; +typedef struct xtoq_image_t xtoq_image_t; /** * Context which contains the display's root window. + * + * FIXME: We should avoid having global state where at all possible, and + * certainly not export such state for client access */ extern xtoq_context_t *root_context; @@ -103,36 +141,6 @@ void xtoq_set_window_to_top(xtoq_context_t *context); /** - * Starts the event loop and listens on the connection specified in - * the given xtoq_context_t. Uses callback as the function to call - * when an event of interest is received. Callback must be able to - * take an xtoq_event_t as its one and only parameter. - * @param context The context containing the connection to listen - * for events on. - * @param callback The function to call when an event of interest is - * received. - * @return Uses the return value of the call to pthread_create as - * the return value. - */ -int -xtoq_start_event_loop (xtoq_context_t *context, xtoq_event_cb_t callback); - -/** - * Request a lock on the mutex for the event loop thread. Blocks - * until lock is aquired, or error occurs. - * @return 0 if successful, otherwise non-zero - */ -int -xtoq_get_event_thread_lock (void); - -/** - * Release the lock on the mutex for the event loop thread. - * @return 0 if successsful, otherwise non-zero - */ -int -xtoq_release_event_thread_lock(void); - -/** * Remove the damage from the given context. * @param context The context to remove the damage from */ diff --git a/src/libcompositewm/data.h b/src/libcompositewm/data.h index 40bfa9b..f7ea0d4 100644 --- a/src/libcompositewm/data.h +++ b/src/libcompositewm/data.h @@ -28,52 +28,12 @@ #ifndef _DATA_H_ #define _DATA_H_ -#include <xcb/xcb.h> -#include <xcb/damage.h> - -#define XTOQ_DAMAGE 0 -#define XTOQ_EXPOSE 1 -#define XTOQ_CREATE 2 -#define XTOQ_DESTROY 3 - -typedef struct xtoq_context_t { - xcb_connection_t *conn; - xcb_drawable_t window; - xcb_window_t parent; - xcb_damage_damage_t damage; - int x; - int y; - int width; - int height; - int damaged_x; - int damaged_y; - int damaged_width; - int damaged_height; - char *name; /* The name of the window */ - int wm_delete_set; /* Flag for WM_DELETE_WINDOW, 1 if set */ - void *local_data; // Area for data client cares about -} xtoq_context_t; - -typedef struct xtoq_event_t { +struct xtoq_event_t { xtoq_context_t *context; int event_type; -} xtoq_event_t; - -typedef struct image_data_t { - uint8_t *data; - int length; -} image_data_t; - -typedef struct xtoq_image_t { - xcb_image_t *image; - int x; - int y; - int width; - int height; -} xtoq_image_t; - -typedef void (*xtoq_event_cb_t) (xtoq_event_t const *event); +}; +/* FIXME: We should not be using a global for this */ extern int _damage_event; #endif diff --git a/src/libcompositewm/event_loop.c b/src/libcompositewm/event_loop.c index 2ec1b75..0a42a8d 100644 --- a/src/libcompositewm/event_loop.c +++ b/src/libcompositewm/event_loop.c @@ -26,7 +26,7 @@ #include <pthread.h> -#include <xcwm/xtoq.h> +#include <xcwm/xcwm.h> #include "xtoq_internal.h" typedef struct _connection_data { @@ -301,3 +301,12 @@ void *run_event_loop (void *thread_arg_struct) } return NULL; } + +int xtoq_event_get_type(xtoq_event_t const *event) { + return event->event_type; +} + +xtoq_context_t * xtoq_event_get_context(xtoq_event_t const *event) { + return event->context; +} + diff --git a/src/libcompositewm/input.c b/src/libcompositewm/input.c index e4f7f48..cf70272 100644 --- a/src/libcompositewm/input.c +++ b/src/libcompositewm/input.c @@ -24,7 +24,9 @@ // xtoq-xcode #include <stdio.h> -#include <xcwm/xtoq.h> +#include <xcwm/xcwm.h> + +#include "xtoq_internal.h" void xtoq_key_press (xtoq_context_t *context, int window, uint8_t code) diff --git a/src/libcompositewm/window.c b/src/libcompositewm/window.c index b4f58a5..ec4f7c4 100644 --- a/src/libcompositewm/window.c +++ b/src/libcompositewm/window.c @@ -23,7 +23,7 @@ * SOFTWARE. */ -#include <xcwm/xtoq.h> +#include <xcwm/xcwm.h> #include "xtoq_internal.h" /* Functions only used within this file */ diff --git a/src/libcompositewm/xtoq.c b/src/libcompositewm/xtoq.c index c581af9..ebeca75 100644 --- a/src/libcompositewm/xtoq.c +++ b/src/libcompositewm/xtoq.c @@ -26,7 +26,7 @@ /* #ifndef _XTOQ_C_ */ /* #define _XTOQ_C_ */ -#include <xcwm/xtoq.h> +#include <xcwm/xcwm.h> #include "xtoq_internal.h" #include "X11/keysym.h" #include <string.h> diff --git a/src/libcompositewm/xtoq_internal.h b/src/libcompositewm/xtoq_internal.h index 87ab292..891aee9 100644 --- a/src/libcompositewm/xtoq_internal.h +++ b/src/libcompositewm/xtoq_internal.h @@ -36,9 +36,9 @@ #include <xcb/xcb_image.h> #include <xcb/xcb_icccm.h> #include <xcb/xcb_atom.h> -#include "data.h" -#include <xcwm/xtoq.h> +#include <xcwm/xcwm.h> +#include "data.h" /** * Strucuture used to pass nesessary data to xtoq_start_event_loop. diff --git a/src/xtoq/Makefile.am b/src/xtoq/Makefile.am index f72c63c..c487bd8 100644 --- a/src/xtoq/Makefile.am +++ b/src/xtoq/Makefile.am @@ -7,7 +7,7 @@ SUBDIRS = bundle AM_CFLAGS = $(XCB_CFLAGS) $(BASE_CFLAGS) AM_OBJCFLAGS = $(XCB_CFLAGS) $(BASE_CFLAGS) -INCLUDES = -I$(top_srcdir)/include -I$(top_srcdir)/src/libcompositewm +INCLUDES = -I$(top_srcdir)/include xtoqappdir = $(APPLE_APPLICATIONS_DIR)/$(APPLE_APPLICATION_NAME).app/Contents/MacOS diff --git a/src/xtoq/XtoqController.h b/src/xtoq/XtoqController.h index 4c7a3ba..2475824 100644 --- a/src/xtoq/XtoqController.h +++ b/src/xtoq/XtoqController.h @@ -38,7 +38,7 @@ #import "XtoqWindow.h" #import "XtoqImageRep.h" #import "XtoqView.h" -#import <xcwm/xtoq.h> +#import <xcwm/xcwm.h> #import "spawn.h" #import "crt_externs.h" #import "sys/times.h" diff --git a/src/xtoq/XtoqController.m b/src/xtoq/XtoqController.m index 3671dc1..42bda81 100644 --- a/src/xtoq/XtoqController.m +++ b/src/xtoq/XtoqController.m @@ -510,13 +510,13 @@ void eventHandler (xtoq_event_t *event) { - xtoq_context_t *context = event->context; - if (event->event_type == XTOQ_DAMAGE) { + xtoq_context_t *context = xtoq_event_get_context(event); + if (xtoq_event_get_type(event) == XTOQ_DAMAGE) { [referenceToSelf updateImage: context]; - } else if (event->event_type == XTOQ_CREATE) { + } else if (xtoq_event_get_type(event) == XTOQ_CREATE) { NSLog(@"Window was created"); [referenceToSelf createNewWindow: context]; - } else if (event->event_type == XTOQ_DESTROY) { + } else if (xtoq_event_get_type(event) == XTOQ_DESTROY) { NSLog(@"Window was destroyed"); [referenceToSelf destroyWindow: context]; } else { diff --git a/src/xtoq/XtoqImageRep.h b/src/xtoq/XtoqImageRep.h index 0f862ce..7e3a2e4 100644 --- a/src/xtoq/XtoqImageRep.h +++ b/src/xtoq/XtoqImageRep.h @@ -26,7 +26,7 @@ #import <AppKit/AppKit.h> #import <Cocoa/Cocoa.h> #import <xcb/xcb_image.h> -#import <xcwm/xtoq.h> +#import <xcwm/xcwm.h> @interface XtoqImageRep : NSImageRep { diff --git a/src/xtoq/XtoqView.h b/src/xtoq/XtoqView.h index 60157d9..b5810e7 100644 --- a/src/xtoq/XtoqView.h +++ b/src/xtoq/XtoqView.h @@ -29,7 +29,7 @@ SOFTWARE. #import <Cocoa/Cocoa.h> #import "XtoqImageRep.h" -#import <xcwm/xtoq.h> +#import <xcwm/xcwm.h> @interface XtoqView : NSView { xtoq_context_t *viewContext; diff --git a/src/xtoq/XtoqWindow.h b/src/xtoq/XtoqWindow.h index 85258e0..1102941 100644 --- a/src/xtoq/XtoqWindow.h +++ b/src/xtoq/XtoqWindow.h @@ -22,7 +22,7 @@ // Placehoder #import <Cocoa/Cocoa.h> -#import <xcwm/xtoq.h> +#import <xcwm/xcwm.h> #import "XtoqView.h" @interface XtoqWindow : NSWindow { |