From a3dbde2de87ee4f577748a8c447501a3ea462559 Mon Sep 17 00:00:00 2001 From: Jeremy Huddleston Date: Sun, 27 Sep 2009 17:08:12 -0700 Subject: XQuartz: Transition from xEvent based mieq to InternalEvent --- hw/xquartz/Makefile.am | 2 - hw/xquartz/darwinEvents.c | 241 ++++++++++++++++++++---------------------- hw/xquartz/darwinEvents.h | 7 +- hw/xquartz/quartz.c | 17 +-- hw/xquartz/quartz.h | 8 +- hw/xquartz/quartzCocoa.m | 57 ---------- hw/xquartz/quartzKeyboard.c | 2 +- hw/xquartz/quartzKeyboard.h | 2 +- hw/xquartz/quartzPasteboard.c | 147 -------------------------- hw/xquartz/quartzPasteboard.h | 44 -------- hw/xquartz/xpr/xpr.h | 2 +- hw/xquartz/xpr/xprCursor.c | 6 +- hw/xquartz/xpr/xprEvent.c | 49 ++++----- hw/xquartz/xpr/xprEvent.h | 2 +- include/events.h | 3 + include/eventstr.h | 18 ++++ mi/mieq.c | 3 +- 17 files changed, 170 insertions(+), 440 deletions(-) delete mode 100644 hw/xquartz/quartzPasteboard.c delete mode 100644 hw/xquartz/quartzPasteboard.h diff --git a/hw/xquartz/Makefile.am b/hw/xquartz/Makefile.am index ae8aa7f53..65c70b076 100644 --- a/hw/xquartz/Makefile.am +++ b/hw/xquartz/Makefile.am @@ -33,7 +33,6 @@ libXquartz_la_SOURCES = \ quartzAudio.c \ quartzCocoa.m \ quartzKeyboard.c \ - quartzPasteboard.c \ quartzStartup.c \ threadSafety.c @@ -50,7 +49,6 @@ EXTRA_DIST = \ quartzAudio.h \ quartzCommon.h \ quartzKeyboard.h \ - quartzPasteboard.h \ sanitizedCarbon.h \ sanitizedCocoa.h \ threadSafety.h diff --git a/hw/xquartz/darwinEvents.c b/hw/xquartz/darwinEvents.c index 4822af479..d300cce05 100644 --- a/hw/xquartz/darwinEvents.c +++ b/hw/xquartz/darwinEvents.c @@ -43,6 +43,7 @@ in this Software without prior written authorization from The Open Group. #include "windowstr.h" #include "pixmapstr.h" #include "inputstr.h" +#include "eventstr.h" #include "mi.h" #include "scrnintstr.h" #include "mipointer.h" @@ -71,7 +72,7 @@ in this Software without prior written authorization from The Open Group. #include "applewmExt.h" /* FIXME: Abstract this better */ -void QuartzModeEQInit(void); +extern Bool QuartzModeEventHandler(int screenNum, XQuartzEvent *e, DeviceIntPtr dev); int darwin_all_modifier_flags = 0; // last known modifier state int darwin_all_modifier_mask = 0; @@ -84,7 +85,7 @@ static pthread_mutex_t fd_add_lock = PTHREAD_MUTEX_INITIALIZER; static pthread_cond_t fd_add_ready_cond = PTHREAD_COND_INITIALIZER; static pthread_t fd_add_tid = NULL; -static EventList *darwinEvents = NULL; +static EventListPtr darwinEvents = NULL; static pthread_mutex_t mieq_lock = PTHREAD_MUTEX_INITIALIZER; static pthread_cond_t mieq_ready_cond = PTHREAD_COND_INITIALIZER; @@ -190,89 +191,98 @@ static void DarwinUpdateModifiers( be moved into their own individual functions and set as handlers using mieqSetHandler. */ -static void DarwinEventHandler(int screenNum, xEventPtr xe, DeviceIntPtr dev, int nevents) { - int i; - +static void DarwinEventHandler(int screenNum, InternalEvent *ie, DeviceIntPtr dev) { + XQuartzEvent *e = &(ie->xquartz_event); + TA_SERVER(); -// DEBUG_LOG("DarwinEventHandler(%d, %p, %p, %d)\n", screenNum, xe, dev, nevents); - for (i=0; isubtype) { + case kXquartzControllerNotify: + DEBUG_LOG("kXquartzControllerNotify\n"); + AppleWMSendEvent(AppleWMControllerNotify, + AppleWMControllerNotifyMask, + e->data[0], + e->data[1]); + break; + + case kXquartzPasteboardNotify: + DEBUG_LOG("kXquartzPasteboardNotify\n"); + AppleWMSendEvent(AppleWMPasteboardNotify, + AppleWMPasteboardNotifyMask, + e->data[0], + e->data[1]); + break; + + case kXquartzActivate: + DEBUG_LOG("kXquartzActivate\n"); + QuartzShow(); + AppleWMSendEvent(AppleWMActivationNotify, + AppleWMActivationNotifyMask, + AppleWMIsActive, 0); + break; + + case kXquartzDeactivate: + DEBUG_LOG("kXquartzDeactivate\n"); + AppleWMSendEvent(AppleWMActivationNotify, + AppleWMActivationNotifyMask, + AppleWMIsInactive, 0); + QuartzHide(); + break; + + case kXquartzReloadPreferences: + DEBUG_LOG("kXquartzReloadPreferences\n"); + AppleWMSendEvent(AppleWMActivationNotify, + AppleWMActivationNotifyMask, + AppleWMReloadPreferences, 0); + break; + + case kXquartzToggleFullscreen: + DEBUG_LOG("kXquartzToggleFullscreen\n"); + if (quartzEnableRootless) + QuartzSetFullscreen(!quartzHasRoot); + else if (quartzHasRoot) QuartzHide(); - break; - - case kXquartzReloadPreferences: - DEBUG_LOG("kXquartzReloadPreferences\n"); - AppleWMSendEvent(AppleWMActivationNotify, - AppleWMActivationNotifyMask, - AppleWMReloadPreferences, 0); - break; - - case kXquartzToggleFullscreen: - DEBUG_LOG("kXquartzToggleFullscreen\n"); - if (quartzEnableRootless) - QuartzSetFullscreen(!quartzHasRoot); - else if (quartzHasRoot) - QuartzHide(); - else - QuartzShow(xe[i].u.keyButtonPointer.rootX, - xe[i].u.keyButtonPointer.rootY); - break; - - case kXquartzSetRootless: - DEBUG_LOG("kXquartzSetRootless\n"); - QuartzSetRootless(xe[i].u.clientMessage.u.l.longs0); - if (!quartzEnableRootless && !quartzHasRoot) - QuartzHide(); - break; - - case kXquartzSetRootClip: - QuartzSetRootClip((Bool)xe[i].u.clientMessage.u.l.longs0); - break; - - case kXquartzQuit: - GiveUp(0); - break; - - case kXquartzSpaceChanged: - DEBUG_LOG("kXquartzSpaceChanged\n"); - QuartzSpaceChanged(xe[i].u.clientMessage.u.l.longs0); - break; - - default: - ErrorF("Unknown application defined event type %d.\n", xe[i].u.u.type); - } - } + else + QuartzShow(); + break; + + case kXquartzSetRootless: + DEBUG_LOG("kXquartzSetRootless\n"); + QuartzSetRootless(e->data[0]); + if (!quartzEnableRootless && !quartzHasRoot) + QuartzHide(); + break; + + case kXquartzSetRootClip: + QuartzSetRootClip((Bool)e->data[0]); + break; + + case kXquartzQuit: + GiveUp(0); + break; + + case kXquartzSpaceChanged: + DEBUG_LOG("kXquartzSpaceChanged\n"); + QuartzSpaceChanged(e->data[0]); + break; + + case kXquartzListenOnOpenFD: + ErrorF("Calling ListenOnOpenFD() for new fd: %d\n", (int)e->data[0]); + ListenOnOpenFD((int)e->data[0], 1); + break; + + case kXquartzReloadKeymap: + DarwinKeyboardReloadHandler(); + break; + + case kXquartzDisplayChanged: + QuartzUpdateScreens(); + break; + + default: + if(!QuartzModeEventHandler(screenNum, e, dev)) + ErrorF("Unknown application defined event type %d.\n", e->subtype); + } } void DarwinListenOnOpenFD(int fd) { @@ -298,16 +308,6 @@ static void DarwinProcessFDAdditionQueue_thread(void *args) { } } -static void kXquartzListenOnOpenFDHandler(int screenNum, xEventPtr xe, DeviceIntPtr dev, int nevents) { - size_t i; - TA_SERVER(); - - for (i=0; i oh, i ... er ... christ. - write(darwinEventWriteFD, &nullbyte, 1); + write(darwinEventWriteFD, &nullbyte, sizeof(nullbyte)); } /* Convert from Appkit pointer input values to X input values: @@ -476,7 +460,7 @@ void DarwinSendPointerEvents(DeviceIntPtr pDev, int ev_type, int ev_button, floa darwinEvents_lock(); { num_events = GetPointerEvents(darwinEvents, pDev, ev_type, ev_button, POINTER_ABSOLUTE, 0, pDev==darwinTabletCurrent?5:2, valuators); - for(i=0; i 0) DarwinPokeEQ(); } darwinEvents_unlock(); } @@ -491,7 +475,7 @@ void DarwinSendKeyboardEvents(int ev_type, int keycode) { darwinEvents_lock(); { num_events = GetKeyboardEvents(darwinEvents, darwinKeyboard, ev_type, keycode + MIN_KEYCODE); - for(i=0; i 0) DarwinPokeEQ(); } darwinEvents_unlock(); } @@ -519,7 +503,7 @@ void DarwinSendProximityEvents(int ev_type, float pointer_x, float pointer_y) { darwinEvents_lock(); { num_events = GetProximityEvents(darwinEvents, pDev, ev_type, 0, 5, valuators); - for(i=0; i 0) DarwinPokeEQ(); } darwinEvents_unlock(); } @@ -566,27 +550,26 @@ void DarwinUpdateModKeys(int flags) { * Send the X server thread a message by placing it on the event queue. */ void DarwinSendDDXEvent(int type, int argc, ...) { - xEvent xe; - INT32 *argv; - int i, max_args; + XQuartzEvent e; + int i; va_list args; - memset(&xe, 0, sizeof(xe)); - xe.u.u.type = type; - xe.u.clientMessage.u.l.type = type; - - argv = &xe.u.clientMessage.u.l.longs0; - max_args = 4; + memset(&e, 0, sizeof(e)); + e.header = ET_Internal; + e.type = ET_XQuartz; + e.length = sizeof(e); + e.time = GetTimeInMillis(); + e.subtype = type; - if (argc > 0 && argc <= max_args) { + if (argc > 0 && argc < XQUARTZ_EVENT_MAXARGS) { va_start (args, argc); for (i = 0; i < argc; i++) - argv[i] = (int) va_arg (args, int); + e.data[i] = (uint32_t) va_arg (args, uint32_t); va_end (args); } darwinEvents_lock(); { - mieqEnqueue(NULL, &xe); + mieqEnqueue(NULL, (InternalEvent*)&e); DarwinPokeEQ(); } darwinEvents_unlock(); } diff --git a/hw/xquartz/darwinEvents.h b/hw/xquartz/darwinEvents.h index 126851422..590305f3e 100644 --- a/hw/xquartz/darwinEvents.h +++ b/hw/xquartz/darwinEvents.h @@ -45,17 +45,14 @@ void DarwinUpdateModKeys(int flags); void DarwinListenOnOpenFD(int fd); /* - * Special ddx events understood by the X server + * Subtypes for the ET_XQuartz event type */ enum { - kXquartzReloadKeymap // Reload system keymap - = LASTEvent+1, // (from X.h list of event names) + kXquartzReloadKeymap, // Reload system keymap kXquartzActivate, // restore X drawing and cursor kXquartzDeactivate, // clip X drawing and switch to Aqua cursor kXquartzSetRootClip, // enable or disable drawing to the X screen kXquartzQuit, // kill the X server and release the display - kXquartzReadPasteboard, // copy Mac OS X pasteboard into X cut buffer - kXquartzWritePasteboard, // copy X cut buffer onto Mac OS X pasteboard kXquartzBringAllToFront, // bring all X windows to front kXquartzToggleFullscreen, // Enable/Disable fullscreen mode kXquartzSetRootless, // Set rootless mode diff --git a/hw/xquartz/quartz.c b/hw/xquartz/quartz.c index ca8b24595..64933135d 100644 --- a/hw/xquartz/quartz.c +++ b/hw/xquartz/quartz.c @@ -231,7 +231,7 @@ RREditConnectionInfo (ScreenPtr pScreen) } #endif -static void QuartzUpdateScreens(void) { +void QuartzUpdateScreens(void) { ScreenPtr pScreen; WindowPtr pRoot; int x, y, width, height, sx, sy; @@ -299,14 +299,6 @@ static void QuartzUpdateScreens(void) { #endif } -/* - * QuartzDisplayChangeHandler - * Adjust for screen arrangement changes. - */ -void QuartzDisplayChangedHandler(int screenNum, xEventPtr xe, DeviceIntPtr dev, int nevents) { - QuartzUpdateScreens(); -} - void QuartzSetFullscreen(Bool state) { DEBUG_LOG("QuartzSetFullscreen: state=%d\n", state); @@ -374,10 +366,7 @@ void QuartzSetRootless(Bool state) { * Calls mode specific screen resume to restore the X clip regions * (if needed) and the X server cursor state. */ -void QuartzShow( - int x, // cursor location - int y ) -{ +void QuartzShow() { int i; if (quartzServerVisible) @@ -386,7 +375,7 @@ void QuartzShow( quartzServerVisible = TRUE; for (i = 0; i < screenInfo.numScreens; i++) { if (screenInfo.screens[i]) { - quartzProcs->ResumeScreen(screenInfo.screens[i], x, y); + quartzProcs->ResumeScreen(screenInfo.screens[i]); } } diff --git a/hw/xquartz/quartz.h b/hw/xquartz/quartz.h index c5da4c510..64ef122ae 100644 --- a/hw/xquartz/quartz.h +++ b/hw/xquartz/quartz.h @@ -33,8 +33,6 @@ #ifndef _QUARTZ_H #define _QUARTZ_H -#include "quartzPasteboard.h" - #include "screenint.h" #include "window.h" @@ -59,7 +57,7 @@ typedef Bool (*InitCursorProc)(ScreenPtr pScreen); * Suspend and resume X11 activity */ typedef void (*SuspendScreenProc)(ScreenPtr pScreen); -typedef void (*ResumeScreenProc)(ScreenPtr pScreen, int x, int y); +typedef void (*ResumeScreenProc)(ScreenPtr pScreen); /* * Screen state change support @@ -123,9 +121,9 @@ void QuartzInitInput(int argc, char **argv); void QuartzInitServer(int argc, char **argv, char **envp); void QuartzGiveUp(void); void QuartzProcessEvent(xEvent *xe); -void QuartzDisplayChangedHandler(int screenNum, xEventPtr xe, DeviceIntPtr dev, int nevents); +void QuartzUpdateScreens(void); -void QuartzShow(int x, int y); // (x, y) = cursor loc +void QuartzShow(void); void QuartzHide(void); void QuartzSetRootClip(BOOL enable); void QuartzSpaceChanged(uint32_t space_id); diff --git a/hw/xquartz/quartzCocoa.m b/hw/xquartz/quartzCocoa.m index 0ab94936c..450147207 100644 --- a/hw/xquartz/quartzCocoa.m +++ b/hw/xquartz/quartzCocoa.m @@ -40,66 +40,9 @@ #include "quartzCommon.h" #include "inputstr.h" -#include "quartzPasteboard.h" #include "darwin.h" -/* - * QuartzWriteCocoaPasteboard - * Write text to the Mac OS X pasteboard. - */ -void QuartzWriteCocoaPasteboard( - char *text) -{ - NSPasteboard *pasteboard; - NSArray *pasteboardTypes; - NSString *string; - - if (! text) return; - pasteboard = [NSPasteboard generalPasteboard]; - if (! pasteboard) return; - string = [NSString stringWithCString:text]; - if (! string) return; - pasteboardTypes = [NSArray arrayWithObject:NSStringPboardType]; - - // nil owner because we don't provide type translations - [pasteboard declareTypes:pasteboardTypes owner:nil]; - [pasteboard setString:string forType:NSStringPboardType]; -} - - -/* - * QuartzReadCocoaPasteboard - * Read text from the Mac OS X pasteboard and return it as a heap string. - * The caller must free the string. - */ -char *QuartzReadCocoaPasteboard(void) -{ - NSPasteboard *pasteboard; - NSArray *pasteboardTypes; - NSString *existingType; - char *text = NULL; - - pasteboardTypes = [NSArray arrayWithObject:NSStringPboardType]; - pasteboard = [NSPasteboard generalPasteboard]; - if (! pasteboard) return NULL; - - existingType = [pasteboard availableTypeFromArray:pasteboardTypes]; - if (existingType) { - NSString *string = [pasteboard stringForType:existingType]; - char *buffer; - - if (! string) return NULL; - buffer = (char *) [string UTF8String]; - text = (char *) malloc(strlen(buffer)+1); - if (text) - strcpy(text, buffer); - } - - return text; -} - - /* * QuartzFSUseQDCursor * Return whether the screen should use a QuickDraw cursor. diff --git a/hw/xquartz/quartzKeyboard.c b/hw/xquartz/quartzKeyboard.c index 503383f91..b3a4eccfb 100644 --- a/hw/xquartz/quartzKeyboard.c +++ b/hw/xquartz/quartzKeyboard.c @@ -354,7 +354,7 @@ void DarwinKeyboardInit(DeviceIntPtr pDev) { CopyKeyClass(pDev, inputInfo.keyboard); } -void DarwinKeyboardReloadHandler(int screenNum, xEventPtr xe, DeviceIntPtr pDev, int nevents) { +void DarwinKeyboardReloadHandler(void) { KeySymsRec keySyms; DEBUG_LOG("DarwinKeyboardReloadHandler\n"); diff --git a/hw/xquartz/quartzKeyboard.h b/hw/xquartz/quartzKeyboard.h index 215a4a9a5..1aaec6ef2 100644 --- a/hw/xquartz/quartzKeyboard.h +++ b/hw/xquartz/quartzKeyboard.h @@ -53,7 +53,7 @@ Bool QuartzReadSystemKeymap(darwinKeyboardInfo *info); /* Provided for darwinEvents.c */ extern darwinKeyboardInfo keyInfo; extern pthread_mutex_t keyInfo_mutex; -void DarwinKeyboardReloadHandler(int screenNum, xEventPtr xe, DeviceIntPtr dev, int nevents); +void DarwinKeyboardReloadHandler(void); int DarwinModifierNXKeycodeToNXKey(unsigned char keycode, int *outSide); int DarwinModifierNXKeyToNXKeycode(int key, int side); int DarwinModifierNXKeyToNXMask(int key); diff --git a/hw/xquartz/quartzPasteboard.c b/hw/xquartz/quartzPasteboard.c deleted file mode 100644 index 60bcabe4c..000000000 --- a/hw/xquartz/quartzPasteboard.c +++ /dev/null @@ -1,147 +0,0 @@ -/************************************************************** - * quartzPasteboard.c - * - * Aqua pasteboard <-> X cut buffer - * Greg Parker gparker@cs.stanford.edu March 8, 2001 - **************************************************************/ -/* - * Copyright (c) 2001 Greg Parker. All Rights Reserved. - * - * 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 ABOVE LISTED COPYRIGHT HOLDER(S) 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. - * - * Except as contained in this notice, the name(s) of the above copyright - * holders shall not be used in advertising or otherwise to promote the sale, - * use or other dealings in this Software without prior written authorization. - */ - -#ifdef HAVE_DIX_CONFIG_H -#include -#endif - -#include "misc.h" -#include "inputstr.h" -#include "quartzPasteboard.h" - -#include -#include "windowstr.h" -#include "propertyst.h" -#include "scrnintstr.h" -#include "selection.h" -#include "globals.h" - - -// Helper function to read the X11 cut buffer -// FIXME: What about multiple screens? Currently, this reads the first -// CUT_BUFFER0 from the first screen where the buffer content is a string. -// Returns a string on the heap that the caller must free. -// Returns NULL if there is no cut text or there is not enough memory. -static char * QuartzReadCutBuffer(void) -{ - int rc, i; - char *text = NULL; - - for (i = 0; i < screenInfo.numScreens; i++) { - ScreenPtr pScreen = screenInfo.screens[i]; - PropertyPtr pProp; - - rc = dixLookupProperty(&pProp, WindowTable[pScreen->myNum], - XA_CUT_BUFFER0, serverClient, DixReadAccess); - if (rc != Success) continue; - if (pProp->type != XA_STRING) continue; - if (pProp->format != 8) continue; - - text = xalloc(1 + pProp->size); - if (! text) continue; - memcpy(text, pProp->data, pProp->size); - text[pProp->size] = '\0'; - return text; - } - - // didn't find any text - return NULL; -} - -// Write X cut buffer to Mac OS X pasteboard -// Called by mieqProcessInputEvents() in response to request from X server thread. -void QuartzWritePasteboard(int screenNum, xEventPtr xe, DeviceIntPtr dev, int nevents) -{ - char *text; - text = QuartzReadCutBuffer(); - if (text) { - QuartzWriteCocoaPasteboard(text); - free(text); - } -} - -#define strequal(a, b) (0 == strcmp((a), (b))) - -// Read Mac OS X pasteboard into X cut buffer -// Called by mieqProcessInputEvents() in response to request from X server thread. -void QuartzReadPasteboard(int screenNum, xEventPtr xe, DeviceIntPtr dev, int nevents) -{ - char *oldText = QuartzReadCutBuffer(); - char *text = QuartzReadCocoaPasteboard(); - - // Compare text with current cut buffer contents. - // Change the buffer if both exist and are different - // OR if there is new text but no old text. - // Otherwise, don't clear the selection unnecessarily. - - if ((text && oldText && !strequal(text, oldText)) || - (text && !oldText)) { - int scrn, rc; - Selection *pSel; - - for (scrn = 0; scrn < screenInfo.numScreens; scrn++) { - ScreenPtr pScreen = screenInfo.screens[scrn]; - // Set the cut buffers on each screen - // fixme really on each screen? - dixChangeWindowProperty(serverClient, WindowTable[pScreen->myNum], - XA_CUT_BUFFER0, XA_STRING, 8, PropModeReplace, - strlen(text), (pointer)text, TRUE); - } - - // Undo any current X selection (similar to code in dispatch.c) - // FIXME: what about secondary selection? - // FIXME: only touch first XA_PRIMARY selection? - rc = dixLookupSelection(&pSel, XA_PRIMARY, serverClient, - DixSetAttrAccess); - if (rc == Success) { - // Notify client if necessary - if (pSel->client) { - xEvent event; - - event.u.u.type = SelectionClear; - event.u.selectionClear.time = GetTimeInMillis(); - event.u.selectionClear.window = pSel->window; - event.u.selectionClear.atom = pSel->selection; - TryClientEvents(pSel->client, dev, &event, 1, NoEventMask, - NoEventMask /*CantBeFiltered*/, NullGrab); - } - - // Erase it - pSel->pWin = NullWindow; - pSel->window = None; - pSel->client = NullClient; - } - } - - if (text) free(text); - if (oldText) free(oldText); -} diff --git a/hw/xquartz/quartzPasteboard.h b/hw/xquartz/quartzPasteboard.h deleted file mode 100644 index b51cd88e0..000000000 --- a/hw/xquartz/quartzPasteboard.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - QuartzPasteboard.h - - Mac OS X pasteboard <-> X cut buffer - Greg Parker gparker@cs.stanford.edu March 8, 2001 -*/ -/* - * Copyright (c) 2001 Greg Parker. All Rights Reserved. - * - * 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 ABOVE LISTED COPYRIGHT HOLDER(S) 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. - * - * Except as contained in this notice, the name(s) of the above copyright - * holders shall not be used in advertising or otherwise to promote the sale, - * use or other dealings in this Software without prior written authorization. - */ - -#ifndef _QUARTZPASTEBOARD_H -#define _QUARTZPASTEBOARD_H - -// Aqua->X -void QuartzReadPasteboard(int, xEventPtr, DeviceIntPtr, int); -char * QuartzReadCocoaPasteboard(void); // caller must free string - -// X->Aqua -void QuartzWritePasteboard(int, xEventPtr, DeviceIntPtr, int); -void QuartzWriteCocoaPasteboard(char *text); - -#endif /* _QUARTZPASTEBOARD_H */ diff --git a/hw/xquartz/xpr/xpr.h b/hw/xquartz/xpr/xpr.h index c657e1586..af1a90ca0 100644 --- a/hw/xquartz/xpr/xpr.h +++ b/hw/xquartz/xpr/xpr.h @@ -45,7 +45,7 @@ void xprHideWindows(Bool hide); Bool QuartzInitCursor(ScreenPtr pScreen); void QuartzSuspendXCursor(ScreenPtr pScreen); -void QuartzResumeXCursor(ScreenPtr pScreen, int x, int y); +void QuartzResumeXCursor(ScreenPtr pScreen); /* If we are rooted, we need the root window and desktop levels to be below * the menubar (24) but above native windows. Normal window level is 0. diff --git a/hw/xquartz/xpr/xprCursor.c b/hw/xquartz/xpr/xprCursor.c index 8c47b671c..84291a938 100644 --- a/hw/xquartz/xpr/xprCursor.c +++ b/hw/xquartz/xpr/xprCursor.c @@ -212,7 +212,7 @@ QuartzUnrealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor) * Set the cursor sprite and position. */ static void -QuartzSetCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor, int x, int y) +QuartzSetCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor) { QuartzCursorScreenPtr ScreenPriv = CURSOR_PRIV(pScreen); @@ -392,7 +392,7 @@ QuartzSuspendXCursor(ScreenPtr pScreen) * X server is showing. Restore the X cursor. */ void -QuartzResumeXCursor(ScreenPtr pScreen, int x, int y) +QuartzResumeXCursor(ScreenPtr pScreen) { WindowPtr pWin; CursorPtr pCursor; @@ -407,5 +407,5 @@ QuartzResumeXCursor(ScreenPtr pScreen, int x, int y) if (pCursor == NULL) return; - QuartzSetCursor(darwinPointer, pScreen, pCursor, x, y); + QuartzSetCursor(darwinPointer, pScreen, pCursor); } diff --git a/hw/xquartz/xpr/xprEvent.c b/hw/xquartz/xpr/xprEvent.c index f8e985aba..6245cce42 100644 --- a/hw/xquartz/xpr/xprEvent.c +++ b/hw/xquartz/xpr/xprEvent.c @@ -39,6 +39,7 @@ #include "windowstr.h" #include "pixmapstr.h" #include "inputstr.h" +#include "eventstr.h" #include "mi.h" #include "scrnintstr.h" #include "mipointer.h" @@ -55,36 +56,26 @@ #include "rootlessWindow.h" #include "xprEvent.h" -static void xprEventHandler(int screenNum, xEventPtr xe, DeviceIntPtr dev, int nevents) { - int i; - +Bool QuartzModeEventHandler(int screenNum, XQuartzEvent *e, DeviceIntPtr dev) { TA_SERVER(); - DEBUG_LOG("DarwinEventHandler(%d, %p, %p, %d)\n", screenNum, xe, dev, nevents); - for (i=0; isubtype) { + case kXquartzWindowState: + DEBUG_LOG("kXquartzWindowState\n"); + RootlessNativeWindowStateChanged(xprGetXWindow(e->data[0]), + e->data[1]); + return TRUE; + + case kXquartzWindowMoved: + DEBUG_LOG("kXquartzWindowMoved\n"); + RootlessNativeWindowMoved(xprGetXWindow(e->data[0])); + return TRUE; + + case kXquartzBringAllToFront: + DEBUG_LOG("kXquartzBringAllToFront\n"); + RootlessOrderAllWindows(); + return TRUE; + default: + return FALSE; } } - -void QuartzModeEQInit(void) { - mieqSetHandler(kXquartzWindowState, xprEventHandler); - mieqSetHandler(kXquartzWindowMoved, xprEventHandler); - mieqSetHandler(kXquartzBringAllToFront, xprEventHandler); -} diff --git a/hw/xquartz/xpr/xprEvent.h b/hw/xquartz/xpr/xprEvent.h index 5af9dfd77..ebfa36bd8 100644 --- a/hw/xquartz/xpr/xprEvent.h +++ b/hw/xquartz/xpr/xprEvent.h @@ -29,6 +29,6 @@ #ifndef __XPR_EVENT_H__ #define __XPR_EVENT_H__ -void QuartzModeEQInit(void); +Bool QuartzModeEventHandler(int screenNum, XQuartzEvent *e, DeviceIntPtr dev); #endif diff --git a/include/events.h b/include/events.h index 9f6a94c5b..375173adc 100644 --- a/include/events.h +++ b/include/events.h @@ -30,6 +30,9 @@ typedef struct _DeviceChangedEvent DeviceChangedEvent; typedef struct _DGAEvent DGAEvent; #endif typedef struct _RawDeviceEvent RawDeviceEvent; +#ifdef XQUARTZ +typedef struct _XQuartzEvent XQuartzEvent; +#endif typedef union _InternalEvent InternalEvent; #endif diff --git a/include/eventstr.h b/include/eventstr.h index 509982b46..0d5b1c62a 100644 --- a/include/eventstr.h +++ b/include/eventstr.h @@ -66,6 +66,9 @@ enum EventType { ET_RawButtonPress, ET_RawButtonRelease, ET_RawMotion, +#ifdef XQUARTZ + ET_XQuartz, +#endif ET_Internal = 0xFF /* First byte */ }; @@ -210,6 +213,18 @@ struct _RawDeviceEvent } valuators; }; +#ifdef XQUARTZ +#define XQUARTZ_EVENT_MAXARGS 5 +struct _XQuartzEvent { + unsigned char header; /**< Always ET_Internal */ + enum EventType type; /**< Always ET_XQuartz */ + int length; /**< Length in bytes */ + Time time; /**< Time in ms. */ + int subtype; /**< Subtype defined by XQuartz DDX */ + uint32_t data[XQUARTZ_EVENT_MAXARGS]; /**< Up to 5 32bit values passed to handler */ +}; +#endif + /** * Event type used inside the X server for input event * processing. @@ -227,6 +242,9 @@ union _InternalEvent { DGAEvent dga_event; #endif RawDeviceEvent raw_event; +#ifdef XQUARTZ + XQuartzEvent xquartz_event; +#endif }; #endif diff --git a/mi/mieq.c b/mi/mieq.c index 4c6c3bdc6..9b6d0c901 100644 --- a/mi/mieq.c +++ b/mi/mieq.c @@ -323,7 +323,8 @@ CopyGetMasterEvent(DeviceIntPtr sdev, CHECKEVENT(original); - if (!sdev->u.master) + /* ET_XQuartz has sdev == NULL */ + if (!sdev || !sdev->u.master) return NULL; switch(original->any.type) -- cgit v1.2.3 From ceaa5c779ceed3de5ea53727649613be3133b24e Mon Sep 17 00:00:00 2001 From: Jeremy Huddleston Date: Sun, 27 Sep 2009 18:25:57 -0700 Subject: XQuartz: Force a keymap resync on the first keypress to workaround XKB mucking with our keymap. We need to find a better way to work with XKB on this. --- hw/xquartz/X11Application.m | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m index 9fb192648..3cf7a7799 100644 --- a/hw/xquartz/X11Application.m +++ b/hw/xquartz/X11Application.m @@ -1180,6 +1180,17 @@ static inline int ensure_flag(int flags, int device_independent, int device_depe break; case NSKeyDown: case NSKeyUp: + { + /* XKB clobbers our keymap at startup, so we need to force it on the first keypress. + * TODO: Make this less of a kludge. + */ + static int force_resync_keymap = YES; + if(force_resync_keymap) { + DarwinSendDDXEvent(kXquartzReloadKeymap, 0); + force_resync_keymap = NO; + } + } + if(darwinSyncKeymap) { #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050 TISInputSourceRef key_layout = TISCopyCurrentKeyboardLayoutInputSource(); -- cgit v1.2.3 From de6cee11e1c335a0e5f708e7641e81d3cfe52529 Mon Sep 17 00:00:00 2001 From: Jeremy Huddleston Date: Sun, 27 Sep 2009 22:26:22 -0700 Subject: XQuartz: Fix inverse map from mode_switch to alt --- hw/xquartz/quartzKeyboard.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hw/xquartz/quartzKeyboard.c b/hw/xquartz/quartzKeyboard.c index b3a4eccfb..d36d967a2 100644 --- a/hw/xquartz/quartzKeyboard.c +++ b/hw/xquartz/quartzKeyboard.c @@ -251,6 +251,10 @@ static void DarwinBuildModifierMaps(darwinKeyboardInfo *info) { break; case XK_Mode_switch: + info->modifierKeycodes[NX_MODIFIERKEY_ALTERNATE][0] = i; +#ifdef NX_MODIFIERKEY_RALTERNATE + info->modifierKeycodes[NX_MODIFIERKEY_RALTERNATE][0] = i; +#endif info->modMap[MIN_KEYCODE + i] = Mod1Mask; break; -- cgit v1.2.3 From 29cb904e4de2411a9b6dbe68694954788f0525f7 Mon Sep 17 00:00:00 2001 From: Jeremy Huddleston Date: Sun, 27 Sep 2009 22:29:49 -0700 Subject: XQuartz: Nuke TSM It's deprecated in SnowLeopard. Ben and I both have no idea what it is for. It says something about unicode input, but urxvt seems fine taking in unicode, so /shrug... bye. --- hw/xquartz/X11Application.m | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m index 3cf7a7799..ad022c9ab 100644 --- a/hw/xquartz/X11Application.m +++ b/hw/xquartz/X11Application.m @@ -184,9 +184,6 @@ static void message_kit_thread (SEL selector, NSObject *arg) { } - (void) activateX:(OSX_BOOL)state { - /* Create a TSM document that supports full Unicode input, and - have it activated while X is active */ - static TSMDocumentID x11_document; size_t i; DEBUG_LOG("state=%d, _x_active=%d, \n", state, _x_active) if (state) { @@ -195,16 +192,6 @@ static void message_kit_thread (SEL selector, NSObject *arg) { bgMouseLocationUpdated = FALSE; } DarwinSendDDXEvent(kXquartzActivate, 0); - - if (!_x_active) { - if (x11_document == 0) { - OSType types[1]; - types[0] = kUnicodeDocument; - NewTSMDocument (1, types, &x11_document, 0); - } - - if (x11_document != 0) ActivateTSMDocument (x11_document); - } } else { if(darwin_all_modifier_flags) @@ -217,9 +204,6 @@ static void message_kit_thread (SEL selector, NSObject *arg) { } DarwinSendDDXEvent(kXquartzDeactivate, 0); - - if (_x_active && x11_document != 0) - DeactivateTSMDocument (x11_document); } _x_active = state; -- cgit v1.2.3 From 54000bdcbca52a2de31f7c1a1147de6d8e9dbbb8 Mon Sep 17 00:00:00 2001 From: Jeremy Huddleston Date: Sun, 27 Sep 2009 22:57:25 -0700 Subject: XQuartz: Fix a bunch of compilation warnings about style --- hw/xquartz/GL/visualConfigs.c | 2 +- hw/xquartz/X11Application.m | 17 ++++++++++------- hw/xquartz/X11Controller.m | 4 +++- hw/xquartz/applewm.c | 19 ++++--------------- hw/xquartz/darwinEvents.c | 5 +++-- hw/xquartz/mach-startup/bundle-main.c | 15 +++++++++------ hw/xquartz/mach-startup/launchd_fd.c | 2 +- hw/xquartz/mach-startup/stub.c | 16 +++++++++------- hw/xquartz/quartz.c | 2 +- hw/xquartz/quartz.h | 2 ++ hw/xquartz/quartzAudio.c | 2 ++ hw/xquartz/xpr/appledri.c | 2 +- hw/xquartz/xpr/x-hash.h | 2 +- hw/xquartz/xpr/xprFrame.c | 8 ++++---- hw/xquartz/xpr/xprScreen.c | 4 ++-- 15 files changed, 53 insertions(+), 49 deletions(-) diff --git a/hw/xquartz/GL/visualConfigs.c b/hw/xquartz/GL/visualConfigs.c index fee665d1d..f92677847 100644 --- a/hw/xquartz/GL/visualConfigs.c +++ b/hw/xquartz/GL/visualConfigs.c @@ -277,7 +277,7 @@ __GLXconfig *__glXAquaCreateVisualConfigs(int *numConfigsPtr, int screenNumber) (c-1)->next = NULL; if (c - visualConfigs != numConfigs) { - FatalError("numConfigs calculation error in setVisualConfigs! numConfigs is %d i is %d\n", numConfigs, c - visualConfigs); + FatalError("numConfigs calculation error in setVisualConfigs! numConfigs is %d i is %d\n", numConfigs, (int)(c - visualConfigs)); } freeGlCapabilities(&caps); diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m index ad022c9ab..749a8932b 100644 --- a/hw/xquartz/X11Application.m +++ b/hw/xquartz/X11Application.m @@ -243,23 +243,26 @@ static void message_kit_thread (SEL selector, NSObject *arg) { if(!for_appkit) { NSPoint NSlocation = [e locationInWindow]; NSWindow *window = [e window]; - + NSRect NSframe, NSvisibleFrame; + CGRect CGframe, CGvisibleFrame; + CGPoint CGlocation; + if (window != nil) { NSRect frame = [window frame]; NSlocation.x += frame.origin.x; NSlocation.y += frame.origin.y; } - NSRect NSframe = [[NSScreen mainScreen] frame]; - NSRect NSvisibleFrame = [[NSScreen mainScreen] visibleFrame]; + NSframe = [[NSScreen mainScreen] frame]; + NSvisibleFrame = [[NSScreen mainScreen] visibleFrame]; - CGRect CGframe = CGRectMake(NSframe.origin.x, NSframe.origin.y, + CGframe = CGRectMake(NSframe.origin.x, NSframe.origin.y, NSframe.size.width, NSframe.size.height); - CGRect CGvisibleFrame = CGRectMake(NSvisibleFrame.origin.x, + CGvisibleFrame = CGRectMake(NSvisibleFrame.origin.x, NSvisibleFrame.origin.y, NSvisibleFrame.size.width, NSvisibleFrame.size.height); - CGPoint CGlocation = CGPointMake(NSlocation.x, NSlocation.y); + CGlocation = CGPointMake(NSlocation.x, NSlocation.y); if(CGRectContainsPoint(CGframe, CGlocation) && !CGRectContainsPoint(CGvisibleFrame, CGlocation)) @@ -334,6 +337,7 @@ static void message_kit_thread (SEL selector, NSObject *arg) { case NSApplicationActivatedEventType: for_x = NO; if ([self modalWindow] == nil) { + BOOL switch_on_activate, ok; for_appkit = NO; /* FIXME: hack to avoid having to pass the event to appkit, @@ -344,7 +348,6 @@ static void message_kit_thread (SEL selector, NSObject *arg) { /* Get the Spaces preference for SwitchOnActivate */ (void)CFPreferencesAppSynchronize(CFSTR(".GlobalPreferences")); - BOOL switch_on_activate, ok; switch_on_activate = CFPreferencesGetAppBooleanValue(CFSTR("AppleSpacesSwitchOnActivate"), CFSTR(".GlobalPreferences"), &ok); if(!ok) switch_on_activate = YES; diff --git a/hw/xquartz/X11Controller.m b/hw/xquartz/X11Controller.m index f58747e15..d8d23ec2f 100644 --- a/hw/xquartz/X11Controller.m +++ b/hw/xquartz/X11Controller.m @@ -632,6 +632,8 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn row:(int)row - (IBAction)prefs_changed:sender { + BOOL pbproxy_active; + darwinFakeButtons = [fake_buttons intValue]; quartzUseSysBeep = [use_sysbeep intValue]; X11EnableKeyEquivalents = [enable_keyequivs intValue]; @@ -653,7 +655,7 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn row:(int)row [NSApp prefs_set_boolean:@PREFS_NO_TCP value:![enable_tcp intValue]]; [NSApp prefs_set_integer:@PREFS_DEPTH value:[depth selectedTag]]; - BOOL pbproxy_active = [sync_pasteboard intValue]; + pbproxy_active = [sync_pasteboard intValue]; [NSApp prefs_set_boolean:@PREFS_SYNC_PB value:pbproxy_active]; [NSApp prefs_set_boolean:@PREFS_SYNC_PB_TO_CLIPBOARD value:[sync_pasteboard_to_clipboard intValue]]; diff --git a/hw/xquartz/applewm.c b/hw/xquartz/applewm.c index 14be180a1..d2cca13f3 100644 --- a/hw/xquartz/applewm.c +++ b/hw/xquartz/applewm.c @@ -210,10 +210,7 @@ updateEventMask (WMEventPtr *pHead) /*ARGSUSED*/ static int -WMFreeClient (data, id) - pointer data; - XID id; -{ +WMFreeClient (pointer data, XID id) { WMEventPtr pEvent; WMEventPtr *pHead, pCur, pPrev; @@ -237,10 +234,7 @@ WMFreeClient (data, id) /*ARGSUSED*/ static int -WMFreeEvents (data, id) - pointer data; - XID id; -{ +WMFreeEvents (pointer data, XID id) { WMEventPtr *pHead, pCur, pNext; pHead = (WMEventPtr *) data; @@ -344,10 +338,7 @@ ProcAppleWMSelectInput (register ClientPtr client) */ void -AppleWMSendEvent (type, mask, which, arg) - int type, which, arg; - unsigned int mask; -{ +AppleWMSendEvent (int type, unsigned int mask, int which, int arg) { WMEventPtr *pHead, pEvent; ClientPtr client; xAppleWMNotifyEvent se; @@ -712,9 +703,7 @@ ProcAppleWMDispatch ( } static void -SNotifyEvent(from, to) - xAppleWMNotifyEvent *from, *to; -{ +SNotifyEvent(xAppleWMNotifyEvent *from, xAppleWMNotifyEvent *to) { to->type = from->type; to->kind = from->kind; cpswaps (from->sequenceNumber, to->sequenceNumber); diff --git a/hw/xquartz/darwinEvents.c b/hw/xquartz/darwinEvents.c index d300cce05..421efcedf 100644 --- a/hw/xquartz/darwinEvents.c +++ b/hw/xquartz/darwinEvents.c @@ -513,13 +513,14 @@ void DarwinSendProximityEvents(int ev_type, float pointer_x, float pointer_y) { void DarwinSendScrollEvents(float count_x, float count_y, float pointer_x, float pointer_y, float pressure, float tilt_x, float tilt_y) { + int sign_x, sign_y; if(!darwinEvents) { DEBUG_LOG("DarwinSendScrollEvents called before darwinEvents was initialized\n"); return; } - int sign_x = count_x > 0.0f ? SCROLLWHEELLEFTFAKE : SCROLLWHEELRIGHTFAKE; - int sign_y = count_y > 0.0f ? SCROLLWHEELUPFAKE : SCROLLWHEELDOWNFAKE; + sign_x = count_x > 0.0f ? SCROLLWHEELLEFTFAKE : SCROLLWHEELRIGHTFAKE; + sign_y = count_y > 0.0f ? SCROLLWHEELUPFAKE : SCROLLWHEELDOWNFAKE; count_x = fabs(count_x); count_y = fabs(count_y); diff --git a/hw/xquartz/mach-startup/bundle-main.c b/hw/xquartz/mach-startup/bundle-main.c index e887c469d..917bbafbe 100644 --- a/hw/xquartz/mach-startup/bundle-main.c +++ b/hw/xquartz/mach-startup/bundle-main.c @@ -149,15 +149,17 @@ static int accept_fd_handoff(int connected_fd) { char databuf[] = "display"; struct iovec iov[1]; - iov[0].iov_base = databuf; - iov[0].iov_len = sizeof(databuf); - union { struct cmsghdr hdr; char bytes[CMSG_SPACE(sizeof(int))]; } buf; struct msghdr msg; + struct cmsghdr *cmsg; + + iov[0].iov_base = databuf; + iov[0].iov_len = sizeof(databuf); + msg.msg_iov = iov; msg.msg_iovlen = 1; msg.msg_control = buf.bytes; @@ -166,7 +168,7 @@ static int accept_fd_handoff(int connected_fd) { msg.msg_namelen = 0; msg.msg_flags = 0; - struct cmsghdr *cmsg = CMSG_FIRSTHDR (&msg); + cmsg = CMSG_FIRSTHDR (&msg); cmsg->cmsg_level = SOL_SOCKET; cmsg->cmsg_type = SCM_RIGHTS; cmsg->cmsg_len = CMSG_LEN(sizeof(int)); @@ -197,6 +199,7 @@ static void socket_handoff_thread(void *arg) { socket_handoff_t *handoff_data = (socket_handoff_t *)arg; int launchd_fd = -1; int connected_fd; + unsigned remain; /* Now actually get the passed file descriptor from this connection * If we encounter an error, keep listening. @@ -229,7 +232,7 @@ static void socket_handoff_thread(void *arg) { * into it. */ - unsigned remain = 3000000; + remain = 3000000; fprintf(stderr, "X11.app: Received new $DISPLAY fd: %d ... sleeping to allow xinitrc to catchup.\n", launchd_fd); while((remain = usleep(remain)) > 0); @@ -626,11 +629,11 @@ static char *command_from_prefs(const char *key, const char *default_value) { if ((PlistRef == NULL) || (CFGetTypeID(PlistRef) != CFStringGetTypeID())) { CFStringRef cfDefaultValue = CFStringCreateWithCString(NULL, default_value, kCFStringEncodingASCII); + int len = strlen(default_value) + 1; CFPreferencesSetAppValue(cfKey, cfDefaultValue, kCFPreferencesCurrentApplication); CFPreferencesAppSynchronize(kCFPreferencesCurrentApplication); - int len = strlen(default_value) + 1; command = (char *)malloc(len * sizeof(char)); if(!command) return NULL; diff --git a/hw/xquartz/mach-startup/launchd_fd.c b/hw/xquartz/mach-startup/launchd_fd.c index fa623ea12..6dace8ea1 100644 --- a/hw/xquartz/mach-startup/launchd_fd.c +++ b/hw/xquartz/mach-startup/launchd_fd.c @@ -36,7 +36,7 @@ #include "launchd_fd.h" -int launchd_display_fd() { +int launchd_display_fd(void) { launch_data_t sockets_dict, checkin_request, checkin_response; launch_data_t listening_fd_array, listening_fd; diff --git a/hw/xquartz/mach-startup/stub.c b/hw/xquartz/mach-startup/stub.c index fd831a828..3d22db5d1 100644 --- a/hw/xquartz/mach-startup/stub.c +++ b/hw/xquartz/mach-startup/stub.c @@ -69,13 +69,12 @@ static char x11_path[PATH_MAX + 1]; static pid_t x11app_pid = 0; -static void set_x11_path() { +static void set_x11_path(void) { #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050 CFURLRef appURL = NULL; CFBundleRef bundle = NULL; OSStatus osstatus = LSFindApplicationForInfo(kLSUnknownCreator, CFSTR(kX11AppBundleId), nil, nil, &appURL); - UInt32 ver; switch (osstatus) { case noErr: @@ -148,15 +147,17 @@ static void send_fd_handoff(int connected_fd, int launchd_fd) { char databuf[] = "display"; struct iovec iov[1]; - iov[0].iov_base = databuf; - iov[0].iov_len = sizeof(databuf); - union { struct cmsghdr hdr; char bytes[CMSG_SPACE(sizeof(int))]; } buf; struct msghdr msg; + struct cmsghdr *cmsg; + + iov[0].iov_base = databuf; + iov[0].iov_len = sizeof(databuf); + msg.msg_iov = iov; msg.msg_iovlen = 1; msg.msg_control = buf.bytes; @@ -165,7 +166,7 @@ static void send_fd_handoff(int connected_fd, int launchd_fd) { msg.msg_namelen = 0; msg.msg_flags = 0; - struct cmsghdr *cmsg = CMSG_FIRSTHDR (&msg); + cmsg = CMSG_FIRSTHDR (&msg); cmsg->cmsg_level = SOL_SOCKET; cmsg->cmsg_type = SCM_RIGHTS; cmsg->cmsg_len = CMSG_LEN(sizeof(int)); @@ -231,10 +232,11 @@ int main(int argc, char **argv, char **envp) { kr = bootstrap_look_up(bootstrap_port, server_bootstrap_name, &mp); if(kr != KERN_SUCCESS) { + pid_t child; set_x11_path(); /* This forking is ugly and will be cleaned up later */ - pid_t child = fork(); + child = fork(); if(child == -1) { fprintf(stderr, "Xquartz: Could not fork: %s\n", strerror(errno)); return EXIT_FAILURE; diff --git a/hw/xquartz/quartz.c b/hw/xquartz/quartz.c index 64933135d..c4142a801 100644 --- a/hw/xquartz/quartz.c +++ b/hw/xquartz/quartz.c @@ -366,7 +366,7 @@ void QuartzSetRootless(Bool state) { * Calls mode specific screen resume to restore the X clip regions * (if needed) and the X server cursor state. */ -void QuartzShow() { +void QuartzShow(void) { int i; if (quartzServerVisible) diff --git a/hw/xquartz/quartz.h b/hw/xquartz/quartz.h index 64ef122ae..b1a3f3183 100644 --- a/hw/xquartz/quartz.h +++ b/hw/xquartz/quartz.h @@ -130,4 +130,6 @@ void QuartzSpaceChanged(uint32_t space_id); void QuartzSetFullscreen(Bool state); void QuartzSetRootless(Bool state); + +int server_main(int argc, char **argv, char **envp); #endif diff --git a/hw/xquartz/quartzAudio.c b/hw/xquartz/quartzAudio.c index 8cf241738..af63d18f5 100644 --- a/hw/xquartz/quartzAudio.c +++ b/hw/xquartz/quartzAudio.c @@ -311,8 +311,10 @@ void QuartzAudioInit(void) // Prepare for playback #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050 + { AudioDeviceIOProcID sInputIOProcID = NULL; status = AudioDeviceCreateIOProcID( outputDevice, QuartzAudioIOProc, &data, &sInputIOProcID ); + } #else status = AudioDeviceAddIOProc(outputDevice, QuartzAudioIOProc, &data); #endif diff --git a/hw/xquartz/xpr/appledri.c b/hw/xquartz/xpr/appledri.c index 835ccabaf..74a4ec315 100644 --- a/hw/xquartz/xpr/appledri.c +++ b/hw/xquartz/xpr/appledri.c @@ -255,10 +255,10 @@ ProcAppleDRIDestroySurface( register ClientPtr client ) { + int rc; REQUEST(xAppleDRIDestroySurfaceReq); DrawablePtr pDrawable; REQUEST_SIZE_MATCH(xAppleDRIDestroySurfaceReq); - int rc; rc = dixLookupDrawable(&pDrawable, stuff->drawable, client, 0, DixReadAccess); diff --git a/hw/xquartz/xpr/x-hash.h b/hw/xquartz/xpr/x-hash.h index 78bc7b317..f876b6b71 100644 --- a/hw/xquartz/xpr/x-hash.h +++ b/hw/xquartz/xpr/x-hash.h @@ -72,7 +72,7 @@ X_PFX (cvt_vptr_to_uint) (void * val) __attribute__((always_inline)); static __inline__ void * X_PFX (cvt_uint_to_vptr) (unsigned int val) { - return (void*)((size_t)(val)); + return (void*)((unsigned long)(val)); } static __inline__ unsigned int diff --git a/hw/xquartz/xpr/xprFrame.c b/hw/xquartz/xpr/xprFrame.c index 6635f08d8..a3e207616 100644 --- a/hw/xquartz/xpr/xprFrame.c +++ b/hw/xquartz/xpr/xprFrame.c @@ -215,10 +215,10 @@ xprDestroyFrame(RootlessFrameID wid) static void xprMoveFrame(RootlessFrameID wid, ScreenPtr pScreen, int newX, int newY) { - TA_SERVER(); - xp_window_changes wc; + TA_SERVER(); + wc.x = newX; wc.y = newY; // ErrorF("xprMoveFrame(%d, %p, %d, %d)\n", wid, pScreen, newX, newY); @@ -272,7 +272,7 @@ static void xprRestackFrame(RootlessFrameID wid, RootlessFrameID nextWid) { } if(window_hash) { - RootlessWindowRec *winRec = x_hash_table_lookup(window_hash, x_cvt_uint_to_vptr((xp_window_id)wid), NULL); + RootlessWindowRec *winRec = x_hash_table_lookup(window_hash, wid, NULL); if(winRec) { if(quartzEnableRootless) @@ -566,8 +566,8 @@ xprHideWindows(Bool hide) TA_SERVER(); for (screen = 0; screen < screenInfo.numScreens; screen++) { - pRoot = WindowTable[screenInfo.screens[screen]->myNum]; RootlessFrameID prevWid = NULL; + pRoot = WindowTable[screenInfo.screens[screen]->myNum]; for (pWin = pRoot->firstChild; pWin; pWin = pWin->nextSib) { RootlessWindowRec *winRec = WINREC(pWin); diff --git a/hw/xquartz/xpr/xprScreen.c b/hw/xquartz/xpr/xprScreen.c index 3387ecf0a..22a727e67 100644 --- a/hw/xquartz/xpr/xprScreen.c +++ b/hw/xquartz/xpr/xprScreen.c @@ -317,11 +317,11 @@ xprAddScreen(int index, ScreenPtr pScreen) if (noPseudoramiXExtension) { - ErrorF("Warning: noPseudoramiXExtension!\n"); - CGDirectDisplayID dpy; CGRect frame; + ErrorF("Warning: noPseudoramiXExtension!\n"); + dpy = displayAtIndex(index); frame = displayScreenBounds(dpy); -- cgit v1.2.3 From dadab5a2279a19dcf709402d7f22f0cd48670db0 Mon Sep 17 00:00:00 2001 From: Jeremy Huddleston Date: Sun, 27 Sep 2009 23:00:59 -0700 Subject: XQuartz: Fix QuartzSetCursor to match the expected prototype. --- hw/xquartz/xpr/xprCursor.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/xquartz/xpr/xprCursor.c b/hw/xquartz/xpr/xprCursor.c index 84291a938..b577fc099 100644 --- a/hw/xquartz/xpr/xprCursor.c +++ b/hw/xquartz/xpr/xprCursor.c @@ -212,7 +212,7 @@ QuartzUnrealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor) * Set the cursor sprite and position. */ static void -QuartzSetCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor) +QuartzSetCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor, int x, int y) { QuartzCursorScreenPtr ScreenPriv = CURSOR_PRIV(pScreen); @@ -407,5 +407,5 @@ QuartzResumeXCursor(ScreenPtr pScreen) if (pCursor == NULL) return; - QuartzSetCursor(darwinPointer, pScreen, pCursor); + QuartzSetCursor(darwinPointer, pScreen, pCursor, /* x */ 0, /* y */ 0); } -- cgit v1.2.3 From cf2e3312cff3f341e9edba8c321a4ca7ffd8748e Mon Sep 17 00:00:00 2001 From: Jeremy Huddleston Date: Sun, 27 Sep 2009 23:09:51 -0700 Subject: Rootless: Correct border rendering on parent-relative windows Resurected code from the punted RootlessPaintBackground/Border and added it conditionally to miPaintWindow --- mi/miexpose.c | 21 +++++++++++++++++++++ mi/miwindow.c | 1 + miext/rootless/rootlessWindow.c | 26 ++++++++++++++++++++++++++ 3 files changed, 48 insertions(+) diff --git a/mi/miexpose.c b/mi/miexpose.c index 6ce56ee85..1c9c3a436 100644 --- a/mi/miexpose.c +++ b/mi/miexpose.c @@ -518,6 +518,14 @@ miWindowExposures( WindowPtr pWin, RegionPtr prgn, RegionPtr other_exposed) REGION_DESTROY( pWin->drawable.pScreen, exposures); } +#ifdef ROOTLESS +/* Ugly, ugly, but we lost our hooks into miPaintWindow... =/ */ +void RootlessSetPixmapOfAncestors(WindowPtr pWin); +void RootlessStartDrawing(WindowPtr pWin); +void RootlessDamageRegion(WindowPtr pWin, RegionPtr prgn); +Bool IsFramedWindow(WindowPtr pWin); +#endif + void miPaintWindow(WindowPtr pWin, RegionPtr prgn, int what) { @@ -543,6 +551,19 @@ miPaintWindow(WindowPtr pWin, RegionPtr prgn, int what) Bool solid = TRUE; DrawablePtr drawable = &pWin->drawable; +#ifdef ROOTLESS + if(IsFramedWindow(pWin)) { + RootlessStartDrawing(pWin); + RootlessDamageRegion(pWin, prgn); + + if(pWin->backgroundState == ParentRelative) { + if((what == PW_BACKGROUND) || + (what == PW_BORDER && !pWin->borderIsPixel)) + RootlessSetPixmapOfAncestors(pWin); + } + } +#endif + if (what == PW_BACKGROUND) { while (pWin->backgroundState == ParentRelative) diff --git a/mi/miwindow.c b/mi/miwindow.c index 31c028482..c2333938e 100644 --- a/mi/miwindow.c +++ b/mi/miwindow.c @@ -1,3 +1,4 @@ + /*********************************************************** Copyright 1987, 1998 The Open Group diff --git a/miext/rootless/rootlessWindow.c b/miext/rootless/rootlessWindow.c index e273d0e38..d43301fc1 100644 --- a/miext/rootless/rootlessWindow.c +++ b/miext/rootless/rootlessWindow.c @@ -1684,3 +1684,29 @@ RootlessShowAllWindows (void) RootlessScreenExpose (pScreen); } } + +/* + * SetPixmapOfAncestors + * Set the Pixmaps on all ParentRelative windows up the ancestor chain. + */ +void +RootlessSetPixmapOfAncestors(WindowPtr pWin) +{ + ScreenPtr pScreen = pWin->drawable.pScreen; + WindowPtr topWin = TopLevelParent(pWin); + RootlessWindowRec *topWinRec = WINREC(topWin); + + while (pWin->backgroundState == ParentRelative) { + if (pWin == topWin) { + // disallow ParentRelative background state on top level + XID pixel = 0; + ChangeWindowAttributes(pWin, CWBackPixel, &pixel, serverClient); + RL_DEBUG_MSG("Cleared ParentRelative on 0x%x.\n", pWin); + break; + } + + pWin = pWin->parent; + pScreen->SetWindowPixmap(pWin, topWinRec->pixmap); + } +} + -- cgit v1.2.3 From b49dba33f94b51ba9a14803f0d81ccde2cb778f8 Mon Sep 17 00:00:00 2001 From: Ben Byer Date: Sun, 27 Sep 2009 10:35:53 -0700 Subject: Add (ok, fix) support for DTrace under OS X (cherry picked from commit 8428a57184f542941d2c8c90e97d18e111a69dd2) --- .gitignore | 1 + configure.ac | 8 +------- dix/Makefile.am | 2 ++ dix/Xserver.d | 7 ++++++- os/Makefile.am | 2 ++ 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index 3fb73f061..3a8fe501d 100644 --- a/.gitignore +++ b/.gitignore @@ -45,6 +45,7 @@ xorg-server.pc xorg-server-*.tar.bz2 xorg-server-*.tar.gz stamp-h? +dix/Xserver-dtrace.h do-not-use-config.h do-not-use-config.h.in dix/dix.c diff --git a/configure.ac b/configure.ac index 422ef0bf7..7d0abca8f 100644 --- a/configure.ac +++ b/configure.ac @@ -85,12 +85,6 @@ dnl ISDN trace program named dtrace AC_ARG_WITH(dtrace, AS_HELP_STRING([--with-dtrace=PATH], [Enable dtrace probes (default: enabled if dtrace found)]), [WDTRACE=$withval], [WDTRACE=auto]) -dnl Darwin 9 has dtrace, but it doesn't support compilation into ELF... -if test "x$WDTRACE" = xauto; then - case $host_os in - darwin*) WDTRACE="no" ;; - esac -fi if test "x$WDTRACE" = "xyes" -o "x$WDTRACE" = "xauto" ; then AC_PATH_PROG(DTRACE, [dtrace], [not_found], [$PATH:/usr/sbin]) if test "x$DTRACE" = "xnot_found" ; then @@ -1250,7 +1244,7 @@ AC_DEFINE(XSYNC, 1, [Support XSync extension]) AC_DEFINE(XCMISC, 1, [Support XCMisc extension]) AC_DEFINE(BIGREQS, 1, [Support BigRequests extension]) -if test "x$WDTRACE" != "xno" ; then +if test "x$WDTRACE" != "xno" && test "x$XQUARTZ" = "xno"; then DIX_LIB='$(top_builddir)/dix/dix.O' OS_LIB='$(top_builddir)/os/os.O' else diff --git a/dix/Makefile.am b/dix/Makefile.am index 13e5dedd7..23fe46007 100644 --- a/dix/Makefile.am +++ b/dix/Makefile.am @@ -54,6 +54,7 @@ Xserver-dtrace.h: $(srcdir)/Xserver.d $(DTRACE) -C -h -o $@ -s $(srcdir)/Xserver.d \ || cp Xserver-dtrace.h.in $@ +if !XQUARTZ # Generate dtrace object code for probes in libdix dtrace-dix.o: $(top_srcdir)/dix/Xserver.d $(am_libdix_la_OBJECTS) $(DTRACE) -G -C -o $@ -s $(top_srcdir)/dix/Xserver.d .libs/*.o @@ -63,6 +64,7 @@ noinst_PROGRAMS = dix.O dix.O: dtrace-dix.o $(am_libdix_la_OBJECTS) ld -r -o $@ .libs/*.o endif +endif dix.c: touch $@ diff --git a/dix/Xserver.d b/dix/Xserver.d index e4c9b8320..cea97e908 100644 --- a/dix/Xserver.d +++ b/dix/Xserver.d @@ -29,8 +29,13 @@ /* * Xserver dtrace provider definition */ - +#ifdef __APPLE__ +#define string char * +#define pid_t uint32_t +#define zoneid_t uint32_t +#else #include +#endif provider Xserver { /* reqType, data, length, client id, request buffer */ diff --git a/os/Makefile.am b/os/Makefile.am index f89da6ba2..9ce8ff274 100644 --- a/os/Makefile.am +++ b/os/Makefile.am @@ -41,6 +41,7 @@ endif EXTRA_DIST = $(SECURERPC_SRCS) $(INTERNALMALLOC_SRCS) \ $(XDMCP_SRCS) $(STRLCAT_SRCS) +if !XQUARTZ if XSERVER_DTRACE # Generate dtrace object code for probes in libos & libdix dtrace.o: $(top_srcdir)/dix/Xserver.d $(am_libos_la_OBJECTS) @@ -51,6 +52,7 @@ noinst_PROGRAMS = os.O os.O: dtrace.o $(am_libos_la_OBJECTS) ld -r -o $@ dtrace.o .libs/*.o endif +endif os.c: touch $@ -- cgit v1.2.3