diff options
author | Jeremy Huddleston <jeremyhu@freedesktop.org> | 2009-10-01 13:36:59 -0700 |
---|---|---|
committer | Jeremy Huddleston <jeremyhu@freedesktop.org> | 2009-10-01 13:36:59 -0700 |
commit | 385adb19afe5c6c6a88370a422b722fc06e50b23 (patch) | |
tree | b811dabbbb99564d29d8801df4e0630b87c951e5 | |
parent | 60f4fe18caebbc91f3feea3ff9e158273f40740d (diff) |
XQuartz: Dead code removal: quartzPasteboard.[hc]
(cherry picked from commit 9936b5b188dd85f169c41ef8ec46c9a210528c3f)
-rw-r--r-- | hw/xquartz/Makefile.am | 2 | ||||
-rw-r--r-- | hw/xquartz/darwinEvents.c | 2 | ||||
-rw-r--r-- | hw/xquartz/darwinEvents.h | 2 | ||||
-rw-r--r-- | hw/xquartz/quartz.h | 2 | ||||
-rw-r--r-- | hw/xquartz/quartzCocoa.m | 57 | ||||
-rw-r--r-- | hw/xquartz/quartzPasteboard.c | 147 | ||||
-rw-r--r-- | hw/xquartz/quartzPasteboard.h | 44 |
7 files changed, 0 insertions, 256 deletions
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 de2a60eb2..99306947a 100644 --- a/hw/xquartz/darwinEvents.c +++ b/hw/xquartz/darwinEvents.c @@ -331,8 +331,6 @@ Bool DarwinEQInit(void) { mieqSetHandler(kXquartzReloadPreferences, DarwinEventHandler); mieqSetHandler(kXquartzSetRootClip, DarwinEventHandler); mieqSetHandler(kXquartzQuit, DarwinEventHandler); - mieqSetHandler(kXquartzReadPasteboard, QuartzReadPasteboard); - mieqSetHandler(kXquartzWritePasteboard, QuartzWritePasteboard); mieqSetHandler(kXquartzToggleFullscreen, DarwinEventHandler); mieqSetHandler(kXquartzSetRootless, DarwinEventHandler); mieqSetHandler(kXquartzSpaceChanged, DarwinEventHandler); diff --git a/hw/xquartz/darwinEvents.h b/hw/xquartz/darwinEvents.h index 126851422..e1585fea8 100644 --- a/hw/xquartz/darwinEvents.h +++ b/hw/xquartz/darwinEvents.h @@ -54,8 +54,6 @@ enum { 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.h b/hw/xquartz/quartz.h index 257055158..c1169b139 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" 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,67 +40,10 @@ #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/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 <dix-config.h> -#endif - -#include "misc.h" -#include "inputstr.h" -#include "quartzPasteboard.h" - -#include <X11/Xatom.h> -#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 */ |