Permalink
Browse files

Provide the dock-support API as a dylib

This should allow easier building on and deployment to different
versions of Mac OS X.

Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
  • Loading branch information...
1 parent 9518841 commit c724411a40635de8b081c620f2cb0414c4234e96 @jeremyhu jeremyhu committed Feb 16, 2012
View
@@ -19,7 +19,7 @@
#
# @APPLE_LICENSE_HEADER_END@
-SUBDIRS = src man
+SUBDIRS = lib src man
MAINTAINERCLEANFILES = ChangeLog INSTALL
View
@@ -47,9 +47,14 @@ AC_ARG_WITH(bundle-id-prefix, AS_HELP_STRING([--with-bundle-id-prefix=PATH], [P
AC_SUBST([BUNDLE_ID_PREFIX])
AC_DEFINE_UNQUOTED(BUNDLE_ID_PREFIX, "$BUNDLE_ID_PREFIX", [Prefix to use for bundle identifiers])
-# dock-support.o has weak symbols that may not be present at build time
-LDFLAGS="$LDFLAGS -undefined suppress -flat_namespace"
+# dock-support.o has weak symbols that will not be present at build time on Leopard
+case $host_os in
+ darwin9.*)
+ LDFLAGS="$LDFLAGS -undefined suppress -flat_namespace"
+ ;;
+esac
AC_OUTPUT([Makefile
+ lib/Makefile
src/Makefile
man/Makefile])
View
@@ -0,0 +1,2 @@
+libquartz-wm-ds.1.dylib
+libquartz-wm-ds.dylib
View
@@ -0,0 +1,42 @@
+# Copyright (c) 2012 Apple Inc. All Rights Reserved.
+#
+# @APPLE_LICENSE_HEADER_START@
+#
+# This file contains Original Code and/or Modifications of Original Code
+# as defined in and that are subject to the Apple Public Source License
+# Version 2.0 (the 'License'). You may not use this file except in
+# compliance with the License. Please obtain a copy of the License at
+# http://www.opensource.apple.com/apsl/ and read it before using this
+# file.
+#
+# The Original Code and all software distributed under the License are
+# distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+# EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
+# INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+# Please see the License for the specific language governing rights and
+# limitations under the License.
+#
+# @APPLE_LICENSE_HEADER_END@
+
+DIST_LIB = libquartz-wm-ds.apsl.dylib
+LIBRARY_BASENAME = libquartz-wm-ds.1.dylib
+LIBRARY_SYMLINK = libquartz-wm-ds.dylib
+
+all : $(LIBRARY_SYMLINK)
+
+$(LIBRARY_SYMLINK) : $(LIBRARY_BASENAME)
+ ln -s $^ $@
+
+$(LIBRARY_BASENAME) : $(DIST_LIB)
+ cp $^ $@
+ install_name_tool -id $(libdir)/$@ $@
+
+install-exec-hook : $(LIBRARY_BASENAME)
+ install -d -m 755 $(DESTDIR)$(libdir)
+ install -m 755 $(LIBRARY_BASENAME) $(DESTDIR)$(libdir)
+ ln -s $(LIBRARY_BASENAME) $(DESTDIR)$(libdir)/$(LIBRARY_SYMLINK)
+
+CLEANFILES = $(LIBRARY_SYMLINK) $(LIBRARY_BASENAME)
+
+EXTRA_DIST = dock-support.h $(DIST_LIB)
View
@@ -0,0 +1,82 @@
+/* dock-support.h
+ *
+ * Copyright (c) 2002-2011 Apple Inc. All Rights Reserved.
+ *
+ * @APPLE_LICENSE_HEADER_START@
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ *
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
+ *
+ * @APPLE_LICENSE_HEADER_END@
+ */
+
+#ifndef __DOCK_SUPPORT_H__
+#define __DOCK_SUPPORT_H__
+
+#include <ApplicationServices/ApplicationServices.h>
+#include <objc/objc.h>
+
+typedef uint32_t qwm_native_window_id;
+
+#define QWM_NULL_NATIVE_WINDOW_ID ((qwm_native_window_id)0)
+
+/* Dock location */
+typedef enum {
+ QWM_DOCK_ORIENTATION_BOTTOM = 2,
+ QWM_DOCK_ORIENTATION_LEFT = 3,
+ QWM_DOCK_ORIENTATION_RIGHT = 4,
+} qwm_dock_orientation;
+
+extern qwm_dock_orientation qwm_dock_get_orientation(void);
+extern CGRect qwm_dock_get_rect(void);
+
+/* Window Visibility */
+extern CGError qwm_dock_is_window_visible(qwm_native_window_id window_id, BOOL *is_visible);
+
+/* Minimize / Restore */
+extern OSStatus qwm_dock_minimize_item_with_title_async(qwm_native_window_id osxwindow_id, CFStringRef title);
+extern OSStatus qwm_dock_restore_item_async(qwm_native_window_id osxwindow_id);
+extern OSStatus qwm_dock_remove_item(qwm_native_window_id osxwindow_id);
+
+/* Window dragging */
+extern OSStatus qwm_dock_drag_begin(qwm_native_window_id osxwindow_id);
+extern OSStatus qwm_dock_drag_end(qwm_native_window_id osxwindow_id);
+
+/* Initialization */
+extern void qwm_dock_init(bool only_proxy);
+
+/* Event handling */
+typedef enum {
+ QWM_DOCK_EVENT_RESTORE_ALL_WINDOWS = 1,
+ QWM_DOCK_EVENT_RESTORE_WINDOWS = 2,
+ QWM_DOCK_EVENT_SELECT_WINDOWS = 3,
+ QWM_DOCK_EVENT_RESTORE_DONE = 4,
+ QWM_DOCK_EVENT_MINIMIZE_DONE = 5,
+} qwm_dock_event_type;
+
+typedef struct {
+ qwm_dock_event_type type;
+
+ /* QWM_NULL_NATIVE_WINDOW_ID terminated list of windows affected by this event */
+ qwm_native_window_id *windows;
+
+ /* YES if the event was successful (for QWM_DOCK_EVENT_RESTORE_DONE and QWM_DOCK_EVENT_MINIMIZE_DONE) */
+ BOOL success;
+} qwm_dock_event;
+
+typedef void (*qwm_dock_event_handler)(qwm_dock_event *event);
+extern void qwm_dock_event_set_handler(qwm_dock_event_handler new_handler);
+
+#endif /* __DOCK_SUPPORT_H__ */
Binary file not shown.
View
@@ -21,19 +21,16 @@
bin_PROGRAMS = quartz-wm
-AM_CPPFLAGS = -F /System/Library/Frameworks/ApplicationServices.framework/Frameworks
+AM_CPPFLAGS = -I$(top_srcdir)/lib
AM_OBJCFLAGS = $(QUARTZWM_CFLAGS) $(CWARNFLAGS)
AM_CFLAGS = $(QUARTZWM_CFLAGS) $(CWARNFLAGS)
quartz_wm_LDFLAGS = $(QUARTZWM_LIBS) \
- -framework AppKit \
- -framework Foundation \
- -framework ApplicationServices
-
-quartz_wm_LDADD = dock-support.o
+ -L$(top_builddir)/lib -lquartz-wm-ds \
+ -framework AppKit
quartz_wm_SOURCES = \
- dock-support.h \
+ dock-support-handler.m \
frame.h \
frame.m \
main.m \
@@ -49,11 +46,3 @@ quartz_wm_SOURCES = \
x-window.m \
x11-geometry.c \
x11-geometry.h
-
-EXTRA_DIST = binary/dock-support.o
-
-BUILT_SOURCES = dock-support.o
-MAINTAINERCLEANFILES = $(BUILT_SOURCES)
-
-dock-support.o : $(srcdir)/binary/dock-support.o
- cp $(srcdir)/binary/dock-support.o dock-support.o
View
Binary file not shown.
View
@@ -0,0 +1,95 @@
+/* dock-support-handler.m
+ *
+ * Copyright (c) 2012 Apple Inc. All Rights Reserved.
+ *
+ * @APPLE_LICENSE_HEADER_START@
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ *
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
+ *
+ * @APPLE_LICENSE_HEADER_END@
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <X11/Xlib.h>
+#include <X11/extensions/applewm.h>
+
+#include "quartz-wm.h"
+#include "x-list.h"
+#include "x-window.h"
+
+#include "dock-support.h"
+
+void dock_event_handler(qwm_dock_event *event) {
+ x_list *s_node = NULL, *w_node = NULL;
+ x_window *w = NULL;
+ x_screen *s = NULL;
+ qwm_native_window_id *native_wid;
+
+ switch (event->type) {
+ case QWM_DOCK_EVENT_RESTORE_ALL_WINDOWS:
+ for (s_node = screen_list; s_node != NULL; s_node = s_node->next) {
+ s = s_node->data;
+ for (w_node = s->_window_list; w_node != NULL; w_node = w_node->next) {
+ w = w_node->data;
+ if (w->_minimized) {
+ DB(" restoring window wid:%x\n", [w get_osx_id]);
+ [w do_uncollapse_and_tell_dock:FALSE];
+ }
+ }
+ }
+ break;
+ case QWM_DOCK_EVENT_RESTORE_WINDOWS:
+ case QWM_DOCK_EVENT_SELECT_WINDOWS:
+ case QWM_DOCK_EVENT_RESTORE_DONE:
+ case QWM_DOCK_EVENT_MINIMIZE_DONE:
+ if (event->type == QWM_DOCK_EVENT_RESTORE_WINDOWS ||
+ event->type == QWM_DOCK_EVENT_SELECT_WINDOWS)
+ XAppleWMSetFrontProcess (x_dpy);
+
+ for (native_wid = event->windows; *native_wid != QWM_NULL_NATIVE_WINDOW_ID; native_wid++) {
+ w = x_get_window_by_osx_id (*native_wid);
+ if (w == NULL) {
+ DB("Invalid native window id: %u\n", *native_wid);
+ return;
+ }
+
+ switch (event->type) {
+ case QWM_DOCK_EVENT_RESTORE_WINDOWS:
+ [w do_uncollapse_and_tell_dock:FALSE];
+ [w activate:CurrentTime];
+ break;
+ case QWM_DOCK_EVENT_SELECT_WINDOWS:
+ [w activate:CurrentTime];
+ break;
+ case QWM_DOCK_EVENT_RESTORE_DONE:
+ [w uncollapse_finished:event->success];
+ break;
+ case QWM_DOCK_EVENT_MINIMIZE_DONE:
+ [w collapse_finished:event->success];
+ break;
+ default:
+ break;
+ }
+ }
+ XFlush (x_dpy);
+ break;
+ default:
+ break;
+ }
+}
View
@@ -1,60 +0,0 @@
-/* dock-support.h
- *
- * Copyright (c) 2002-2011 Apple Inc. All Rights Reserved.
- *
- * @APPLE_LICENSE_HEADER_START@
- *
- * This file contains Original Code and/or Modifications of Original Code
- * as defined in and that are subject to the Apple Public Source License
- * Version 2.0 (the 'License'). You may not use this file except in
- * compliance with the License. Please obtain a copy of the License at
- * http://www.opensource.apple.com/apsl/ and read it before using this
- * file.
- *
- * The Original Code and all software distributed under the License are
- * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
- * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
- * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
- * Please see the License for the specific language governing rights and
- * limitations under the License.
- *
- * @APPLE_LICENSE_HEADER_END@
- */
-
-#ifndef __DOCK_SUPPORT_H__
-#define __DOCK_SUPPORT_H__
-
-#include <CoreGraphics/CoreGraphics.h>
-#include <stdint.h>
-
-typedef uint32_t OSXWindowID;
-
-#define kOSXNullWindowID ((OSXWindowID)0)
-
-/* Dock location */
-typedef enum {
- kDockBottom = 2,
- kDockLeft = 3,
- kDockRight = 4,
-} DockOrientation;
-
-extern DockOrientation DockGetOrientation(void);
-extern CGRect DockGetRect(void);
-
-/* Window Visibility */
-extern CGError DockIsWindowVisible(OSXWindowID window_id, BOOL *isVisible);
-
-/* Minimize / Restore */
-extern OSStatus DockMinimizeItemWithTitleAsync(OSXWindowID osxwindow_id, CFStringRef title);
-extern OSStatus DockRestoreItemAsync(OSXWindowID osxwindow_id);
-extern OSStatus DockRemoveItem(OSXWindowID osxwindow_id);
-
-/* Window dragging */
-extern OSStatus DockDragBegin(OSXWindowID osxwindow_id);
-extern OSStatus DockDragEnd(OSXWindowID osxwindow_id);
-
-/* Initialization */
-extern void DockInit(bool only_proxy);
-
-#endif /* __DOCK_SUPPORT_H__ */
View
@@ -571,7 +571,7 @@ static void x_error_shutdown (void) {
}
id
-x_get_window_by_osx_id (OSXWindowID osxwindow_id)
+x_get_window_by_osx_id (qwm_native_window_id osxwindow_id)
{
x_list *node;
@@ -983,7 +983,8 @@ int main (int argc, const char *argv[]) {
aslc = asl_open("quartz-wm", asl_facility, asl_opts);
signal_handler_cb_init();
- DockInit(0);
+ qwm_dock_event_set_handler(dock_event_handler);
+ qwm_dock_init(0);
x_init ();
signal (SIGINT, signal_handler);
View
@@ -88,7 +88,7 @@ extern void x_update_keymap (void);
extern id x_get_screen (Screen *xs);
extern id x_get_screen_with_root (Window xwindow_id);
extern id x_get_window (Window xwindow_id);
-extern id x_get_window_by_osx_id (OSXWindowID osxwindow_id);
+extern id x_get_window_by_osx_id (qwm_native_window_id osxwindow_id);
extern void x_set_active_window (id w);
extern id x_get_active_window (void);
extern void x_set_is_active (BOOL state);
@@ -190,6 +190,10 @@ struct atoms_struct_t {
extern struct atoms_struct_t atoms;
+/* Dock Events */
+#include "dock-support.h"
+extern void dock_event_handler(qwm_dock_event *event);
+
/* Debugging support */
extern void debug_printf (const char *fmt, ...) _X_ATTRIBUTE_PRINTF(1,2);
extern void debug_asl (const char *file, const char *function, int line, const char *fmt, ...) _X_ATTRIBUTE_PRINTF(4,5);
Oops, something went wrong.

0 comments on commit c724411

Please sign in to comment.