static void gtk_xtbin_realize (GtkWidget *widget) { GtkXtBin *xtbin; GtkAllocation allocation = { 0, 0, 200, 200 }; #if GTK_CHECK_VERSION(2, 18, 0) GtkAllocation widget_allocation; #endif #ifdef DEBUG_XTBIN printf("gtk_xtbin_realize()\n"); #endif g_return_if_fail (GTK_IS_XTBIN (widget)); xtbin = GTK_XTBIN (widget); /* caculate the allocation before realize */ #if GTK_CHECK_VERSION(2, 24, 0) allocation.width = gdk_window_get_width(xtbin->parent_window); allocation.height = gdk_window_get_height(xtbin->parent_window); #else gint x, y, w, h, d; /* geometry of window */ gdk_window_get_geometry(xtbin->parent_window, &x, &y, &w, &h, &d); allocation.width = w; allocation.height = h; #endif gtk_widget_size_allocate (widget, &allocation); #ifdef DEBUG_XTBIN printf("initial allocation %d %d %d %d\n", x, y, w, h); #endif #if GTK_CHECK_VERSION(2, 18, 0) gtk_widget_get_allocation(widget, &widget_allocation); xtbin->width = widget_allocation.width; xtbin->height = widget_allocation.height; #else xtbin->width = widget->allocation.width; xtbin->height = widget->allocation.height; #endif /* use GtkSocket's realize */ (*GTK_WIDGET_CLASS(parent_class)->realize)(widget); /* create the Xt client widget */ xt_client_create(&(xtbin->xtclient), gtk_socket_get_id(GTK_SOCKET(xtbin)), xtbin->height, xtbin->width); xtbin->xtwindow = XtWindow(xtbin->xtclient.child_widget); gdk_flush(); /* now that we have created the xt client, add it to the socket. */ gtk_socket_add_id(GTK_SOCKET(widget), xtbin->xtwindow); }
GdkWindow * awn_ua_alignment_add_id (AwnUAAlignment *self,GdkNativeWindow native_window) { GdkWindow * plugwin; AwnUAAlignmentPrivate *priv; priv = AWN_UA_ALIGNMENT_GET_PRIVATE (self); gtk_socket_add_id (GTK_SOCKET(priv->socket), native_window); plugwin = gtk_socket_get_plug_window (GTK_SOCKET(priv->socket)); g_signal_connect (priv->socket,"plug-removed", G_CALLBACK(awn_ua_alignment_plug_removed),self); gtk_widget_realize (priv->socket); gtk_widget_show_all (priv->socket); return plugwin; }
/***f* socket/gnoclSocketCmd * AUTHOR * PGB * SOURCE */ int gnoclSocketCmd ( ClientData data, Tcl_Interp *interp, int objc, Tcl_Obj * const objv[] ) { int ret; GtkSocket *socket; if ( gnoclParseOptions ( interp, objc, objv, socketOptions ) != TCL_OK ) { gnoclClearOptions ( socketOptions ); return TCL_ERROR; } socket = GTK_SOCKET ( gtk_socket_new() ); gtk_widget_show ( GTK_WIDGET ( socket ) ); ret = gnoclSetOptions ( interp, socketOptions, G_OBJECT ( socket ), -1 ); if ( ret == TCL_OK ) ret = configure ( interp, socket, socketOptions ); gnoclClearOptions ( socketOptions ); if ( ret != TCL_OK ) { gtk_widget_destroy ( GTK_WIDGET ( socket ) ); return TCL_ERROR; } return gnoclRegisterWidget ( interp, GTK_WIDGET ( socket ), socketFunc ); }
void setup_new_socket_for_plug(struct Gtkabber *gtkabber) { struct ContainerData *cd; static int __id; { cd = malloc( sizeof *cd ); if (cd == NULL) { fprintf( stderr, "Can't malloc() *cd\n" ); exit( EXIT_FAILURE ); } memset( cd, '\0', sizeof *cd ); } cd->id = ++__id; cd->socket = gtk_socket_new(); new_tab_page( gtkabber, GTK_WIDGET(cd->socket) ); cd->xwin_id = gtk_socket_get_id( GTK_SOCKET( cd->socket ) ); gtkabber->toplevel.next_socket_id = cd->xwin_id; gtkabber->socket_list = g_list_append( gtkabber->socket_list, (gpointer)cd ); }
UzblInstance::UzblInstance(const char* u, const char* mainfifo, GtkNotebook* n, GtkTreeRowReference* r) { //id = ID++; url = g_strdup(u); title = g_strdup("..."); /*sprintf(fifopath, "/tmp/uzbl_fifo_%s", fifo); sprintf(sockpath, "/tmp/uzbl_socket_%s", fifo);*/ row = r; notebook = n; children = NULL; socket = GTK_SOCKET(gtk_socket_new()); //gtk_widget_set_can_focus(GTK_WIDGET(socket), false); gtk_notebook_append_page(notebook, GTK_WIDGET(socket), NULL); //gtk_widget_show_all(GTK_WIDGET(notebook)); gtk_widget_show(GTK_WIDGET(socket)); int rn = rand(); sprintf(name, "%d", rn &0x7FFFFFFF); char cmd[1024]; sprintf(cmd, "uzbl-browser tab %d %s %s \"%s\"", gtk_socket_get_id(socket), name, mainfifo, u); printf("%s\n", cmd); g_spawn_command_line_async(cmd, NULL); }
nsresult nsPluginNativeWindowGtk2::CallSetWindow(nsCOMPtr<nsIPluginInstance> &aPluginInstance) { if(aPluginInstance) { nsresult rv; PRBool val = PR_FALSE; if(!mGtkSocket) { if (CanGetValueFromPlugin(aPluginInstance)) rv = aPluginInstance->GetValue ((nsPluginInstanceVariable)NPPVpluginNeedsXEmbed, &val); } #ifdef DEBUG printf("nsPluginNativeWindowGtk2: NPPVpluginNeedsXEmbed=%d\n", val); #endif if(val) { CreateXEmbedWindow(); } if(mGtkSocket) { // Make sure to resize and re-place the window if required SetAllocation(); window = (nsPluginPort *)gtk_socket_get_id(GTK_SOCKET(mGtkSocket)); } #ifdef DEBUG printf("nsPluginNativeWindowGtk2: call SetWindow with xid=%p\n", (void *)window); #endif aPluginInstance->SetWindow(this); } else if (mPluginInstance) mPluginInstance->SetWindow(nsnull); SetPluginInstance(aPluginInstance); return NS_OK; }
NetscapePluginX11::NetscapePluginX11(NetscapePlugin& plugin, Display* display, uint64_t windowID) : m_plugin(plugin) , m_pluginDisplay(display) , m_windowID(windowID) { // It seems flash needs the socket to be in the same process, // I guess it uses gdk_window_lookup(), so we create a new socket here // containing a plug with the UI process socket embedded. m_platformPluginWidget = gtk_plug_new(static_cast<Window>(windowID)); // Hide the GtkPlug on delete-event since we assume the widget is valid while the plugin is active. // platformDestroy() will be called anyway right after the delete-event. g_signal_connect(m_platformPluginWidget, "delete-event", G_CALLBACK(gtk_widget_hide_on_delete), nullptr); GtkWidget* socket = gtk_socket_new(); // Do not show the plug widget until the socket is connected. g_signal_connect_swapped(socket, "plug-added", G_CALLBACK(gtk_widget_show), m_platformPluginWidget); g_signal_connect(socket, "plug-removed", G_CALLBACK(socketPlugRemovedCallback), nullptr); gtk_container_add(GTK_CONTAINER(m_platformPluginWidget), socket); gtk_widget_show(socket); Display* hostDisplay = x11HostDisplay(); m_npWindowID = gtk_socket_get_id(GTK_SOCKET(socket)); GdkWindow* window = gtk_widget_get_window(socket); m_setWindowCallbackStruct.display = GDK_WINDOW_XDISPLAY(window); m_setWindowCallbackStruct.visual = GDK_VISUAL_XVISUAL(gdk_window_get_visual(window)); m_setWindowCallbackStruct.depth = gdk_visual_get_depth(gdk_window_get_visual(window)); m_setWindowCallbackStruct.colormap = XCreateColormap(hostDisplay, GDK_ROOT_WINDOW(), m_setWindowCallbackStruct.visual, AllocNone); XFlush(hostDisplay); }
static void egg_tray_manager_handle_dock_request (EggTrayManager *manager, XClientMessageEvent *xevent) { GtkWidget *socket; Window *window; socket = gtk_socket_new (); /* We need to set the child window here * so that the client can call _get functions * in the signal handler */ window = g_new (Window, 1); *window = xevent->data.l[2]; g_object_set_data_full (G_OBJECT (socket), "egg-tray-child-window", window, g_free); g_signal_emit (manager, manager_signals[TRAY_ICON_ADDED], 0, socket); /* Add the socket only if it's been attached */ if (GTK_IS_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (socket)))) { g_signal_connect (socket, "plug_removed", G_CALLBACK (egg_tray_manager_plug_removed), manager); gtk_socket_add_id (GTK_SOCKET (socket), xevent->data.l[2]); g_hash_table_insert (manager->socket_table, GINT_TO_POINTER (xevent->data.l[2]), socket); } else gtk_widget_destroy (socket); }
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 na_tray_manager_handle_dock_request (NaTrayManager *manager, XClientMessageEvent *xevent) { Window icon_window = xevent->data.l[2]; GtkWidget *child; if (g_hash_table_lookup (manager->socket_table, GINT_TO_POINTER (icon_window))) { /* We already got this notification earlier, ignore this one */ return; } child = na_tray_child_new (manager->screen, icon_window); if (child == NULL) /* already gone or other error */ return; g_signal_emit (manager, manager_signals[TRAY_ICON_ADDED], 0, child); /* If the child wasn't attached, then destroy it */ if (!GTK_IS_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (child)))) { gtk_widget_destroy (child); return; } g_signal_connect (child, "plug_removed", G_CALLBACK (na_tray_manager_plug_removed), manager); gtk_socket_add_id (GTK_SOCKET (child), icon_window); if (!GTK_SOCKET (child)->plug_window) { /* Embedding failed, we won't get a plug-removed signal */ g_signal_emit (manager, manager_signals[TRAY_ICON_REMOVED], 0, child); gtk_widget_destroy (child); return; } g_hash_table_insert (manager->socket_table, GINT_TO_POINTER (icon_window), child); gtk_widget_show (child); }
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; }
nsresult nsPluginNativeWindowGtk2::CallSetWindow(nsRefPtr<nsNPAPIPluginInstance> &aPluginInstance) { if (aPluginInstance) { if (type == NPWindowTypeWindow) { if (!mSocketWidget) { nsresult rv; PRBool needXEmbed = PR_FALSE; rv = aPluginInstance->GetValueFromPlugin(NPPVpluginNeedsXEmbed, &needXEmbed); // If the call returned an error code make sure we still use our default value. if (NS_FAILED(rv)) { needXEmbed = PR_FALSE; } #ifdef DEBUG printf("nsPluginNativeWindowGtk2: NPPVpluginNeedsXEmbed=%d\n", needXEmbed); #endif if (needXEmbed) { rv = CreateXEmbedWindow(); } else { rv = CreateXtWindow(); } if (NS_FAILED(rv)) { return NS_ERROR_FAILURE; } } if (!mSocketWidget) { return NS_ERROR_FAILURE; } // Make sure to resize and re-place the window if required. // Need to reset "window" each time as nsObjectFrame::DidReflow sets it // to the ancestor window. if (GTK_IS_XTBIN(mSocketWidget)) { gtk_xtbin_resize(mSocketWidget, width, height); // Point the NPWindow structures window to the actual X window window = (void*)GTK_XTBIN(mSocketWidget)->xtwindow; } else { // XEmbed SetAllocation(); window = (void*)gtk_socket_get_id(GTK_SOCKET(mSocketWidget)); } #ifdef DEBUG printf("nsPluginNativeWindowGtk2: call SetWindow with xid=%p\n", (void *)window); #endif } // NPWindowTypeWindow aPluginInstance->SetWindow(this); } else if (mPluginInstance) mPluginInstance->SetWindow(nsnull); SetPluginInstance(aPluginInstance); return NS_OK; }
void MCNativeLayerX11::doAttach() { if (m_socket == NULL) { // Create a new GTK socket to deal with the XEMBED protocol GtkSocket *t_socket; t_socket = GTK_SOCKET(gtk_socket_new()); // Create a new GTK window to hold the socket MCRectangle t_rect; t_rect = m_object->getrect(); m_child_window = GTK_WINDOW(gtk_window_new(GTK_WINDOW_POPUP)); gtk_widget_set_parent_window(GTK_WIDGET(m_child_window), getStackGdkWindow()); gtk_widget_realize(GTK_WIDGET(m_child_window)); gdk_window_reparent(gtk_widget_get_window(GTK_WIDGET(m_child_window)), getStackGdkWindow(), t_rect.x, t_rect.y); // Add the socket to the window gtk_container_add(GTK_CONTAINER(m_child_window), GTK_WIDGET(t_socket)); // The socket needs to be realised before going any further or any // operations on it will fail. gtk_widget_realize(GTK_WIDGET(t_socket)); // Show the socket (we'll control visibility at the window level) gtk_widget_show(GTK_WIDGET(t_socket)); // Create an empty region to act as an input mask while in edit mode m_input_shape = gdk_region_new(); // Retain a reference to the socket m_socket = GTK_SOCKET(g_object_ref(G_OBJECT(t_socket))); } // Attach the X11 window to this socket if (gtk_socket_get_plug_window(m_socket) == NULL) gtk_socket_add_id(m_socket, m_widget_xid); //fprintf(stderr, "XID: %u\n", gtk_socket_get_id(m_socket)); // Act as if there were a re-layer to put the widget in the right place doRelayer(); doSetViewportGeometry(m_viewport_rect); doSetGeometry(m_rect); doSetVisible(ShouldShowLayer()); }
nsresult nsPluginNativeWindowGtk2::CallSetWindow(nsCOMPtr<nsIPluginInstance> &aPluginInstance) { if(aPluginInstance) { if (type == nsPluginWindowType_Window) { nsresult rv; if(!mSocketWidget) { PRBool needXEmbed = PR_FALSE; if (CanGetValueFromPlugin(aPluginInstance)) { rv = aPluginInstance->GetValue ((nsPluginInstanceVariable)NPPVpluginNeedsXEmbed, &needXEmbed); #ifdef DEBUG printf("nsPluginNativeWindowGtk2: NPPVpluginNeedsXEmbed=%d\n", needXEmbed); #endif } nsresult rv; if(needXEmbed) { #ifdef MOZ_COMPOSITED_PLUGINS rv = CreateXCompositedWindow(); #else rv = CreateXEmbedWindow(); #endif } else { rv = CreateXtWindow(); } if(NS_FAILED(rv)) return NS_ERROR_FAILURE; } if(!mSocketWidget) return NS_ERROR_FAILURE; // Make sure to resize and re-place the window if required. // Need to reset "window" each time as nsObjectFrame::DidReflow sets it // to the ancestor window. if(GTK_IS_XTBIN(mSocketWidget)) { gtk_xtbin_resize(mSocketWidget, width, height); // Point the NPWindow structures window to the actual X window window = (nsPluginPort *)GTK_XTBIN(mSocketWidget)->xtwindow; } else { // XEmbed SetAllocation(); window = (nsPluginPort *)gtk_socket_get_id(GTK_SOCKET(mSocketWidget)); } #ifdef DEBUG printf("nsPluginNativeWindowGtk2: call SetWindow with xid=%p\n", (void *)window); #endif } // nsPluginWindowType_Window aPluginInstance->SetWindow(this); } else if (mPluginInstance) mPluginInstance->SetWindow(nsnull); SetPluginInstance(aPluginInstance); return NS_OK; }
int main(int argc, char **argv) { GtkWidget *window, *button, *textview, *vbox; GtkWidget *socket, *plug, *socket_box; unsigned long kb_xid; gtk_init (&argc, &argv); install_signal_handlers(); kb_xid = launch_keyboard(); if (!kb_xid) { perror ("### 'matchbox-keyboard --xid', failed to return valid window ID. ### "); exit(-1); } /* Window */ window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_default_size (GTK_WINDOW (window), 640, 480); gtk_container_set_border_width (GTK_CONTAINER (window), 10); g_signal_connect (G_OBJECT (window), "destroy", G_CALLBACK (widget_destroy), NULL); /* Container and textview */ vbox = gtk_vbox_new(FALSE, 5); gtk_container_add (GTK_CONTAINER (window), vbox); textview = gtk_text_view_new(); gtk_box_pack_start (GTK_BOX(vbox), textview, TRUE, TRUE, 2); /* Socket ( XEMBED ) stuff */ socket_box = gtk_event_box_new (); gtk_widget_show (socket_box); socket = gtk_socket_new (); gtk_container_add (GTK_CONTAINER (socket_box), socket); gtk_box_pack_start (GTK_BOX (vbox), GTK_WIDGET(socket_box), TRUE, TRUE, 0); gtk_socket_add_id(GTK_SOCKET(socket), kb_xid); /* FIXME: handle "plug-added" & "plug-removed" signals for socket */ gtk_widget_show_all (window); gtk_main (); return 0; }
static gint luaH_socket_newindex(lua_State *L, luapdf_token_t token) { widget_t *w = luaH_checkwidget(L, 1); if (token == L_TK_ID) { gint id = luaL_checkint(L, 2); gtk_socket_add_id(GTK_SOCKET(w->widget), (GdkNativeWindow) id); } return 0; }
static gint luaH_socket_index(lua_State *L, luapdf_token_t token) { widget_t *w = luaH_checkwidget(L, 1); switch(token) { LUAPDF_WIDGET_INDEX_COMMON /* push integer methods */ PI_CASE(ID, (int) gtk_socket_get_id(GTK_SOCKET(w->widget))) /* push boolean methods */ PB_CASE(PLUGGED, gtk_socket_get_plug_window(GTK_SOCKET(w->widget))!=NULL) default: break; } return 0; }
static void gtk_socket_finalize (GObject *object) { GtkSocket *socket = GTK_SOCKET (object); GtkSocketPrivate *priv = socket->priv; g_object_unref (priv->accel_group); G_OBJECT_CLASS (gtk_socket_parent_class)->finalize (object); }
static void add_menubar(MacMenu* mmb, WnckWindow* mbarwin) { Window mbar = wnck_window_get_xid(mbarwin); GtkWidget* sck = gtk_socket_new(); g_signal_connect(sck, "destroy", G_CALLBACK(socket_destroyed), mmb); gtk_notebook_append_page(mmb->notebook, GTK_WIDGET(sck), NULL); gtk_socket_steal(GTK_SOCKET(sck), mbar); gtk_widget_show_all(sck); g_hash_table_insert(mmb->mbars_scks, (gpointer) mbar, sck); }
static void gtk_socket_finalize (GObject *object) { GtkSocket *socket = GTK_SOCKET (object); g_object_unref (socket->accel_group); socket->accel_group = NULL; G_OBJECT_CLASS (gtk_socket_parent_class)->finalize (object); }
/* If we are faking transparency with a window-relative background, force a * redraw of the icon. This should be called if the background changes or if * the child is shifted with respect to the background. */ void na_tray_child_force_redraw (NaTrayChild *child) { GtkWidget *widget = GTK_WIDGET (child); if (gtk_widget_get_mapped (widget) && child->parent_relative_bg) { #if 1 /* Sending an ExposeEvent might cause redraw problems if the * icon is expecting the server to clear-to-background before * the redraw. It should be ok for GtkStatusIcon or EggTrayIcon. */ Display *xdisplay = GDK_DISPLAY_XDISPLAY (gtk_widget_get_display (widget)); XEvent xev; GdkWindow *plug_window; GtkAllocation allocation; plug_window = gtk_socket_get_plug_window (GTK_SOCKET (child)); gtk_widget_get_allocation (widget, &allocation); xev.xexpose.type = Expose; #if GTK_CHECK_VERSION (3, 0, 0) xev.xexpose.window = GDK_WINDOW_XID (plug_window); #else xev.xexpose.window = GDK_WINDOW_XWINDOW (plug_window); #endif xev.xexpose.x = 0; xev.xexpose.y = 0; xev.xexpose.width = allocation.width; xev.xexpose.height = allocation.height; xev.xexpose.count = 0; gdk_error_trap_push (); XSendEvent (GDK_DISPLAY_XDISPLAY (gtk_widget_get_display (widget)), xev.xexpose.window, False, ExposureMask, &xev); /* We have to sync to reliably catch errors from the XSendEvent(), * since that is asynchronous. */ XSync (xdisplay, False); #if GTK_CHECK_VERSION (3, 0, 0) gdk_error_trap_pop_ignored (); #else gdk_error_trap_pop (); #endif #else /* Hiding and showing is the safe way to do it, but can result in more * flickering. */ gdk_window_hide (widget->window); gdk_window_show (widget->window); #endif } }
/* playerbackend_start */ int playerbackend_start(PlayerBackend * player) { int ret; char const buf[] = "pausing loadfile " PLAYER_SPLASH " 0\nframe_step\n"; char wid[32]; char * argv[] = { BINDIR "/mplayer", "mplayer", "-slave", "-wid", NULL, "-quiet", "-idle", "-framedrop", "-softvol", "-softvol-max", "200", "-identify", "-noconsolecontrols", "-nomouseinput", NULL }; GError * error = NULL; argv[4] = wid; /* XXX not portable */ snprintf(wid, sizeof(wid), "%lu", (unsigned long)gtk_socket_get_id( GTK_SOCKET(player->view))); if(pipe(player->fd[0]) != 0 || pipe(player->fd[1]) != 0) return -player_error(player->player, strerror(errno), 1); if((player->pid = fork()) == -1) return -player_error(player->player, strerror(errno), 1); if(player->pid == 0) /* child */ { close(player->fd[0][0]); close(player->fd[1][1]); if(dup2(player->fd[1][0], 0) == -1) exit(player_error(NULL, "dup2", 2)); if(dup2(player->fd[0][1], 1) == -1) exit(player_error(NULL, "dup2", 2)); execv(argv[0], &argv[1]); exit(player_error(NULL, argv[0], 2)); } close(player->fd[0][1]); close(player->fd[1][0]); player->channel[0] = g_io_channel_unix_new(player->fd[0][0]); if(g_io_channel_set_encoding(player->channel[0], NULL, &error) != G_IO_STATUS_NORMAL) { player_error(player->player, error->message, 1); g_error_free(error); error = NULL; } g_io_channel_set_buffered(player->channel[0], FALSE); player->read_id = g_io_add_watch(player->channel[0], G_IO_IN, _command_read, player); player->channel[1] = g_io_channel_unix_new(player->fd[1][1]); if(g_io_channel_set_encoding(player->channel[1], NULL, &error) != G_IO_STATUS_NORMAL) { player_error(player->player, error->message, 1); g_error_free(error); } g_io_channel_set_buffered(player->channel[1], FALSE); ret = _playerbackend_command(player, buf, sizeof(buf) - 1); player_set_paused(player->player, TRUE); return ret; }
void add_local_active_child (GtkWidget *window) { Socket *socket; socket = create_socket (); gtk_box_pack_start (GTK_BOX (box), socket->box, TRUE, TRUE, 0); gtk_widget_show (socket->box); create_child_plug (gtk_socket_get_id (GTK_SOCKET (socket->socket)), TRUE); }
static char * get_display_string(visualizer_t * v) { char * ret; GdkDisplay * dpy; /* Get the display string */ gtk_widget_realize(v->normal_window.socket); gtk_widget_realize(v->fullscreen_window.socket); dpy = gdk_display_get_default(); // ret = bg_sprintf("%s:%08lx:%08lx", gdk_display_get_name(dpy), // GDK_WINDOW_XID(v->normal_window.window->window), // GDK_WINDOW_XID(v->fullscreen_window.window->window)); ret = bg_sprintf("%s:%08lx:%08lx", gdk_display_get_name(dpy), (long unsigned int)gtk_socket_get_id(GTK_SOCKET(v->normal_window.socket)), (long unsigned int)gtk_socket_get_id(GTK_SOCKET(v->fullscreen_window.socket))); return ret; }
int clip_GTK_SOCKETGETID(ClipMachine * cm) { C_widget *csocket = _fetch_cw_arg(cm); CHECKCWID(csocket,GTK_IS_SOCKET); _clip_retni(cm, gtk_socket_get_id(GTK_SOCKET(csocket->widget))); return 0; err: return 1; }
void add_local_passive_child (GtkWidget *window) { Socket *socket; Window xid; socket = create_socket (); gtk_box_pack_start (GTK_BOX (box), socket->box, TRUE, TRUE, 0); gtk_widget_show (socket->box); xid = create_child_plug (0, TRUE); gtk_socket_add_id (GTK_SOCKET (socket->socket), xid); }
/* [gtk thread] */ static gboolean do_create_display_hook(gpointer data) { const ARGS_CREATE *args = _al_gtk_lock_args(data); ALLEGRO_DISPLAY *display = (ALLEGRO_DISPLAY *)args->display; ALLEGRO_DISPLAY_XGLX *d = args->display; const int w = args->w; const int h = args->h; GtkWidget *window; GtkWidget *vbox; GtkWidget *socket; window = gtk_window_new(GTK_WINDOW_TOPLEVEL); d->gtk->gtkwindow = window; gtk_window_set_default_size(GTK_WINDOW(window), w, h); g_signal_connect(G_OBJECT(window), "delete-event", G_CALLBACK(xgtk_quit_callback), display); g_signal_connect(G_OBJECT(window), "configure-event", G_CALLBACK(xgtk_handle_configure_event), display); vbox = gtk_vbox_new(FALSE, 0); gtk_container_add(GTK_CONTAINER(window), vbox); socket = gtk_socket_new(); d->gtk->gtksocket = socket; gtk_box_pack_end(GTK_BOX(vbox), socket, TRUE, TRUE, 0); gtk_socket_add_id(GTK_SOCKET(socket), d->window); ALLEGRO_DEBUG("gtk_socket_add_id: window = %ld\n", d->window); gtk_window_set_title(GTK_WINDOW(window), args->title); gtk_widget_show_all(window); if (display->flags & ALLEGRO_RESIZABLE) { /* Allow socket widget to be resized smaller than initial size. */ gtk_widget_set_size_request(socket, -1, -1); gtk_window_set_resizable(GTK_WINDOW(window), true); } else { gtk_window_set_resizable(GTK_WINDOW(window), false); } if (display->flags & ALLEGRO_FULLSCREEN_WINDOW) { gtk_window_fullscreen(GTK_WINDOW(window)); } d->overridable_vt = &xgtk_override_vt; return _al_gtk_release_args(data); }
/* FIXME: should we schedule the event or not? static gboolean schedule_send_client_event (gpointer data) { GdkEvent *event = (GdkEvent*) data; gdk_event_send_client_message (event, GDK_WINDOW_XID (event->client.window)); gdk_event_free (event); return FALSE; } */ static void on_size_alloc (AwnAppletProxy *proxy, GtkAllocation *alloc) { AwnAppletProxyPrivate *priv; GtkWidget *parent; GtkAllocation parent_alloc; GdkWindow *plug_win; g_return_if_fail (AWN_IS_APPLET_PROXY (proxy)); priv = proxy->priv; parent = gtk_widget_get_parent (GTK_WIDGET (proxy)); gtk_widget_get_allocation (parent, &parent_alloc); gint pos_x = alloc->x; gint pos_y = alloc->y; gint rel_x = pos_x - parent_alloc.x; gint rel_y = pos_y - parent_alloc.y; gint parent_w = parent_alloc.width; gint parent_h = parent_alloc.height; if (pos_x == priv->old_x && pos_y == priv->old_y && parent_w == priv->old_w && parent_h == priv->old_h) return; priv->old_x = pos_x; priv->old_y = pos_y; priv->old_w = parent_w; priv->old_h = parent_h; /* Only directly access the struct member if we have to. */ plug_win = gtk_socket_get_plug_window (GTK_SOCKET (proxy)); if (plug_win) { GdkAtom msg_type = gdk_atom_intern("_AWN_APPLET_POS_CHANGE", FALSE); GdkEvent *event = gdk_event_new (GDK_CLIENT_EVENT); event->client.window = g_object_ref (plug_win); event->client.data_format = 32; event->client.message_type = msg_type; // first two longs are our relative [x, y] event->client.data.l[0] = rel_x; event->client.data.l[1] = rel_y; // other two longs are our parent's [w, h] event->client.data.l[2] = parent_w; event->client.data.l[3] = parent_h; gdk_event_send_client_message (event, GDK_WINDOW_XID (plug_win)); gdk_event_free (event); /* g_idle_add (schedule_send_client_event, event); */ } }
static void cinnamon_tray_icon_constructed (GObject *object) { GdkWindow *icon_app_window; CinnamonTrayIcon *icon = CINNAMON_TRAY_ICON (object); CinnamonEmbeddedWindow *window; GdkDisplay *display; Window plug_xid; Atom _NET_WM_PID, type; int result, format; gulong nitems, bytes_after, *val = NULL; /* We do all this now rather than computing it on the fly later, * because Cinnamon may want to see their values from a * tray-icon-removed signal handler, at which point the plug has * already been removed from the socket. */ g_object_get (object, "window", &window, NULL); g_return_if_fail (window != NULL); icon->priv->socket = NA_TRAY_CHILD (gtk_bin_get_child (GTK_BIN (window))); g_object_unref (window); icon->priv->title = na_tray_child_get_title (icon->priv->socket); na_tray_child_get_wm_class (icon->priv->socket, NULL, &icon->priv->wm_class); icon_app_window = gtk_socket_get_plug_window (GTK_SOCKET (icon->priv->socket)); if (icon_app_window == NULL) { g_warning ("cinnamon tray: icon app window is gone"); return; } plug_xid = GDK_WINDOW_XID (icon_app_window); display = gtk_widget_get_display (GTK_WIDGET (icon->priv->socket)); gdk_error_trap_push (); _NET_WM_PID = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_PID"); result = XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display), plug_xid, _NET_WM_PID, 0, G_MAXLONG, False, XA_CARDINAL, &type, &format, &nitems, &bytes_after, (guchar **)&val); if (!gdk_error_trap_pop () && result == Success && type == XA_CARDINAL && nitems == 1) icon->priv->pid = *val; if (val) XFree (val); }
void new_tab_page(struct Gtkabber *gtkabber, GtkWidget *socket) { gtk_widget_show( socket ); gtk_notebook_append_page( GTK_NOTEBOOK(gtkabber->toplevel.notebook), socket, NULL ); gtk_notebook_set_current_page( GTK_NOTEBOOK(gtkabber->toplevel.notebook), -1 ); gtk_notebook_set_tab_reorderable (GTK_NOTEBOOK( gtkabber->toplevel.notebook), socket, TRUE); printf("%d\n", gtk_socket_get_id( GTK_SOCKET( socket ) ) ); fflush(stdout); }