ClipboardPoll::ClipboardPoll() : xfixes_event_base( -1 ) { hide(); const char* names[ 6 ] = { "_QT_SELECTION_SENTINEL", "_QT_CLIPBOARD_SENTINEL", "CLIPBOARD", "TIMESTAMP", "KLIPPER_SELECTION_TIMESTAMP", "KLIPPER_CLIPBOARD_TIMESTAMP" }; Atom atoms[ 6 ]; XInternAtoms( QX11Info::display(), const_cast< char** >( names ), 6, False, atoms ); selection.sentinel_atom = atoms[ 0 ]; clipboard.sentinel_atom = atoms[ 1 ]; xa_clipboard = atoms[ 2 ]; xa_timestamp = atoms[ 3 ]; selection.timestamp_atom = atoms[ 4 ]; clipboard.timestamp_atom = atoms[ 5 ]; bool use_polling = true; kapp->installX11EventFilter( this ); timer.setSingleShot( false ); #ifdef HAVE_XFIXES int dummy; if( XFixesQueryExtension( QX11Info::display(), &xfixes_event_base, &dummy )) { XFixesSelectSelectionInput( QX11Info::display(), QX11Info::appRootWindow( 0 ), XA_PRIMARY, XFixesSetSelectionOwnerNotifyMask | XFixesSelectionWindowDestroyNotifyMask | XFixesSelectionClientCloseNotifyMask ); XFixesSelectSelectionInput( QX11Info::display(), QX11Info::appRootWindow( 0 ), xa_clipboard, XFixesSetSelectionOwnerNotifyMask | XFixesSelectionWindowDestroyNotifyMask | XFixesSelectionClientCloseNotifyMask ); use_polling = false; #ifdef NOISY_KLIPPER_ kDebug() << "Using XFIXES"; #endif } #endif if( use_polling ) { #ifdef NOISY_KLIPPER_ kDebug() << "Using polling"; #endif initPolling(); } }
void CompMgr::run() { dpy = XOpenDisplay(0); ::createAtomList(); XSetErrorHandler (error); if (!XRenderQueryExtension (dpy, &render_event, &render_error)) { fprintf (stderr, "No render extension\n"); return; } if (!XDamageQueryExtension (dpy, &damage_event, &damage_error)) { fprintf (stderr, "No damage extension\n"); return; } if (!XFixesQueryExtension (dpy, &xfixes_event, &xfixes_error)) { fprintf (stderr, "No XFixes extension\n"); return; } if (!register_cm(dpy)) return; Workspace* workspace = Workspace::instance(); qDebug("Composite Manager started."); while (!m_stop) { XEvent event; XNextEvent( dpy, &event ); workspace->x11Event( &event ); } qDebug("Composite Manager stopped."); delete workspace; XCloseDisplay (dpy); }
bool haveXfixes () { bool result = false; int event_base, error_base; if (XFixesQueryExtension(QX11Info::display(), &event_base, &error_base)) { int major, minor; XFixesQueryVersion(QX11Info::display(), &major, &minor); result = (major >= 2); } return result; }
static int setup_mouse(Display *dpy, int screen) { int ev_ret, ev_err; if (XFixesQueryExtension(dpy, &ev_ret, &ev_err)) { Window root = RootWindow(dpy, screen); XFixesSelectCursorInput(dpy, root, XFixesDisplayCursorNotifyMask); return 0; } return AVERROR(ENOSYS); }
int main(int argc, char** argv) { if (argc != 2 || !argv[1][0] || !argv[1][1]) { fprintf(stderr, "Usage: %s chrootdisplay\n", argv[0]); return 2; } /* Make sure the displays aren't equal */ char *cros_n = XDisplayName(NULL); if (cros_n[1] == argv[1][1]) { fprintf(stderr, "You must specify a different display.\n"); return 2; } /* Open the displays */ Display *cros_d, *chroot_d; Window cros_w, chroot_w; if (!(cros_d = XOpenDisplay(NULL))) { fprintf(stderr, "Failed to open Chromium OS display\n"); return 1; } if (!(chroot_d = XOpenDisplay(argv[1]))) { fprintf(stderr, "Failed to open chroot display %s\n", argv[1]); return 1; } /* Get the XFixes extension for the chroot to monitor the cursor */ int xfixes_event, xfixes_error; if (!XFixesQueryExtension(chroot_d, &xfixes_event, &xfixes_error)) { fprintf(stderr, "chroot is missing XFixes extension\n"); return 1; } XSetErrorHandler(error_handler); /* Get the root windows */ cros_w = DefaultRootWindow(cros_d); chroot_w = DefaultRootWindow(chroot_d); /* Monitor the chroot root window for cursor changes */ XFixesSelectCursorInput(chroot_d, chroot_w, XFixesDisplayCursorNotifyMask); XEvent e; while (!error) { XNextEvent(chroot_d, &e); if (error) break; if (e.type != xfixes_event + XFixesCursorNotify) continue; /* Grab the new cursor and apply it to the Chromium OS X11 server */ XFixesCursorImage *img = XFixesGetCursorImage(chroot_d); apply_cursor(cros_d, cros_w, img); XFree(img); } /* Clean up */ apply_cursor(cros_d, cros_w, NULL); XCloseDisplay(cros_d); XCloseDisplay(chroot_d); return 0; }
/* Connects to the X11 display, initializes extensions, register for events */ static int init_display(char* name) { dpy = XOpenDisplay(name); if (!dpy) { error("Cannot open display."); return -1; } /* We need XTest, XDamage and XFixes */ int event, error, major, minor; if (!XTestQueryExtension(dpy, &event, &error, &major, &minor)) { error("XTest not available!"); return -1; } if (!XDamageQueryExtension(dpy, &damageEvent, &error)) { error("XDamage not available!"); return -1; } if (!XFixesQueryExtension(dpy, &fixesEvent, &error)) { error("XFixes not available!"); return -1; } /* Get notified when new windows are created. */ Window root = DefaultRootWindow(dpy); XSelectInput(dpy, root, SubstructureNotifyMask); /* Register damage events for existing windows */ Window rootp, parent; Window *children; unsigned int i, nchildren; XQueryTree(dpy, root, &rootp, &parent, &children, &nchildren); /* FIXME: We never reset the handler, is that a good thing? */ XSetErrorHandler(xerror_handler); register_damage(dpy, root); for (i = 0; i < nchildren; i++) { register_damage(dpy, children[i]); } XFree(children); /* Register for cursor events */ XFixesSelectCursorInput(dpy, root, XFixesDisplayCursorNotifyMask); return 0; }
int xf_cursor_init(xfInfo* xfi) { int event; int error; if (!XFixesQueryExtension(xfi->display, &event, &error)) { fprintf(stderr, "XFixesQueryExtension failed\n"); return -1; } xfi->xfixes_notify_event = event + XFixesCursorNotify; XFixesSelectCursorInput(xfi->display, DefaultRootWindow(xfi->display), XFixesDisplayCursorNotifyMask); return 0; }
void rmdQueryExtensions(Display *dpy, ProgArgs *args, int *damage_event, int *damage_error, int *shm_opcode) { int xf_event_basep, xf_error_basep, shm_event_base, shm_error_base, shape_event_base, shape_error_base; if((!(args->full_shots))&&(!XDamageQueryExtension( dpy, damage_event, damage_error))) { fprintf(stderr,"XDamage extension not found!!!\n" "Try again using the --full-shots option, though\n" "enabling XDamage is highly recommended,\n" "for performance reasons.\n"); exit(4); } if((!args->noshared)&&(!XQueryExtension(dpy, "MIT-SHM", shm_opcode, &shm_event_base, &shm_error_base))) { args->noshared=1; fprintf(stderr,"Shared Memory extension not present!\n" "Try again using the --no-shared option\n"); exit(5); } if((args->xfixes_cursor)&& (XFixesQueryExtension(dpy,&xf_event_basep,&xf_error_basep)==False)) { args->xfixes_cursor=0; fprintf(stderr,"Xfixes extension not present!\n" "Please run with the -dummy-cursor or" " --no-cursor option.\n"); exit(6); } if((!args->noframe)&& (!XShapeQueryExtension(dpy,&shape_event_base,&shape_error_base))) { fprintf(stderr,"XShape Not Found!!!\n" "Frame won't be available.\n"); args->noframe=1; } }
static gboolean ccm_display_init_xfixes (CCMDisplay * self) { g_return_val_if_fail (self != NULL, FALSE); if (XFixesQueryExtension (self->priv->xdisplay, &self->priv->fixes.event_base, &self->priv->fixes.error_base)) { self->priv->fixes.available = TRUE; ccm_debug ("FIXES EVENT BASE: %i", self->priv->fixes.event_base); ccm_debug ("FIXES ERROR BASE: %i", self->priv->fixes.error_base); return TRUE; } return FALSE; }
void* X11Create(FcitxInstance* instance) { FcitxX11 *x11priv = fcitx_utils_new(FcitxX11); x11priv->dpy = XOpenDisplay(NULL); if (x11priv->dpy == NULL) return NULL; x11priv->owner = instance; x11priv->iScreen = DefaultScreen(x11priv->dpy); x11priv->rootWindow = DefaultRootWindow(x11priv->dpy); x11priv->eventWindow = XCreateWindow(x11priv->dpy, x11priv->rootWindow, 0, 0, 1, 1, 0, 0, InputOnly, CopyFromParent, 0, NULL); X11InitAtoms(x11priv); utarray_init(&x11priv->handlers, &handler_icd); utarray_init(&x11priv->comphandlers, &comphandler_icd); FcitxX11AddFunctions(instance); #ifdef HAVE_XFIXES int ignore; if (XFixesQueryExtension(x11priv->dpy, &x11priv->xfixesEventBase, &ignore)) x11priv->hasXfixes = true; #endif X11InitSelection(x11priv); X11InitComposite(x11priv); X11InitScreen(x11priv); XWindowAttributes attr; XGetWindowAttributes(x11priv->dpy, x11priv->rootWindow, &attr); if ((attr.your_event_mask & StructureNotifyMask) != StructureNotifyMask) { XSelectInput(x11priv->dpy, x11priv->rootWindow, attr.your_event_mask | StructureNotifyMask); } InitXErrorHandler(x11priv); X11DelayedCompositeTest(x11priv); FcitxInstanceAddTimeout(x11priv->owner, 5000, X11DelayedCompositeTest, x11priv); return x11priv; }
bool CursorTheme::haveXfixes() { bool result = false; #ifdef HAVE_XFIXES if (!QX11Info::isPlatformX11()) { return result; } int event_base, error_base; if (XFixesQueryExtension(QX11Info::display(), &event_base, &error_base)) { int major, minor; XFixesQueryVersion(QX11Info::display(), &major, &minor); result = (major >= 2); } #endif return result; }
int xf_cursor_init(xfInfo* xfi) { #ifdef WITH_XFIXES int event; int error; if (!XFixesQueryExtension(xfi->display, &event, &error)) { DEBUG_WARN( "XFixesQueryExtension failed\n"); return -1; } xfi->xfixes_notify_event = event + XFixesCursorNotify; XFixesSelectCursorInput(xfi->display, DefaultRootWindow(xfi->display), XFixesDisplayCursorNotifyMask); #endif return 0; }
static gboolean byzanz_recorder_prepare (ByzanzRecorder *recorder) { GdkDisplay *display; Display *dpy; display = gdk_display_get_default (); dpy = gdk_x11_display_get_xdisplay (display); if (!XDamageQueryExtension (dpy, &recorder->damage_event_base, &recorder->damage_error_base) || !XFixesQueryExtension (dpy, &recorder->fixes_event_base, &recorder->fixes_error_base)) return FALSE; gdk_x11_register_standard_event_type (display, recorder->damage_event_base + XDamageNotify, 1); gdk_x11_register_standard_event_type (display, recorder->fixes_event_base + XFixesCursorNotify, 1); return TRUE; }
int x11_shadow_xfixes_init(x11ShadowSubsystem* subsystem) { #ifdef WITH_XFIXES int xfixes_event; int xfixes_error; int major, minor; if (!XFixesQueryExtension(subsystem->display, &xfixes_event, &xfixes_error)) return -1; if (!XFixesQueryVersion(subsystem->display, &major, &minor)) return -1; subsystem->xfixes_cursor_notify_event = xfixes_event + XFixesCursorNotify; XFixesSelectCursorInput(subsystem->display, DefaultRootWindow(subsystem->display), XFixesDisplayCursorNotifyMask); return 1; #else return -1; #endif }
void stubCheckXExtensions(WindowInfo *pWindow) { int evb, erb, vmi=0, vma=0; Display *dpy = stubGetWindowDisplay(pWindow); stub.bXExtensionsChecked = GL_TRUE; stub.trackWindowVisibleRgn = 0; XLOCK(dpy); if (XCompositeQueryExtension(dpy, &evb, &erb) && XCompositeQueryVersion(dpy, &vma, &vmi) && (vma>0 || vmi>=4)) { stub.bHaveXComposite = GL_TRUE; crDebug("XComposite %i.%i", vma, vmi); vma=0; vmi=0; if (XFixesQueryExtension(dpy, &evb, &erb) && XFixesQueryVersion(dpy, &vma, &vmi) && vma>=2) { crDebug("XFixes %i.%i", vma, vmi); stub.bHaveXFixes = GL_TRUE; stub.trackWindowVisibleRgn = 1; XUNLOCK(dpy); return; } else { crWarning("XFixes not found or old version (%i.%i), no VisibilityTracking", vma, vmi); } } else { crWarning("XComposite not found or old version (%i.%i), no VisibilityTracking", vma, vmi); } XUNLOCK(dpy); return; }
FdoSelectionManagerPrivate(FdoSelectionManager *q) : q(q), notificationsEngine(0), haveComposite(false) { display = QX11Info::display(); selectionAtom = XInternAtom(display, "_NET_SYSTEM_TRAY_S" + QByteArray::number(QX11Info::appScreen()), false); opcodeAtom = XInternAtom(display, "_NET_SYSTEM_TRAY_OPCODE", false); messageAtom = XInternAtom(display, "_NET_SYSTEM_TRAY_MESSAGE_DATA", false); visualAtom = XInternAtom(display, "_NET_SYSTEM_TRAY_VISUAL", false); #if defined(HAVE_XFIXES) && defined(HAVE_XDAMAGE) && defined(HAVE_XCOMPOSITE) int eventBase, errorBase; bool haveXfixes = XFixesQueryExtension(display, &eventBase, &errorBase); bool haveXdamage = XDamageQueryExtension(display, &damageEventBase, &errorBase); bool haveXComposite = XCompositeQueryExtension(display, &eventBase, &errorBase); if (haveXfixes && haveXdamage && haveXComposite) { haveComposite = true; oldEventFilter = QCoreApplication::instance()->setEventFilter(x11EventFilter); } #endif }
static void xfixes_cursor_set_stage (ShellXFixesCursor *xfixes_cursor, ClutterStage *stage) { if (xfixes_cursor->stage == stage) return; if (xfixes_cursor->stage) { g_signal_handlers_disconnect_by_func (xfixes_cursor->stage, (void *)xfixes_cursor_on_stage_destroy, xfixes_cursor); clutter_x11_remove_filter (xfixes_cursor_event_filter, xfixes_cursor); } xfixes_cursor->stage = stage; if (xfixes_cursor->stage) { int error_base; xfixes_cursor->stage = stage; g_signal_connect (xfixes_cursor->stage, "destroy", G_CALLBACK (xfixes_cursor_on_stage_destroy), xfixes_cursor); clutter_x11_add_filter (xfixes_cursor_event_filter, xfixes_cursor); xfixes_cursor->have_xfixes = XFixesQueryExtension (clutter_x11_get_default_display (), &xfixes_cursor->xfixes_event_base, &error_base); if (xfixes_cursor->have_xfixes) XFixesSelectCursorInput (clutter_x11_get_default_display (), clutter_x11_get_stage_window (stage), XFixesDisplayCursorNotifyMask); xfixes_cursor_reset_image (xfixes_cursor); } }
KWindowSystemPrivate::KWindowSystemPrivate(int _what) : QWidget(0), NETRootInfo( QX11Info::display(), _what >= KWindowSystem::INFO_WINDOWS ? windows_properties : desktop_properties, 2, -1, false ), strutSignalConnected( false ), haveXfixes( false ), what( _what ) { KSystemEventFilter::installEventFilter(this); (void ) qApp->desktop(); //trigger desktop widget creation to select root window events #ifdef HAVE_XFIXES int errorBase; if ((haveXfixes = XFixesQueryExtension(QX11Info::display(), &xfixesEventBase, &errorBase))) { create_atoms(); XFixesSelectSelectionInput(QX11Info::display(), winId(), net_wm_cm, XFixesSetSelectionOwnerNotifyMask | XFixesSelectionWindowDestroyNotifyMask | XFixesSelectionClientCloseNotifyMask); compositingEnabled = XGetSelectionOwner(QX11Info::display(), net_wm_cm) != None; } #endif }
xfClipboard* xf_clipboard_new(xfContext* xfc) { int i, n = 0; rdpChannels* channels; xfClipboard* clipboard; if (!(clipboard = (xfClipboard*) calloc(1, sizeof(xfClipboard)))) { WLog_ERR(TAG, "failed to allocate xfClipboard data"); return NULL; } xfc->clipboard = clipboard; clipboard->xfc = xfc; channels = ((rdpContext*) xfc)->channels; clipboard->channels = channels; clipboard->system = ClipboardCreate(); clipboard->requestedFormatId = -1; clipboard->root_window = DefaultRootWindow(xfc->display); clipboard->clipboard_atom = XInternAtom(xfc->display, "CLIPBOARD", FALSE); if (clipboard->clipboard_atom == None) { WLog_ERR(TAG, "unable to get CLIPBOARD atom"); goto error; } clipboard->property_atom = XInternAtom(xfc->display, "_FREERDP_CLIPRDR", FALSE); clipboard->raw_transfer_atom = XInternAtom(xfc->display, "_FREERDP_CLIPRDR_RAW", FALSE); clipboard->raw_format_list_atom = XInternAtom(xfc->display, "_FREERDP_CLIPRDR_FORMATS", FALSE); xf_cliprdr_set_raw_transfer_enabled(clipboard, TRUE); XSelectInput(xfc->display, clipboard->root_window, PropertyChangeMask); #ifdef WITH_XFIXES if (XFixesQueryExtension(xfc->display, &clipboard->xfixes_event_base, &clipboard->xfixes_error_base)) { int xfmajor, xfminor; if (XFixesQueryVersion(xfc->display, &xfmajor, &xfminor)) { XFixesSelectSelectionInput(xfc->display, clipboard->root_window, clipboard->clipboard_atom, XFixesSetSelectionOwnerNotifyMask); clipboard->xfixes_supported = TRUE; } else { WLog_ERR(TAG, "Error querying X Fixes extension version"); } } else { WLog_ERR(TAG, "Error loading X Fixes extension"); } #else WLog_ERR(TAG, "Warning: Using clipboard redirection without XFIXES extension is strongly discouraged!"); #endif clipboard->clientFormats[n].atom = XInternAtom(xfc->display, "_FREERDP_RAW", False); clipboard->clientFormats[n].formatId = CF_RAW; n++; clipboard->clientFormats[n].atom = XInternAtom(xfc->display, "UTF8_STRING", False); clipboard->clientFormats[n].formatId = CF_UNICODETEXT; n++; clipboard->clientFormats[n].atom = XA_STRING; clipboard->clientFormats[n].formatId = CF_TEXT; n++; clipboard->clientFormats[n].atom = XInternAtom(xfc->display, "image/png", False); clipboard->clientFormats[n].formatId = CB_FORMAT_PNG; n++; clipboard->clientFormats[n].atom = XInternAtom(xfc->display, "image/jpeg", False); clipboard->clientFormats[n].formatId = CB_FORMAT_JPEG; n++; clipboard->clientFormats[n].atom = XInternAtom(xfc->display, "image/gif", False); clipboard->clientFormats[n].formatId = CB_FORMAT_GIF; n++; clipboard->clientFormats[n].atom = XInternAtom(xfc->display, "image/bmp", False); clipboard->clientFormats[n].formatId = CF_DIB; n++; clipboard->clientFormats[n].atom = XInternAtom(xfc->display, "text/html", False); clipboard->clientFormats[n].formatId = CB_FORMAT_HTML; clipboard->clientFormats[n].formatName = _strdup("HTML Format"); if (!clipboard->clientFormats[n].formatName) goto error; n++; /* * Existence of registered format IDs for file formats does not guarantee that they are * in fact supported by wClipboard (as further initialization may have failed after format * registration). However, they are definitely not supported if there are no registered * formats. In this case we should not list file formats in TARGETS. */ if (ClipboardGetFormatId(clipboard->system, "text/uri-list")) { clipboard->file_formats_registered = TRUE; clipboard->clientFormats[n].atom = XInternAtom(xfc->display, "text/uri-list", False); clipboard->clientFormats[n].formatId = CB_FORMAT_TEXTURILIST; clipboard->clientFormats[n].formatName = _strdup("FileGroupDescriptorW"); if (!clipboard->clientFormats[n].formatName) goto error; n++; } clipboard->numClientFormats = n; clipboard->targets[0] = XInternAtom(xfc->display, "TIMESTAMP", FALSE); clipboard->targets[1] = XInternAtom(xfc->display, "TARGETS", FALSE); clipboard->numTargets = 2; clipboard->incr_atom = XInternAtom(xfc->display, "INCR", FALSE); clipboard->delegate = ClipboardGetDelegate(clipboard->system); clipboard->delegate->custom = clipboard; clipboard->delegate->ClipboardFileSizeSuccess = xf_cliprdr_clipboard_file_size_success; clipboard->delegate->ClipboardFileSizeFailure = xf_cliprdr_clipboard_file_size_failure; clipboard->delegate->ClipboardFileRangeSuccess = xf_cliprdr_clipboard_file_range_success; clipboard->delegate->ClipboardFileRangeFailure = xf_cliprdr_clipboard_file_range_failure; return clipboard; error: for (i = 0; i < n; i++) free(clipboard->clientFormats[i].formatName); ClipboardDestroy(clipboard->system); free(clipboard); return NULL; }
xfClipboard* xf_clipboard_new(xfContext* xfc) { int n; UINT32 id; rdpChannels* channels; xfClipboard* clipboard; clipboard = (xfClipboard*) calloc(1, sizeof(xfClipboard)); xfc->clipboard = clipboard; clipboard->xfc = xfc; channels = ((rdpContext*) xfc)->channels; clipboard->channels = channels; clipboard->system = ClipboardCreate(); clipboard->requestedFormatId = -1; clipboard->root_window = DefaultRootWindow(xfc->display); clipboard->clipboard_atom = XInternAtom(xfc->display, "CLIPBOARD", FALSE); if (clipboard->clipboard_atom == None) { WLog_ERR(TAG, "unable to get CLIPBOARD atom"); free(clipboard); return NULL; } id = 1; clipboard->property_atom = XInternAtom(xfc->display, "_FREERDP_CLIPRDR", FALSE); clipboard->identity_atom = XInternAtom(xfc->display, "_FREERDP_CLIPRDR_ID", FALSE); XChangeProperty(xfc->display, xfc->drawable, clipboard->identity_atom, XA_INTEGER, 32, PropModeReplace, (BYTE*) &id, 1); XSelectInput(xfc->display, clipboard->root_window, PropertyChangeMask); #ifdef WITH_XFIXES if (XFixesQueryExtension(xfc->display, &clipboard->xfixes_event_base, &clipboard->xfixes_error_base)) { int xfmajor, xfminor; if (XFixesQueryVersion(xfc->display, &xfmajor, &xfminor)) { XFixesSelectSelectionInput(xfc->display, clipboard->root_window, clipboard->clipboard_atom, XFixesSetSelectionOwnerNotifyMask); clipboard->xfixes_supported = TRUE; } else { WLog_ERR(TAG, "Error querying X Fixes extension version"); } } else { WLog_ERR(TAG, "Error loading X Fixes extension"); } #else WLog_ERR(TAG, "Warning: Using clipboard redirection without XFIXES extension is strongly discouraged!"); #endif n = 0; clipboard->clientFormats[n].atom = XInternAtom(xfc->display, "_FREERDP_RAW", False); clipboard->clientFormats[n].formatId = 0; n++; clipboard->clientFormats[n].atom = XInternAtom(xfc->display, "UTF8_STRING", False); clipboard->clientFormats[n].formatId = CF_UNICODETEXT; n++; clipboard->clientFormats[n].atom = XA_STRING; clipboard->clientFormats[n].formatId = CF_TEXT; n++; clipboard->clientFormats[n].atom = XInternAtom(xfc->display, "image/png", False); clipboard->clientFormats[n].formatId = CB_FORMAT_PNG; n++; clipboard->clientFormats[n].atom = XInternAtom(xfc->display, "image/jpeg", False); clipboard->clientFormats[n].formatId = CB_FORMAT_JPEG; n++; clipboard->clientFormats[n].atom = XInternAtom(xfc->display, "image/gif", False); clipboard->clientFormats[n].formatId = CB_FORMAT_GIF; n++; clipboard->clientFormats[n].atom = XInternAtom(xfc->display, "image/bmp", False); clipboard->clientFormats[n].formatId = CF_DIB; n++; clipboard->clientFormats[n].atom = XInternAtom(xfc->display, "text/html", False); clipboard->clientFormats[n].formatId = CB_FORMAT_HTML; clipboard->clientFormats[n].formatName = _strdup("HTML Format"); if (!clipboard->clientFormats[n].formatName) { ClipboardDestroy(clipboard->system); free(clipboard); return NULL; } n++; clipboard->numClientFormats = n; clipboard->targets[0] = XInternAtom(xfc->display, "TIMESTAMP", FALSE); clipboard->targets[1] = XInternAtom(xfc->display, "TARGETS", FALSE); clipboard->numTargets = 2; clipboard->incr_atom = XInternAtom(xfc->display, "INCR", FALSE); return clipboard; }
void Extensions::init() { int event_base, error_base; data_nextensions = 0; shape_version = 0; if( XShapeQueryExtension( display(), &shape_event_base, &error_base )) { int major, minor; if( XShapeQueryVersion( display(), &major, &minor )) { shape_version = major * 0x10 + minor; addData( "SHAPE" ); } } #ifdef HAVE_XRANDR has_randr = XRRQueryExtension( display(), &randr_event_base, &error_base ); if( has_randr ) { int major, minor; XRRQueryVersion( display(), &major, &minor ); has_randr = ( major > 1 || ( major == 1 && minor >= 1 ) ); addData( "RANDR" ); } #else has_randr = false; #endif #ifdef HAVE_XDAMAGE has_damage = XDamageQueryExtension( display(), &damage_event_base, &error_base ); if( has_damage ) addData( "DAMAGE" ); #else has_damage = false; #endif composite_version = 0; #ifdef HAVE_XCOMPOSITE if( XCompositeQueryExtension( display(), &event_base, &error_base )) { int major = 0, minor = 0; XCompositeQueryVersion( display(), &major, &minor ); composite_version = major * 0x10 + minor; addData( "Composite" ); } #endif fixes_version = 0; #ifdef HAVE_XFIXES if( XFixesQueryExtension( display(), &event_base, &error_base )) { int major = 0, minor = 0; XFixesQueryVersion( display(), &major, &minor ); fixes_version = major * 0x10 + minor; addData( "XFIXES" ); } #endif render_version = 0; #ifdef HAVE_XRENDER if( XRenderQueryExtension( display(), &event_base, &error_base )) { int major = 0, minor = 0; XRenderQueryVersion( display(), &major, &minor ); render_version = major * 0x10 + minor; addData( "RENDER" ); } #endif has_glx = false; #ifdef HAVE_OPENGL has_glx = glXQueryExtension( display(), &event_base, &error_base ); if( has_glx ) addData( "GLX" ); #endif #ifdef HAVE_XSYNC if( XSyncQueryExtension( display(), &sync_event_base, &error_base )) { int major = 0, minor = 0; if( XSyncInitialize( display(), &major, &minor )) { has_sync = true; addData( "SYNC" ); } } #endif kDebug( 1212 ) << "Extensions: shape: 0x" << QString::number( shape_version, 16 ) << " composite: 0x" << QString::number( composite_version, 16 ) << " render: 0x" << QString::number( render_version, 16 ) << " fixes: 0x" << QString::number( fixes_version, 16 ) << endl; }
KSnapshot::KSnapshot(QWidget *parent, KSnapshotObject::CaptureMode mode ) : QDialog(parent), KSnapshotObject(), modified(true), savedPosition(QPoint(-1, -1)) { // TEMPORARY Make sure "untitled" enters the string freeze for 4.6, // as explained in http://lists.kde.org/?l=kde-graphics-devel&m=128942871430175&w=2 const QString untitled = QString(tr("untitled")); setWindowTitle(""); grabber = new QWidget( 0, Qt::X11BypassWindowManagerHint ); // TODO X11 (Xinerama and Twinview, actually) and Windows use different coordinates for the two monitors case // // On Windows, there are two displays. The origin (0, 0) ('o') is the top left of display 1. If display 2 is to the left, then coordinates in display 2 are negative: // .-------. // | |o-----. // | 2 | | // | | 1 | // ._______.._____. // // On Xinerama and Twinview, there is only one display and two screens. The origin (0, 0) ('o') is the top left of the display: // o-------. // | |.-----. // | 2 | | // | | 1 | // ._______.._____. // // Instead of moving to (-10000, -10000), we should compute how many displays are and make sure we move to somewhere out of the total coordinates. // - Windows: use GetSystemMetrics ( http://msdn.microsoft.com/en-us/library/ms724385(v=vs.85).aspx ) // If moving to a negative position, we need to count the size of the dialog; moving to a positive position avoids having to compute the size of the dialog grabber->move( -10000, -10000 ); // FIXME Read above grabber->installEventFilter( this ); QVBoxLayout *vbox = new QVBoxLayout( this ); setLayout(vbox); mainWidget = new KSnapshotWidget(); vbox->addWidget(mainWidget); connect(mainWidget->ok_btn, SIGNAL(clicked()), SLOT(onOkBtnClicked())); connect(mainWidget->cancel_btn, SIGNAL(clicked()), SLOT(onCancelBtnClicked())); connect(mainWidget->save_btn, SIGNAL(clicked()), SLOT(onSaveBtnClicked())); connect(mainWidget->help_btn, SIGNAL(clicked()), SLOT(onHelpBtnClicked())); connect(mainWidget->lblImage, SIGNAL(startDrag()), SLOT(slotDragSnapshot())); connect(mainWidget->btnNew, SIGNAL(clicked()), SLOT(slotGrab())); connect(mainWidget->comboMode, SIGNAL(activated(int)), SLOT(slotModeChanged(int))); if (qApp->desktop()->numScreens() < 2) { mainWidget->comboMode->removeItem(CurrentScreen); } mainWidget->spinDelay->setSuffix(tr(" second", " seconds")); grabber->show(); grabber->grabMouse(); #ifdef HAVE_X11_EXTENSIONS_XFIXES_H { int tmp1, tmp2; //Check whether the XFixes extension is available Display *dpy = QX11Info::display(); if (!XFixesQueryExtension( dpy, &tmp1, &tmp2 )) { mainWidget->cbIncludePointer->hide(); mainWidget->lblIncludePointer->hide(); } } #elif !defined(Q_WS_WIN) mainWidget->cbIncludePointer->hide(); mainWidget->lblIncludePointer->hide(); #endif setMode(KSnapshotObject::Region); qDebug() << "Mode = " << mode; if ( mode == KSnapshotObject::FullScreen ) { snapshot = QPixmap::grabWindow( QApplication::desktop()->winId() ); #ifdef HAVE_X11_EXTENSIONS_XFIXES_H if ( haveXFixes && includePointer() ) grabPointerImage(0, 0); #endif } else if ( mode == KSnapshotObject::CurrentScreen ) { qDebug() << "Desktop Geom = " << QApplication::desktop()->geometry(); QDesktopWidget *desktop = QApplication::desktop(); int screenId = desktop->screenNumber( QCursor::pos() ); qDebug() << "Screenid = " << screenId; QRect geom = desktop->screenGeometry( screenId ); qDebug() << "Geometry = " << screenId; snapshot = QPixmap::grabWindow( desktop->winId(), geom.x(), geom.y(), geom.width(), geom.height() ); } else { setMode( mode ); switch(mode) { case KSnapshotObject::WindowUnderCursor: { setIncludeDecorations( true ); performGrab(); break; } case KSnapshotObject::ChildWindow: { slotGrab(); break; } case KSnapshotObject::Region: { grabRegion(); break; } case KSnapshotObject::FreeRegion: { grabFreeRegion(); break; } default: break; } } //When we use argument to take snapshot we mustn't hide it. if (mode != KSnapshotObject::ChildWindow) { grabber->releaseMouse(); grabber->hide(); } setDelay(0); file_path_ = QQGlobal::tempDir() + "/snapshot/snapshot.png"; connect( &grabTimer, SIGNAL(timeout()), this, SLOT(grabTimerDone()) ); connect( &updateTimer, SIGNAL(timeout()), this, SLOT(updatePreview()) ); QTimer::singleShot( 0, this, SLOT(updateCaption()) ); new QShortcut( Qt::Key_S, mainWidget->ok_btn, SLOT(animateClick())); new QShortcut( Qt::Key_N, mainWidget->btnNew, SLOT(animateClick()) ); new QShortcut( Qt::Key_Space, mainWidget->btnNew, SLOT(animateClick()) ); mainWidget->ok_btn->setFocus(); resize(QSize(400, 500)); move((QApplication::desktop()->width() - this->width()) /2, (QApplication::desktop()->height() - this->height()) /2); }