mirror of
https://gitlab.freedesktop.org/xorg/xserver.git
synced 2026-01-08 11:50:15 +01:00
XQuartz: Dead code removal: quartzPasteboard.[hc]
(cherry picked from commit 9936b5b188)
This commit is contained in:
parent
2a4a79a225
commit
246fcc7bbb
7 changed files with 0 additions and 264 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -332,8 +332,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);
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -33,8 +33,6 @@
|
|||
#ifndef _QUARTZ_H
|
||||
#define _QUARTZ_H
|
||||
|
||||
#include "quartzPasteboard.h"
|
||||
|
||||
#include "screenint.h"
|
||||
#include "window.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -1,155 +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"
|
||||
|
||||
extern Selection *CurrentSelections;
|
||||
extern int NumCurrentSelections;
|
||||
|
||||
|
||||
// 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 i;
|
||||
char *text = NULL;
|
||||
|
||||
for (i = 0; i < screenInfo.numScreens; i++) {
|
||||
ScreenPtr pScreen = screenInfo.screens[i];
|
||||
PropertyPtr pProp;
|
||||
|
||||
pProp = wUserProps (WindowTable[pScreen->myNum]);
|
||||
while (pProp && pProp->propertyName != XA_CUT_BUFFER0) {
|
||||
pProp = pProp->next;
|
||||
}
|
||||
if (! pProp) 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, sel;
|
||||
|
||||
for (scrn = 0; scrn < screenInfo.numScreens; scrn++) {
|
||||
ScreenPtr pScreen = screenInfo.screens[scrn];
|
||||
// Set the cut buffers on each screen
|
||||
// fixme really on each screen?
|
||||
ChangeWindowProperty(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?
|
||||
sel = 0;
|
||||
while ((sel < NumCurrentSelections) &&
|
||||
CurrentSelections[sel].selection != XA_PRIMARY)
|
||||
sel++;
|
||||
if (sel < NumCurrentSelections) {
|
||||
// Notify client if necessary
|
||||
if (CurrentSelections[sel].client) {
|
||||
xEvent event;
|
||||
|
||||
event.u.u.type = SelectionClear;
|
||||
event.u.selectionClear.time = GetTimeInMillis();
|
||||
event.u.selectionClear.window = CurrentSelections[sel].window;
|
||||
event.u.selectionClear.atom = CurrentSelections[sel].selection;
|
||||
TryClientEvents(CurrentSelections[sel].client, &event, 1,
|
||||
NoEventMask, NoEventMask /*CantBeFiltered*/,
|
||||
NullGrab);
|
||||
}
|
||||
|
||||
// Erase it
|
||||
// FIXME: need to erase .selection too? dispatch.c doesn't
|
||||
CurrentSelections[sel].pWin = NullWindow;
|
||||
CurrentSelections[sel].window = None;
|
||||
CurrentSelections[sel].client = NullClient;
|
||||
}
|
||||
}
|
||||
|
||||
if (text) free(text);
|
||||
if (oldText) free(oldText);
|
||||
}
|
||||
|
|
@ -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 */
|
||||
Loading…
Add table
Reference in a new issue