static VALUE gdkwin_lookup(int argc, VALUE *argv, VALUE self) { VALUE arg[2]; GdkWindow * win = NULL; rb_scan_args(argc, argv, "11", &arg[0], &arg[1]); switch(argc) { case 1: win = gdk_window_lookup(RVAL2GDKNATIVEWINDOW(arg[0])); break; case 2: #if GTK_CHECK_VERSION(2,2,0) win = gdk_window_lookup_for_display(RVAL2GOBJ(arg[0]), RVAL2GDKNATIVEWINDOW(arg[1])); #else win = gdk_window_lookup(NUM2UINT(arg[1])); rb_warn("Not supported in GTK+-2.0.x."); #endif break; } if (win == NULL) return Qnil; else { return GOBJ2RVAL(win); } }
static void egg_tray_icon_unrealize (GtkWidget *widget) { EggTrayIcon *icon = EGG_TRAY_ICON (widget); GdkWindow *root_window; if (icon->manager_window != None) { GdkWindow *gdkwin; #if GTK_CHECK_VERSION(2,1,0) gdkwin = gdk_window_lookup_for_display (gtk_widget_get_display (widget), icon->manager_window); #else gdkwin = gdk_window_lookup (icon->manager_window); #endif gdk_window_remove_filter (gdkwin, egg_tray_icon_manager_filter, icon); } #if GTK_CHECK_VERSION(2,1,0) root_window = gdk_screen_get_root_window (gtk_widget_get_screen (widget)); #else root_window = gdk_window_lookup (gdk_x11_get_default_root_xwindow ()); #endif gdk_window_remove_filter (root_window, egg_tray_icon_manager_filter, icon); if (GTK_WIDGET_CLASS (parent_class)->unrealize) (* GTK_WIDGET_CLASS (parent_class)->unrealize) (widget); }
nsresult nsPluginNativeWindowGtk2::CreateXEmbedWindow() { NS_ASSERTION(!mSocketWidget,"Already created a socket widget!"); GdkWindow *parent_win = gdk_window_lookup((XID)window); mSocketWidget = gtk_socket_new(); //attach the socket to the container widget gtk_widget_set_parent_window(mSocketWidget, parent_win); // Make sure to handle the plug_removed signal. If we don't the // socket will automatically be destroyed when the plug is // removed, which means we're destroying it more than once. // SYNTAX ERROR. g_signal_connect(mSocketWidget, "plug_removed", G_CALLBACK(plug_removed_cb), NULL); g_signal_connect(mSocketWidget, "unrealize", G_CALLBACK(socket_unrealize_cb), NULL); g_signal_connect(mSocketWidget, "destroy", G_CALLBACK(gtk_widget_destroyed), &mSocketWidget); gpointer user_data = NULL; gdk_window_get_user_data(parent_win, &user_data); GtkContainer *container = GTK_CONTAINER(user_data); gtk_container_add(container, mSocketWidget); gtk_widget_realize(mSocketWidget); // The GtkSocket has a visible window, but the plugin's XEmbed plug will // cover this window. Normally GtkSockets let the X server paint their // background and this would happen immediately (before the plug is // created). Setting the background to None prevents the server from // painting this window, avoiding flicker. gdk_window_set_back_pixmap(mSocketWidget->window, NULL, FALSE); // Resize before we show SetAllocation(); gtk_widget_show(mSocketWidget); gdk_flush(); window = (void*)gtk_socket_get_id(GTK_SOCKET(mSocketWidget)); // Fill out the ws_info structure. // (The windowless case is done in nsObjectFrame.cpp.) GdkWindow *gdkWindow = gdk_window_lookup((XID)window); if(!gdkWindow) return NS_ERROR_FAILURE; mWsInfo.display = GDK_WINDOW_XDISPLAY(gdkWindow); mWsInfo.colormap = GDK_COLORMAP_XCOLORMAP(gdk_drawable_get_colormap(gdkWindow)); GdkVisual* gdkVisual = gdk_drawable_get_visual(gdkWindow); mWsInfo.visual = GDK_VISUAL_XVISUAL(gdkVisual); mWsInfo.depth = gdkVisual->depth; return NS_OK; }
static void egg_tray_icon_update_manager_window (EggTrayIcon *icon) { Display *xdisplay; #if HAVE_GTK_MULTIHEAD xdisplay = GDK_DISPLAY_XDISPLAY (gtk_widget_get_display (GTK_WIDGET (icon))); #else xdisplay = gdk_display; #endif if (icon->manager_window != None) { GdkWindow *gdkwin; #if HAVE_GTK_MULTIHEAD gdkwin = gdk_window_lookup_for_display (display, icon->manager_window); #else gdkwin = gdk_window_lookup (icon->manager_window); #endif gdk_window_remove_filter (gdkwin, egg_tray_icon_manager_filter, icon); } XGrabServer (xdisplay); icon->manager_window = XGetSelectionOwner (xdisplay, icon->selection_atom); if (icon->manager_window != None) XSelectInput (xdisplay, icon->manager_window, StructureNotifyMask); XUngrabServer (xdisplay); XFlush (xdisplay); if (icon->manager_window != None) { GdkWindow *gdkwin; #if HAVE_GTK_MULTIHEAD gdkwin = gdk_window_lookup_for_display (gtk_widget_get_display (GTK_WIDGET (icon)), icon->manager_window); #else gdkwin = gdk_window_lookup (icon->manager_window); #endif gdk_window_add_filter (gdkwin, egg_tray_icon_manager_filter, icon); /* Send a request that we'd like to dock */ egg_tray_icon_send_dock_request (icon); } }
static void socket_unrealize_cb(GtkWidget *widget, gpointer data) { // Unmap and reparent any child windows that GDK does not yet know about. // (See bug 540114 comment 10.) GdkWindow* socket_window = widget->window; Display* display = GDK_DISPLAY(); // Ignore X errors that may happen if windows get destroyed (possibly // requested by the plugin) between XQueryTree and when we operate on them. gdk_error_trap_push(); Window root, parent; Window* children; unsigned int nchildren; if (!XQueryTree(display, gdk_x11_drawable_get_xid(socket_window), &root, &parent, &children, &nchildren)) return; for (unsigned int i = 0; i < nchildren; ++i) { Window child = children[i]; if (!gdk_window_lookup(child)) { // This window is not known to GDK. XUnmapWindow(display, child); XReparentWindow(display, child, DefaultRootWindow(display), 0, 0); } } if (children) XFree(children); XSync(display, False); gdk_error_trap_pop(); }
GdkWindow *clg_gdk_cairo_surface_get_window (cairo_surface_t *surface) { /* If 'surface_info_key' had been public we would have had a portable way to find the GdkWindow of a Cairo surface. */ #ifdef GDK_WINDOWING_X11 g_return_if_fail (cairo_surface_get_type (surface) == CAIRO_SURFACE_TYPE_XLIB); Display* display = cairo_xlib_surface_get_display (surface); if (display) { Drawable window = cairo_xlib_surface_get_drawable (surface); if (window) return gdk_window_lookup_for_display (window, display); } return NULL; #elif defined (G_OS_WIN32) HDC hdc = (HDC)cairo_win32_surface_get_dc (surface); if (hdc) return gdk_window_lookup ((GdkNativeWindow)hdc); else return NULL; #else return NULL; #endif }
static GdkFilterReturn panel_action_protocol_filter (GdkXEvent *gdk_xevent, GdkEvent *event, gpointer data) { GdkWindow *window; GdkScreen *screen; XEvent *xevent = (XEvent *) gdk_xevent; if (xevent->type != ClientMessage) return GDK_FILTER_CONTINUE; if (xevent->xclient.message_type != atom_gnome_panel_action) return GDK_FILTER_CONTINUE; window = gdk_window_lookup (xevent->xclient.window); if (!window) return GDK_FILTER_CONTINUE; screen = gdk_drawable_get_screen (window); if (xevent->xclient.data.l [0] == atom_gnome_panel_action_main_menu) panel_action_protocol_main_menu (screen, xevent->xclient.data.l [1]); else if (xevent->xclient.data.l [0] == atom_gnome_panel_action_run_dialog) panel_action_protocol_run_dialog (screen, xevent->xclient.data.l [1]); else return GDK_FILTER_CONTINUE; return GDK_FILTER_REMOVE; }
static VALUE rg_s_lookup(int argc, VALUE *argv, G_GNUC_UNUSED VALUE self) { VALUE arg[2]; GdkWindow * win = NULL; rb_scan_args(argc, argv, "11", &arg[0], &arg[1]); switch(argc) { case 1: win = gdk_window_lookup(RVAL2GDKNATIVEWINDOW(arg[0])); break; case 2: win = gdk_window_lookup_for_display(RVAL2GOBJ(arg[0]), RVAL2GDKNATIVEWINDOW(arg[1])); break; default: break; } if (win == NULL) return Qnil; else { return GOBJ2RVAL(win); } }
GdkWindow *gdk_selection_owner_get(GdkAtom selection) { GdkWindow *window; gchar *sel_name; #if 0 /* XXX Hmm, gtk selections seem to work best with this. This causes * gtk to always get the clipboard contents from Windows, and not * from the editable's own stashed-away copy. */ return NULL; #else if (selection != gdk_clipboard_atom) window = NULL; else { window = gdk_window_lookup(GetClipboardOwner()); if (window == NULL) window = (GdkWindow *)GetClipboardOwner(); } #endif GDK_NOTE(DND, (sel_name = gdk_atom_name(selection), g_print("gdk_selection_owner_get: %#x (%s) = %#x\n", selection, sel_name, (window ? GDK_DRAWABLE_XID(window) : 0)), g_free(sel_name))); return window; }
nsresult nsPluginNativeWindowGtk2::CreateXEmbedWindow() { if(!mGtkSocket) { GdkWindow *win = gdk_window_lookup((XID)window); mGtkSocket = gtk_socket_new(); //attach the socket to the container widget gtk_widget_set_parent_window(mGtkSocket, win); // Make sure to handle the plug_removed signal. If we don't the // socket will automatically be destroyed when the plug is // removed, which means we're destroying it more than once. // SYNTAX ERROR. g_signal_connect(mGtkSocket, "plug_removed", G_CALLBACK(plug_removed_cb), NULL); gpointer user_data = NULL; gdk_window_get_user_data(win, &user_data); GtkContainer *container = GTK_CONTAINER(user_data); gtk_container_add(container, mGtkSocket); gtk_widget_realize(mGtkSocket); // Resize before we show SetAllocation(); gtk_widget_show(mGtkSocket); gdk_flush(); window = (nsPluginPort *)gtk_socket_get_id(GTK_SOCKET(mGtkSocket)); } return NS_OK; }
static void egg_tray_icon_realize (GtkWidget *widget) { EggTrayIcon *icon = EGG_TRAY_ICON (widget); gint screen; Display *xdisplay; char buffer[256]; GdkWindow *root_window; if (GTK_WIDGET_CLASS (parent_class)->realize) GTK_WIDGET_CLASS (parent_class)->realize (widget); make_transparent (widget, NULL); xdisplay = egg_tray_icon_get_x_display(icon); if (xdisplay == NULL) return; #if GTK_CHECK_VERSION(2,1,0) screen = gdk_screen_get_number (gtk_widget_get_screen (widget)); #else screen = XScreenNumberOfScreen (DefaultScreenOfDisplay (gdk_display)); #endif /* Now see if there's a manager window around */ g_snprintf (buffer, sizeof (buffer), "_NET_SYSTEM_TRAY_S%d", screen); icon->selection_atom = XInternAtom (xdisplay, buffer, False); icon->manager_atom = XInternAtom (xdisplay, "MANAGER", False); icon->system_tray_opcode_atom = XInternAtom (xdisplay, "_NET_SYSTEM_TRAY_OPCODE", False); icon->orientation_atom = XInternAtom (xdisplay, "_NET_SYSTEM_TRAY_ORIENTATION", False); egg_tray_icon_update_manager_window (icon, FALSE); egg_tray_icon_send_dock_request (icon); #if GTK_CHECK_VERSION(2,1,0) root_window = gdk_screen_get_root_window (gtk_widget_get_screen (widget)); #else root_window = gdk_window_lookup (gdk_x11_get_default_root_xwindow ()); #endif /* Add a root window filter so that we get changes on MANAGER */ gdk_window_add_filter (root_window, egg_tray_icon_manager_filter, icon); }
EggTrayIcon * egg_tray_icon_new_for_xscreen (Screen *xscreen, const char *name) { EggTrayIcon *icon; char buffer[256]; GdkWindow *root_window; g_return_val_if_fail (xscreen != NULL, NULL); icon = g_object_new (EGG_TYPE_TRAY_ICON, NULL); gtk_window_set_title (GTK_WINDOW (icon), name); #if HAVE_GTK_MULTIHEAD /* FIXME: this code does not compile, screen is undefined. Now try * getting the GdkScreen from xscreen (:. Dunno how to solve this * (there is prolly some easy way I cant think of right now) */ gtk_plug_construct_for_display (GTK_PLUG (icon), gdk_screen_get_display (screen), 0); #else gtk_plug_construct (GTK_PLUG (icon), 0); #endif gtk_widget_realize (GTK_WIDGET (icon)); /* Now see if there's a manager window around */ g_snprintf (buffer, sizeof (buffer), "_NET_SYSTEM_TRAY_S%d", XScreenNumberOfScreen (xscreen)); icon->selection_atom = XInternAtom (DisplayOfScreen (xscreen), buffer, False); icon->manager_atom = XInternAtom (DisplayOfScreen (xscreen), "MANAGER", False); icon->system_tray_opcode_atom = XInternAtom (DisplayOfScreen (xscreen), "_NET_SYSTEM_TRAY_OPCODE", False); egg_tray_icon_update_manager_window (icon); #if HAVE_GTK_MULTIHEAD root_window = gdk_screen_get_root_window (gtk_widget_get_screen (screen)); #else root_window = gdk_window_lookup (gdk_x11_get_default_root_xwindow ()); #endif /* Add a root window filter so that we get changes on MANAGER */ gdk_window_add_filter (root_window, egg_tray_icon_manager_filter, icon); return icon; }
static GdkFilterReturn panel_action_protocol_filter (GdkXEvent *gdk_xevent, GdkEvent *event, gpointer data) { GdkWindow *window; GdkScreen *screen; #if GTK_CHECK_VERSION (3, 0, 0) GdkDisplay *display; #endif XEvent *xevent = (XEvent *) gdk_xevent; if (xevent->type != ClientMessage) return GDK_FILTER_CONTINUE; if ((xevent->xclient.message_type != atom_mate_panel_action) && (xevent->xclient.message_type != atom_gnome_panel_action)) return GDK_FILTER_CONTINUE; #if GTK_CHECK_VERSION (3, 0, 0) screen = gdk_event_get_screen (event); display = gdk_screen_get_display (screen); window = gdk_x11_window_lookup_for_display (display, xevent->xclient.window); #else window = gdk_window_lookup (xevent->xclient.window); screen = gdk_drawable_get_screen (window); #endif if (!window) return GDK_FILTER_CONTINUE; #if GTK_CHECK_VERSION (3, 0, 0) if (window != gdk_screen_get_root_window (screen)) return GDK_FILTER_CONTINUE; #endif if (xevent->xclient.data.l [0] == atom_mate_panel_action_main_menu) panel_action_protocol_main_menu (screen, xevent->xclient.data.l [1]); else if (xevent->xclient.data.l [0] == atom_mate_panel_action_run_dialog) panel_action_protocol_run_dialog (screen, xevent->xclient.data.l [1]); else if (xevent->xclient.data.l [0] == atom_gnome_panel_action_main_menu) panel_action_protocol_main_menu (screen, xevent->xclient.data.l [1]); else if (xevent->xclient.data.l [0] == atom_gnome_panel_action_run_dialog) panel_action_protocol_run_dialog (screen, xevent->xclient.data.l [1]); else if (xevent->xclient.data.l [0] == atom_mate_panel_action_kill_dialog) panel_action_protocol_kill_dialog (screen, xevent->xclient.data.l [1]); else return GDK_FILTER_CONTINUE; return GDK_FILTER_REMOVE; }
/* grab top corner of screen directly to a pixmap */ GdkPixmap * grab_pixmap() { GdkDrawable *src; GdkPixmap *dest; GdkGC *gc; dest = gdk_pixmap_new(NULL, 100, 100, 24); src = gdk_window_lookup(gdk_x11_get_default_root_xwindow()); gc = gdk_gc_new(dest); gdk_draw_drawable(dest, gc, src, 0, 0, 0, 0, 100, 100); g_object_unref(G_OBJECT(gc)); return dest; }
static void egg_tray_icon_update_manager_window (EggTrayIcon *icon, gboolean dock_if_realized) { Display *xdisplay; if (icon->manager_window != None) return; #if GTK_CHECK_VERSION(2,1,0) xdisplay = GDK_DISPLAY_XDISPLAY (gtk_widget_get_display (GTK_WIDGET (icon))); #else xdisplay = gdk_display; #endif XGrabServer (xdisplay); icon->manager_window = XGetSelectionOwner (xdisplay, icon->selection_atom); if (icon->manager_window != None) XSelectInput (xdisplay, icon->manager_window, StructureNotifyMask|PropertyChangeMask); XUngrabServer (xdisplay); XFlush (xdisplay); if (icon->manager_window != None) { GdkWindow *gdkwin; #if GTK_CHECK_VERSION(2,1,0) gdkwin = gdk_window_lookup_for_display (gtk_widget_get_display (GTK_WIDGET (icon)), icon->manager_window); #else gdkwin = gdk_window_lookup (icon->manager_window); #endif gdk_window_add_filter (gdkwin, egg_tray_icon_manager_filter, icon); if (dock_if_realized && GTK_WIDGET_REALIZED (GTK_WIDGET (icon))) egg_tray_icon_send_dock_request (icon); egg_tray_icon_get_orientation_property (icon); } }
static void watch_cb (Window window, Bool is_start, long mask, void *cb_data) { GdkWindow *gdkwin; if (is_start) printf ("Starting watch on %#lx with mask %#lx\n", window, mask); else printf ("Stopping watch on %#lx \n", window); gdkwin = gdk_window_lookup (window); if (is_start) gdk_window_add_filter (gdkwin, client_event_filter, NULL); else gdk_window_remove_filter (gdkwin, client_event_filter, NULL); }
nsresult SimplePluginInstance::PlatformSetWindow(nsPluginWindow* window) { #ifdef NS_DEBUG printf("SimplePluginInstance::PlatformSetWindow\n"); #endif if (window == NULL || window->window == NULL) return NS_ERROR_NULL_POINTER; GdkWindow *win = gdk_window_lookup((XID)window->window); if ( fPlatform.superwin && fPlatform.superwin->bin_window == win ) return NS_OK; // should we destroy fPlatform.superwin ?? fPlatform.superwin = gdk_superwin_new(win, 0, 0, window->width, window->height); // a little cleanup if (fPlatform.label) gtk_widget_destroy(fPlatform.label); if (fPlatform.moz_box) gtk_widget_destroy(fPlatform.moz_box); // create a containing mozbox and a label to put in it fPlatform.moz_box = gtk_mozbox_new(fPlatform.superwin->bin_window); fPlatform.label = gtk_label_new(fText); gtk_container_add(GTK_CONTAINER(fPlatform.moz_box), fPlatform.label); // grow the label to fit the entire mozbox gtk_widget_set_usize(fPlatform.label, window->width, window->height); // connect to expose events gtk_signal_connect (GTK_OBJECT(fPlatform.label), "expose_event", GTK_SIGNAL_FUNC(draw), this); gtk_widget_show(fPlatform.label); gtk_widget_show(fPlatform.moz_box); return NS_OK; }
static void egg_tray_icon_manager_window_destroyed (EggTrayIcon *icon) { GdkWindow *gdkwin; g_return_if_fail (icon->manager_window != None); #if GTK_CHECK_VERSION(2,1,0) gdkwin = gdk_window_lookup_for_display (gtk_widget_get_display (GTK_WIDGET (icon)), icon->manager_window); #else gdkwin = gdk_window_lookup (icon->manager_window); #endif gdk_window_remove_filter (gdkwin, egg_tray_icon_manager_filter, icon); icon->manager_window = None; egg_tray_icon_update_manager_window (icon, TRUE); }
static GdkWindow *getGdkWindow(PluginInstance *This) { #ifdef MOZ_X11 GdkWindow *gdk_window; Window xwin = (Window) This->window; Widget xt_w = XtWindowToWidget(This->display, xwin); if (xt_w) { xt_w = XtParent(xt_w); if (xt_w) { xwin = XtWindow(xt_w); /* xwin = xt_w->core.window; */ } } gdk_window = gdk_window_lookup(xwin); return gdk_window; #else return NULL; #endif }
/* * Override the Window proc for top-level GTK windows that contain an embedded * XULRunnerBrowser. This is needed because GTK's focus model is much * different than XULRunner's. */ LRESULT CALLBACK ToplevelFocusHackWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { GdkWindow* window = gdk_window_lookup((GdkNativeWindow)hwnd); WNDPROC old_window_proc = (WNDPROC)GetProp(hwnd, "ToplevelFocusHackOldProc"); if(!window) { if(!old_window_proc) { return DefWindowProc(hwnd, uMsg, wParam, lParam); } else { return CallWindowProc(old_window_proc, hwnd, uMsg, wParam, lParam); } } switch(uMsg) { case WM_MOUSEACTIVATE: // Mouse click on a non-browser widget. Ensure that the top-level // window has the keyboard focus. // (We know it can't be a browser widget, because we handle // WM_MOUSEACTIVATE in BrowserFocusHackWndProc()). gdk_window_focus(window, 0); return MA_NOACTIVATE; case WM_KILLFOCUS: // GTK's toplevel window is losing focus to a child window. // This is probably a XULRunner window. Handle the event so that // the window doesn't think it's lost focus. if(wParam && IsChild(hwnd, (HWND)wParam)) { return 0; } break; case WM_DESTROY: case WM_NCDESTROY: // The Window is about to be destroyed -- Cleanup SetWindowLongPtr(hwnd, GWL_WNDPROC, (LONG_PTR)old_window_proc); RemoveProp(hwnd, "ToplevelFocusHackOldProc"); break; } return CallWindowProc(old_window_proc, hwnd, uMsg, wParam, lParam); }
nsresult nsPluginNativeWindowGtk2::CreateXtWindow() { NS_ASSERTION(!mSocketWidget,"Already created a socket widget!"); #ifdef NS_DEBUG printf("About to create new xtbin of %i X %i from %p...\n", width, height, (void*)window); #endif GdkWindow *gdkWindow = gdk_window_lookup((XID)window); mSocketWidget = gtk_xtbin_new(gdkWindow, 0); // Check to see if creating the xtbin failed for some reason. // if it did, we can't go any further. if (!mSocketWidget) return NS_ERROR_FAILURE; g_signal_connect(mSocketWidget, "destroy", G_CALLBACK(gtk_widget_destroyed), &mSocketWidget); gtk_widget_set_size_request(mSocketWidget, width, height); #ifdef NS_DEBUG printf("About to show xtbin(%p)...\n", (void*)mSocketWidget); fflush(NULL); #endif gtk_widget_show(mSocketWidget); #ifdef NS_DEBUG printf("completed gtk_widget_show(%p)\n", (void*)mSocketWidget); fflush(NULL); #endif // Fill out the ws_info structure. GtkXtBin* xtbin = GTK_XTBIN(mSocketWidget); // The xtbin has its own Display structure. mWsInfo.display = xtbin->xtdisplay; mWsInfo.colormap = xtbin->xtclient.xtcolormap; mWsInfo.visual = xtbin->xtclient.xtvisual; mWsInfo.depth = xtbin->xtclient.xtdepth; // Leave mWsInfo.type = 0 - Who knows what this is meant to be? XFlush(mWsInfo.display); return NS_OK; }
static Bool checkEventProc(Display *display, XEvent *event, XPointer arg) { checkEventContext *context = (checkEventContext *) arg; if (event->xany.type == SelectionNotify || (event->xany.type == PropertyNotify && event->xproperty.atom == context->selAtom)) { GdkWindow *cbWindow = gdk_window_lookup(event->xany.window); if (cbWindow) { GtkWidget *cbWidget = NULL; gdk_window_get_user_data(cbWindow, (gpointer *)&cbWidget); if (cbWidget && GTK_IS_WIDGET(cbWidget)) { context->cbWidget = cbWidget; return True; } } } return False; }
EggTrayIcon * egg_tray_icon_new (const char *name, GdkPixbuf *pix) { EggTrayIcon *icon; char buffer[256]; GdkWindow *root_window; Screen *xscreen=DefaultScreenOfDisplay (GDK_DISPLAY()); g_return_val_if_fail (pix!= NULL, NULL); icon = g_object_new (EGG_TYPE_TRAY_ICON, NULL); gtk_window_set_title (GTK_WINDOW (icon), name); gtk_plug_construct (GTK_PLUG (icon), 0); gtk_widget_realize (GTK_WIDGET (icon)); icon->ready=FALSE; icon->default_pix=pix; /* Now see if there's a manager window around */ g_snprintf (buffer, sizeof (buffer), "_NET_SYSTEM_TRAY_S%d", XScreenNumberOfScreen (xscreen)); icon->selection_atom = XInternAtom (DisplayOfScreen (xscreen), buffer, False); icon->manager_atom = XInternAtom (DisplayOfScreen (xscreen), "MANAGER", False); icon->system_tray_opcode_atom = XInternAtom (DisplayOfScreen (xscreen), "_NET_SYSTEM_TRAY_OPCODE", False); gtk_window_present (GTK_WINDOW (icon)); egg_tray_icon_update_manager_window (icon); root_window = gdk_window_lookup (gdk_x11_get_default_root_xwindow ()); /* Add a root window filter so that we get changes on MANAGER */ gdk_window_add_filter (root_window, egg_tray_icon_manager_filter, icon); return icon; }
/* grab top corner of screen to a pixmap via an intermediate pixbuf */ GdkPixmap * grab_pixmap2() { GdkDrawable *src; GdkPixmap *dest; GdkColormap *cmap; GdkPixbuf *pbuf; GdkGC *gc; dest = gdk_pixmap_new(NULL, 100, 100, 24); src = gdk_window_lookup(gdk_x11_get_default_root_xwindow()); cmap = gdk_window_get_colormap(src); pbuf = gdk_pixbuf_get_from_drawable(NULL, src, cmap, 0, 0, 0, 0, 100, 100); gc = gdk_gc_new(dest); gdk_draw_pixbuf(dest, gc, pbuf, 0, 0, 0, 0, 100, 100, 0, 0, 0); g_object_unref(G_OBJECT(gc)); g_object_unref(G_OBJECT(pbuf)); return dest; }
LRESULT CALLBACK BrowserFocusHackWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { HWND parent; WNDPROC old_window_proc = (WNDPROC)GetProp(hwnd, "BrowserFocusHackOldProc"); if(!old_window_proc) { return DefWindowProc(hwnd, uMsg, wParam, lParam); } switch(uMsg) { case WM_MOUSEACTIVATE: // The user clicked on a xulrunner browser. Have the GTK widget // grab focus. // NOTE: the window that we are handling messages for is the child // ofthe actual GTK widget. See browser.py for info on why this // is. parent = GetParent(hwnd); GdkWindow* window; window = gdk_window_lookup((GdkNativeWindow)parent); if(window) { GtkWidget* browser_widget; gdk_window_get_user_data(window, (gpointer*)&browser_widget); if(browser_widget) { gtk_widget_grab_focus(browser_widget); } } return MA_ACTIVATE; break; case WM_NCDESTROY: // The Window is about to be destroyed -- Cleanup SetWindowLongPtr(hwnd, GWL_WNDPROC, (LONG_PTR)old_window_proc); RemoveProp(hwnd, "BrowserFocusHackOldProc"); break; } return CallWindowProc(old_window_proc, hwnd, uMsg, wParam, lParam); }
static void egg_tray_icon_update_manager_window (EggTrayIcon *icon) { static GdkPixbuf *background_pixbuf; const gchar *window_manager=NULL; if (icon->manager_window != None) { GdkWindow *gdkwin; gdkwin = gdk_window_lookup (icon->manager_window); gdk_window_remove_filter (gdkwin, egg_tray_icon_manager_filter, icon); } XGrabServer (GDK_DISPLAY()); icon->manager_window = XGetSelectionOwner (GDK_DISPLAY(), icon->selection_atom); if (icon->manager_window != None) XSelectInput (GDK_DISPLAY(), icon->manager_window, StructureNotifyMask); XUngrabServer (GDK_DISPLAY()); XFlush (GDK_DISPLAY()); if (icon->manager_window == None) return; window_manager=gdk_x11_screen_get_window_manager_name (gdk_screen_get_default()); if ( !g_ascii_strcasecmp(window_manager, kde_window_manger) && kde_dock (icon)) { if ((background_pixbuf=kde_dock_background(icon)) !=NULL) { icon->box= gtk_fixed_new (); gtk_fixed_set_has_window(GTK_FIXED (icon->box),TRUE); gtk_container_add(GTK_CONTAINER(icon), icon->box); icon->image=gtk_image_new (); gtk_image_set_from_pixbuf(GTK_IMAGE(icon->image), icon->default_pix); icon->background =gtk_image_new (); gtk_image_set_from_pixbuf(GTK_IMAGE(icon->background), background_pixbuf); gtk_fixed_put (GTK_FIXED (icon->box), GTK_WIDGET(icon->background), 0, 0); gtk_fixed_put (GTK_FIXED (icon->box), GTK_WIDGET(icon->image), 0, 0); gtk_widget_show (icon->background); gtk_widget_show (icon->image); gtk_widget_show(icon->box); icon->ready=TRUE; } } else { icon->box=gtk_event_box_new (); gtk_container_add(GTK_CONTAINER(icon), icon->box); icon->image=gtk_image_new (); gtk_image_set_from_pixbuf(GTK_IMAGE(icon->image),icon->default_pix); gtk_container_add(GTK_CONTAINER(icon->box), icon->image); gtk_widget_show (icon->image); gtk_widget_show(icon->box); GdkWindow *gdkwin; gdkwin = gdk_window_lookup (icon->manager_window); gdk_window_add_filter (gdkwin, egg_tray_icon_manager_filter, icon); /* Send a request that we'd like to dock */ egg_tray_icon_send_dock_request (icon); } }
void gtk_pizza_scroll (GtkPizza *pizza, gint dx, gint dy) { GtkWidget *widget; XEvent xevent; XID win; gint x,y,w,h,border; widget = GTK_WIDGET (pizza); pizza->xoffset += dx; pizza->yoffset += dy; if (!GTK_WIDGET_MAPPED (pizza)) { gtk_pizza_position_children (pizza); return; } gtk_pizza_adjust_allocations (pizza, -dx, -dy); if (pizza->shadow_type == GTK_MYSHADOW_NONE) border = 0; else if (pizza->shadow_type == GTK_MYSHADOW_THIN) border = 1; else border = 2; x = 0; y = 0; w = widget->allocation.width - 2*border; h = widget->allocation.height - 2*border; if (dx > 0) { if (gravity_works) { gdk_window_resize (pizza->bin_window, w + dx, h); gdk_window_move (pizza->bin_window, x-dx, y); gdk_window_move_resize (pizza->bin_window, x, y, w, h ); } else { /* FIXME */ } } else if (dx < 0) { if (gravity_works) { gdk_window_move_resize (pizza->bin_window, x + dx, y, w - dx, h); gdk_window_move (pizza->bin_window, x, y); gdk_window_resize (pizza->bin_window, w, h ); } else { /* FIXME */ } } if (dy > 0) { if (gravity_works) { gdk_window_resize (pizza->bin_window, w, h + dy); gdk_window_move (pizza->bin_window, x, y-dy); gdk_window_move_resize (pizza->bin_window, x, y, w, h ); } else { /* FIXME */ } } else if (dy < 0) { if (gravity_works) { gdk_window_move_resize (pizza->bin_window, x, y+dy, w, h - dy ); gdk_window_move (pizza->bin_window, x, y); gdk_window_resize (pizza->bin_window, w, h ); } else { /* FIXME */ } } gtk_pizza_position_children (pizza); gdk_flush(); win = GDK_WINDOW_XWINDOW (pizza->bin_window); while (XCheckIfEvent(GDK_WINDOW_XDISPLAY (pizza->bin_window), &xevent, gtk_pizza_expose_predicate, (XPointer)&win)) { GdkEvent event; GtkWidget *event_widget; if ((xevent.xany.window == GDK_WINDOW_XWINDOW (pizza->bin_window)) ) gtk_pizza_filter (&xevent, &event, pizza); if (xevent.type == Expose) { event.expose.window = gdk_window_lookup (xevent.xany.window); gdk_window_get_user_data (event.expose.window, (gpointer *)&event_widget); if (event_widget) { event.expose.type = GDK_EXPOSE; event.expose.area.x = xevent.xexpose.x; event.expose.area.y = xevent.xexpose.y; event.expose.area.width = xevent.xexpose.width; event.expose.area.height = xevent.xexpose.height; event.expose.count = xevent.xexpose.count; gdk_window_ref (event.expose.window); gtk_widget_event (event_widget, &event); gdk_window_unref (event.expose.window); } } } }
GtkWidget *getGtkWindow(void *nativeWindowHandle) { GdkWindow *p = (GdkWindow *)gdk_window_lookup((XID)nativeWindowHandle); GtkWidget *window = NULL; gdk_window_get_user_data(p, (gpointer *)&window); return window; }
nsresult nsPluginNativeWindowGtk2::CreateXCompositedWindow() { NS_ASSERTION(!mSocketWidget,"Already created a socket widget!"); mParentWindow = gtk_window_new(GTK_WINDOW_POPUP); mSocketWidget = gtk_socket_new(); GdkWindow *parent_win = mParentWindow->window; //attach the socket to the container widget gtk_widget_set_parent_window(mSocketWidget, parent_win); // Make sure to handle the plug_removed signal. If we don't the // socket will automatically be destroyed when the plug is // removed, which means we're destroying it more than once. // SYNTAX ERROR. g_signal_connect(mSocketWidget, "plug_removed", G_CALLBACK(plug_removed_cb), NULL); g_signal_connect(mSocketWidget, "destroy", G_CALLBACK(gtk_widget_destroyed), &mSocketWidget); /*gpointer user_data = NULL; gdk_window_get_user_data(parent_win, &user_data); */ GtkContainer *container = GTK_CONTAINER(mParentWindow); gtk_container_add(container, mSocketWidget); gtk_widget_realize(mSocketWidget); // Resize before we show SetAllocation(); gtk_widget_set_size_request (mSocketWidget, width, height); /* move offscreen */ gtk_window_move (GTK_WINDOW(mParentWindow), width+1000, height+1000); gtk_widget_show(mSocketWidget); gtk_widget_show_all(mParentWindow); /* store away a reference to the socketwidget */ mPlugWindow = (mSocketWidget); gdk_flush(); window = (nsPluginPort *)gtk_socket_get_id(GTK_SOCKET(mSocketWidget)); /* This is useful if we still have the plugin window inline * i.e. firefox vs. fennec */ // gdk_window_set_composited(mSocketWidget->window, TRUE); if (!mDamage) { /* we install a general handler instead of one specific to a particular window * because we don't have a GdkWindow for the plugin window */ gdk_window_add_filter (parent_win, plugin_composite_filter_func, this); int junk; if (!XDamageQueryExtension (GDK_DISPLAY (), &xdamage_event_base, &junk)) printf ("This requires the XDamage extension"); mDamage = XDamageCreate(GDK_DISPLAY(), (Drawable)window, XDamageReportNonEmpty); XCompositeRedirectWindow (GDK_DISPLAY(), (Drawable)window, CompositeRedirectManual); /* this is a hack to avoid having flash causing a crash when it is unloaded. * libplayback sets up dbus_connection_filters. When flash is unloaded it takes * libplayback with it, however the connection filters are not removed * which causes a crash when dbus tries to execute them. dlopening libplayback * ensures that those functions stay around even after flash is gone. */ static void *libplayback_handle; if (!libplayback_handle) { libplayback_handle = dlopen("libplayback-1.so.0", RTLD_NOW); } } // Fill out the ws_info structure. // (The windowless case is done in nsObjectFrame.cpp.) GdkWindow *gdkWindow = gdk_window_lookup((XID)window); mWsInfo.display = GDK_WINDOW_XDISPLAY(gdkWindow); mWsInfo.colormap = GDK_COLORMAP_XCOLORMAP(gdk_drawable_get_colormap(gdkWindow)); GdkVisual* gdkVisual = gdk_drawable_get_visual(gdkWindow); mWsInfo.visual = GDK_VISUAL_XVISUAL(gdkVisual); mWsInfo.depth = gdkVisual->depth; return NS_OK; }