summaryrefslogtreecommitdiffstats
path: root/x11vnc/macosxCGS.c
diff options
context:
space:
mode:
authorrunge <runge>2006-11-21 22:16:23 +0000
committerrunge <runge>2006-11-21 22:16:23 +0000
commit27a884d2f3775cf4d97ea8f3d7433cbe2deebbfc (patch)
treea4b7c9f0ae519b0afa0d14b646abca3ad01b35a8 /x11vnc/macosxCGS.c
parent05ba45f72e70b4372ef05a8aca34a3bddcfaeb71 (diff)
downloadlibvncserver-27a884d2f3775cf4d97ea8f3d7433cbe2deebbfc.zip
libvncserver-27a884d2f3775cf4d97ea8f3d7433cbe2deebbfc.tar.gz
x11vnc: Mac OS X fb fixes and cuttext, -nodpms option, local user wireframing
Diffstat (limited to 'x11vnc/macosxCGS.c')
-rw-r--r--x11vnc/macosxCGS.c88
1 files changed, 82 insertions, 6 deletions
diff --git a/x11vnc/macosxCGS.c b/x11vnc/macosxCGS.c
index 77c1ff7..df2e96e 100644
--- a/x11vnc/macosxCGS.c
+++ b/x11vnc/macosxCGS.c
@@ -15,6 +15,7 @@
extern CGDirectDisplayID displayID;
void macosxCGS_get_all_windows(void);
+void macosxGCS_set_pasteboard(char *str, int len);
typedef CGError CGSError;
typedef long CGSWindowCount;
@@ -79,12 +80,13 @@ void macosxCGS_get_all_windows(void) {
if (first) {
first = 0;
CGS_levelmax = 0;
- CGS_levels[CGS_levelmax++] = (int) kCGDraggingWindowLevel; /* 500 */
- if (0) CGS_levels[CGS_levelmax++] = (int) kCGHelpWindowLevel; /* 102 */
- if (0) CGS_levels[CGS_levelmax++] = (int) kCGPopUpMenuWindowLevel; /* 101 */
- CGS_levels[CGS_levelmax++] = (int) kCGMainMenuWindowLevelKey; /* 24 */
- CGS_levels[CGS_levelmax++] = (int) kCGFloatingWindowLevel; /* 3 */
- CGS_levels[CGS_levelmax++] = (int) kCGNormalWindowLevel; /* 0 */
+ CGS_levels[CGS_levelmax++] = (int) kCGDraggingWindowLevel; /* 500 ? */
+ if (0) CGS_levels[CGS_levelmax++] = (int) kCGHelpWindowLevel; /* 102 ? */
+ if (0) CGS_levels[CGS_levelmax++] = (int) kCGPopUpMenuWindowLevel; /* 101 pulldown menu */
+ CGS_levels[CGS_levelmax++] = (int) kCGMainMenuWindowLevelKey; /* 24 ? */
+ CGS_levels[CGS_levelmax++] = (int) kCGModalPanelWindowLevel; /* 8 open dialog box */
+ CGS_levels[CGS_levelmax++] = (int) kCGFloatingWindowLevel; /* 3 ? */
+ CGS_levels[CGS_levelmax++] = (int) kCGNormalWindowLevel; /* 0 regular window */
}
if (cid == NULL) {
@@ -152,5 +154,79 @@ if (db) fprintf(stderr, "i=%03d ID: %06d x: %03d y: %03d w: %03d h: %03d leve
}
}
+#if 1
+NSLock *pblock = nil;
+NSString *pbstr = nil;
+NSString *cuttext = nil;
+
+int pbcnt = -1;
+NSStringEncoding pbenc = NSWindowsCP1252StringEncoding;
+
+void macosxGCS_initpb(void) {
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+ pblock = [[NSLock alloc] init];
+ if (![NSPasteboard generalPasteboard]) {
+ fprintf(stderr, "macosxGCS_initpb: pasteboard inaccessible.\n");
+ pbcnt = 0;
+ pbstr = [[NSString alloc] initWithString:@"\e<PASTEBOARD INACCESSIBLE>\e"];
+ }
+ [pool release];
+}
+
+void macosxGCS_set_pasteboard(char *str, int len) {
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+ if (pbcnt != 0) {
+ [pblock lock];
+ [cuttext release];
+ cuttext = [[NSString alloc] initWithData:[NSData dataWithBytes:str length:len] encoding: pbenc];
+ if ([[NSPasteboard generalPasteboard] declareTypes:[NSArray arrayWithObject:NSStringPboardType] owner:nil]) {
+ NS_DURING
+ [[NSPasteboard generalPasteboard] setString:cuttext forType:NSStringPboardType];
+ NS_HANDLER
+ fprintf(stderr, "macosxGCS_set_pasteboard: problem writing to pasteboard\n");
+ NS_ENDHANDLER
+ } else {
+ fprintf(stderr, "macosxGCS_set_pasteboard: problem writing to pasteboard\n");
+ }
+ [cuttext release];
+ cuttext = nil;
+ [pblock unlock];
+ }
+ [pool release];
+}
+
+extern void macosx_send_sel(char *, int);
+
+void macosxGCS_poll_pb(void) {
+
+ static double dlast = 0.0;
+ double now = dnow();
+
+ if (now < dlast + 0.2) {
+ return;
+ }
+ dlast = now;
+
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+ [pblock lock];
+ if (pbcnt != [[NSPasteboard generalPasteboard] changeCount]) {
+ pbcnt = [[NSPasteboard generalPasteboard] changeCount];
+ [pbstr release];
+ pbstr = nil;
+ if ([[NSPasteboard generalPasteboard] availableTypeFromArray:[NSArray arrayWithObject:NSStringPboardType]]) {
+ pbstr = [[[NSPasteboard generalPasteboard] stringForType:NSStringPboardType] copy];
+ if (pbstr) {
+ NSData *str = [pbstr dataUsingEncoding:pbenc allowLossyConversion:YES];
+ if ([str length]) {
+ macosx_send_sel((char *) [str bytes], [str length]);
+ }
+ }
+ }
+ }
+ [pblock unlock];
+ [pool release];
+}
+#endif
+
#endif /* __APPLE__ */
OpenPOWER on IntegriCloud