static void xprEventHandler(int screenNum, xEventPtr xe, DeviceIntPtr dev, int nevents) { int i; TA_SERVER(); DEBUG_LOG("DarwinEventHandler(%d, %p, %p, %d)\n", screenNum, xe, dev, nevents); for (i=0; i<nevents; i++) { switch(xe[i].u.u.type) { case kXquartzWindowState: DEBUG_LOG("kXquartzWindowState\n"); RootlessNativeWindowStateChanged(xprGetXWindow(xe[i].u.clientMessage.u.l.longs0), xe[i].u.clientMessage.u.l.longs1); break; case kXquartzWindowMoved: DEBUG_LOG("kXquartzWindowMoved\n"); RootlessNativeWindowMoved(xprGetXWindow(xe[i].u.clientMessage.u.l.longs0)); break; case kXquartzBringAllToFront: DEBUG_LOG("kXquartzBringAllToFront\n"); RootlessOrderAllWindows(); break; } } }
Bool QuartzModeEventHandler(int screenNum, XQuartzEvent *e, DeviceIntPtr dev) { switch (e->subtype) { 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"); /* There's no need to do xp_window_bring_all_to_front on Leopard, * and we don't care about the result, so just do it async. */ #if defined(HAVE_LIBDISPATCH) && defined(XPLUGIN_VERSION) && XPLUGIN_VERSION >= 6 # if defined(XPLUGIN_VERSION_MIN_REQUIRED) && XPLUGIN_VERSION_MIN_REQUIRED < 6 if (&xp_window_bring_all_to_front) { # endif dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ xp_window_bring_all_to_front(); }); # if defined(XPLUGIN_VERSION_MIN_REQUIRED) && XPLUGIN_VERSION_MIN_REQUIRED < 6 } else {
/* * Given the id of a physical window, try to find the top-level (or root) * X window that it represents. */ WindowPtr xprGetXWindowFromAppKit(int windowNumber) { RootlessWindowRec *winRec; Bool ret; xp_window_id wid; if (window_hash == NULL) return FALSE; /* need to lock, since this function can be called by any thread */ pthread_mutex_lock(&window_hash_mutex); if (xp_lookup_native_window(windowNumber, &wid)) ret = xprGetXWindow(wid) != NULL; else ret = FALSE; pthread_mutex_unlock(&window_hash_mutex); if (!ret) return NULL; winRec = x_hash_table_lookup(window_hash, x_cvt_uint_to_vptr(wid), NULL); return winRec != NULL ? winRec->win : NULL; }
/* * The windowNumber is an AppKit window number. Returns TRUE if xpr is * displaying a window with that number. */ Bool xprIsX11Window(void *nsWindow, int windowNumber) { Bool ret; xp_window_id wid; if (window_hash == NULL) return FALSE; /* need to lock, since this function can be called by any thread */ pthread_mutex_lock(&window_hash_mutex); if (xp_lookup_native_window(windowNumber, &wid)) ret = xprGetXWindow(wid) != NULL; else ret = FALSE; pthread_mutex_unlock(&window_hash_mutex); return ret; }