static void createDrawContext(GtkWidget** widget, GdkWindow** window){ GtkWidget *main_window; GdkWindow *gdk_win; char* xwindow_s = getenv("XSCREENSAVER_WINDOW"); if (xwindow_s != NULL) { // parse out the xid from xscreensaver's env var, which is given as // hex like 0x12023 int xid = (int)strtol(xwindow_s, NULL, 0); // if we are running in xscreensaver mode, use the provided window XID main_window = gtk_window_new(GTK_WINDOW_POPUP); //main_window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gdk_win = gdk_window_foreign_new(xid); gtk_widget_show_all(main_window); // reparent window of main_window to gdk_win gdk_window_reparent(gtk_widget_get_window(main_window), gdk_win, 0, 0); gint width; gint height; gdk_window_get_geometry(gdk_win, NULL, NULL, &width, &height, NULL); printf("Looks like we are about %dx%d\n",width,height); // Make us cover our parent window gtk_window_move(GTK_WINDOW(main_window), 0, 0); gtk_window_set_default_size(GTK_WINDOW(main_window), width, height); gtk_widget_set_size_request(main_window, width, height); } else { // otherwise just get a normal window main_window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_default_size(GTK_WINDOW(main_window), 800, 600); gdk_win = gtk_widget_get_window(main_window); } *widget = main_window; *window = gdk_win; }
bool wxNativeContainerWindow::Create(wxNativeContainerWindowHandle win) { wxCHECK( win, false ); if ( !wxTopLevelWindow::Create(NULL, wxID_ANY, "") ) return false; // we need to realize the window first before reparenting it gtk_widget_realize(m_widget); gdk_window_reparent(gtk_widget_get_window(m_widget), win, 0, 0); #ifdef GDK_WINDOWING_X11 // if the native window is destroyed, our own window will be destroyed too // but GTK doesn't expect it and will complain about "unexpectedly // destroyed" GdkWindow, so intercept to DestroyNotify ourselves to fix // this and also destroy the associated C++ object when its window is // destroyed gdk_window_add_filter(gtk_widget_get_window(m_widget), wxNativeContainerWindowFilter, this); #endif // GDK_WINDOWING_X11 // we should be initially visible as we suppose that the native window we // wrap is (we could use gdk_window_is_visible() to test for this but this // doesn't make much sense unless we also react to visibility changes, so // just suppose it's always shown for now) Show(); return true; }
void tray_icon_added (NaTrayManager *manager, Window child, GtkWidget* container) { GdkWindow* wrapper = create_wrapper(gtk_widget_get_window(container), child); if (wrapper == NULL) return; GdkWindow* icon = get_icon_window(wrapper); g_assert(icon != NULL); gdk_window_reparent(wrapper, gtk_widget_get_window(container), 0, gdk_screen_height() - DOCK_HEIGHT); //add this mask so, gdk can handle GDK_SELECTION_CLEAR event to destroy this gdkwindow. gdk_window_set_events(icon, GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK | GDK_VISIBILITY_NOTIFY_MASK); gdk_window_add_filter(icon, (GdkFilterFunc)monitor_icon_event, wrapper); gdk_window_set_composited(wrapper, TRUE); gdk_window_show(wrapper); char *re_class = NULL; get_wmclass(icon, &re_class, NULL); if (g_strcmp0(re_class, DEEPIN_TRAY_ICON) == 0) { _deepin_tray = wrapper; _deepin_tray_width = CLAMP_WIDTH(gdk_window_get_width(icon)); _update_deepin_try_position(); } else if (g_strcmp0(re_class, FCITX_TRAY_ICON) == 0) { _fcitx_tray = wrapper; _fcitx_tray_width = CLAMP_WIDTH(gdk_window_get_width(icon)); _update_fcitx_try_position(); } else { int width = gdk_window_get_width(icon) * 1.0 / gdk_window_get_height(icon) * DEFAULT_HEIGHT; gdk_window_resize(icon, width, DEFAULT_HEIGHT); g_hash_table_insert(_icons, wrapper, GINT_TO_POINTER(CLAMP_WIDTH(width))); } g_free(re_class); _update_notify_area_width(); }
void gui_gtk_widget_create(void) { GtkWidget *main_vbox; GtkWidget *menubar; gchar *accel = NULL; gint root_x, root_y; main_window = gtk_window_new(GTK_WINDOW_TOPLEVEL); // gtk_widget_set_double_buffered(GTK_WIDGET(main_window), FALSE); gtk_window_set_resizable(GTK_WINDOW(main_window), FALSE); gtk_window_set_title(GTK_WINDOW(main_window), np2oscfg.titles); gtk_widget_add_events(main_window, EVENT_MASK); main_vbox = gtk_vbox_new(FALSE, 0); gtk_container_add(GTK_CONTAINER(main_window), main_vbox); gtk_widget_show(main_vbox); menubar = create_menu(); gtk_box_pack_start(GTK_BOX(main_vbox), menubar, FALSE, TRUE, 0); gtk_widget_show(menubar); drawarea = gtk_drawing_area_new(); // gtk_widget_set_double_buffered(GTK_WIDGET(drawarea), FALSE); gtk_widget_set_size_request(GTK_WIDGET(drawarea), 640, 400); gtk_box_pack_end(GTK_BOX(main_vbox), drawarea, FALSE, TRUE, 0); gtk_widget_show(drawarea); g_object_get(gtk_widget_get_settings(main_window), "gtk-menu-bar-accel", &accel, NULL); if (accel) { g_object_set(gtk_widget_get_settings(main_window), "gtk-menu-bar-accel", "Menu", NULL); g_free(accel); } gtk_widget_realize(main_window); gdk_window_get_origin(main_window->window, &root_x, &root_y); gdk_window_reparent(main_window->window, NULL, root_x, root_y); set_icon_bitmap(main_window); g_signal_connect(GTK_OBJECT(main_window), "destroy", G_CALLBACK(destroy_evhandler), (gpointer)"WM destroy"); g_signal_connect(GTK_OBJECT(main_window), "key_press_event", G_CALLBACK(key_press_evhandler), NULL); g_signal_connect(GTK_OBJECT(main_window), "key_release_event", G_CALLBACK(key_release_evhandler), NULL); g_signal_connect(GTK_OBJECT(main_window), "button_press_event", G_CALLBACK(button_press_evhandler), NULL); g_signal_connect(GTK_OBJECT(main_window), "button_release_event", G_CALLBACK(button_release_evhandler), NULL); g_signal_connect(GTK_OBJECT(main_window), "motion_notify_event", G_CALLBACK(motion_notify_evhandler), NULL); g_signal_connect(GTK_OBJECT(drawarea), "configure_event", G_CALLBACK(configure_evhandler), NULL); g_signal_connect(GTK_OBJECT(drawarea), "expose_event", G_CALLBACK(expose_evhandler), NULL); }
void frame_window_realized (GtkWidget *widget, gpointer data) { decor_t *d = (decor_t *) data; if (d) { GdkWindow *gdk_frame_window = gtk_widget_get_window (d->decor_window); gdk_window_reparent (gdk_frame_window, d->frame_window, 0, 0); gdk_window_lower (gdk_frame_window); } }
static void realize(GtkWidget* widget) { parent_class->realize(widget); wxPizza* pizza = WX_PIZZA(widget); if (pizza->m_border_style || pizza->m_is_scrollable) { int border_x, border_y; pizza->get_border_widths(border_x, border_y); int x = widget->allocation.x + border_x; int y = widget->allocation.y + border_y; int w = widget->allocation.width - 2 * border_x; int h = widget->allocation.height - 2 * border_y; if (w < 0) w = 0; if (h < 0) h = 0; if (pizza->m_is_scrollable) { // second window is created if wxWindow is scrollable GdkWindowAttr attr; attr.event_mask = 0; attr.x = x; attr.y = y; attr.width = w; attr.height = h; attr.wclass = GDK_INPUT_OUTPUT; attr.visual = gtk_widget_get_visual(widget); attr.colormap = gtk_widget_get_colormap(widget); attr.window_type = GDK_WINDOW_CHILD; pizza->m_backing_window = gdk_window_new( gdk_window_get_parent(widget->window), &attr, GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP); gdk_window_set_user_data(pizza->m_backing_window, widget); gdk_window_reparent(widget->window, pizza->m_backing_window, 0, 0); gdk_window_resize(widget->window, w, h); // Parts of m_backing_window may be exposed temporarily while // resizing. Setting the backing pixmap to None prevents those // areas from being briefly painted black. gdk_window_set_back_pixmap(pizza->m_backing_window, NULL, false); } else gdk_window_move_resize(widget->window, x, y, w, h); } }
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()); }
JNIEXPORT void JNICALL Java_org_gnome_gdk_GdkWindow_gdk_1window_1reparent ( JNIEnv* env, jclass cls, jlong _self, jlong _newParent, jint _x, jint _y ) { GdkWindow* self; GdkWindow* newParent; gint x; gint y; // convert parameter self self = (GdkWindow*) _self; // convert parameter newParent newParent = (GdkWindow*) _newParent; // convert parameter x x = (gint) _x; // convert parameter y y = (gint) _y; // call function gdk_window_reparent(self, newParent, x, y); // cleanup parameter self // cleanup parameter newParent // cleanup parameter x // cleanup parameter y }
static VALUE gdkwin_reparent(VALUE self, VALUE new_parent, VALUE x, VALUE y) { gdk_window_reparent(_SELF(self), _SELF(new_parent), NUM2INT(x), NUM2INT(y)); return self; }
void moz_drawingarea_reparent (MozDrawingarea *drawingarea, GdkWindow *aNewParent) { gdk_window_reparent(drawingarea->clip_window, aNewParent, 0, 0); }
void gdk_superwin_reparent(GdkSuperWin *superwin, GdkWindow *parent_window) { gdk_window_reparent(superwin->shell_window, parent_window, 0, 0); }