/* This function will make sure that tilda window becomes active (gains * the focus) when it is called. * * This has to be the worst possible way of making this work, but it was the * only way to get metacity to play nicely. All the other WM's are so nice, * why oh why does metacity hate us so? */ void tilda_window_set_active (tilda_window *tw) { DEBUG_FUNCTION ("tilda_window_set_active"); DEBUG_ASSERT (tw != NULL); Display *x11_display = GDK_WINDOW_XDISPLAY (gtk_widget_get_window (tw->window) ); Window x11_window = GDK_WINDOW_XID (gtk_widget_get_window (tw->window) ); Window x11_root_window = GDK_WINDOW_XID ( gtk_widget_get_root_window (tw->window) ); GdkScreen *screen = gtk_widget_get_screen (tw->window); XEvent event; long mask = SubstructureRedirectMask | SubstructureNotifyMask; gtk_window_move (GTK_WINDOW(tw->window), config_getint ("x_pos"), config_getint ("y_pos")); if (gdk_x11_screen_supports_net_wm_hint (screen, gdk_atom_intern_static_string ("_NET_ACTIVE_WINDOW"))) { guint32 timestamp = gtk_get_current_event_time (); if (timestamp == 0) { timestamp = gdk_x11_get_server_time(gtk_widget_get_root_window (tw->window)); } event.xclient.type = ClientMessage; event.xclient.serial = 0; event.xclient.send_event = True; event.xclient.display = x11_display; event.xclient.window = x11_window; event.xclient.message_type = gdk_x11_get_xatom_by_name ("_NET_ACTIVE_WINDOW"); event.xclient.format = 32; event.xclient.data.l[0] = 2; /* pager */ event.xclient.data.l[1] = timestamp; /* timestamp */ event.xclient.data.l[2] = 0; event.xclient.data.l[3] = 0; event.xclient.data.l[4] = 0; XSendEvent (x11_display, x11_root_window, False, mask, &event); } else { /* The WM doesn't support the EWMH standards. We'll print a warning and * try this, though it probably won't work... */ g_printerr (_("WARNING: Window manager (%s) does not support EWMH hints\n"), gdk_x11_screen_get_window_manager_name (screen)); XRaiseWindow (x11_display, x11_window); } }
gboolean turn (gpointer user_data) { static double place = 0.0; place++; while (place>360.0) { place -= 360.0; } XMoveWindow (GDK_WINDOW_XDISPLAY (window->window), GDK_WINDOW_XID (window->window), 100+100*sin(place*(M_PI/180)), 100+100*cos(place*(M_PI/180))); return TRUE; }
static void draw_background (GnomeBGCrossfade *fade) { if (gdk_window_get_window_type (fade->priv->window) == GDK_WINDOW_ROOT) { XClearArea (GDK_WINDOW_XDISPLAY (fade->priv->window), GDK_WINDOW_XID (fade->priv->window), 0, 0, gdk_window_get_width (fade->priv->window), gdk_window_get_height (fade->priv->window), False); send_root_property_change_notification (fade); gdk_flush (); } else { gdk_window_invalidate_rect (fade->priv->window, NULL, FALSE); gdk_window_process_updates (fade->priv->window, FALSE); } }
/* * Need to get GdkWindow after invoke gtk_widget_show() and gtk_main() */ static gboolean have_extension (InputPadGtkWindow *window) { int opcode = 0; int event = 0; int error = 0; g_return_val_if_fail (window != NULL && INPUT_PAD_IS_GTK_WINDOW (window), FALSE); if (!XQueryExtension (GDK_WINDOW_XDISPLAY (gtk_widget_get_window (GTK_WIDGET (window))), "XTEST", &opcode, &event, &error)) { g_warning ("Could not find XTEST module. Maybe you did not install " "libXtst library.\n" "%% xdpyinfo | grep XTEST"); return FALSE; } return TRUE; }
static gboolean input_pad_xkb_init (InputPadGtkWindow *window) { static gboolean retval = FALSE; Display *xdisplay = GDK_WINDOW_XDISPLAY (gtk_widget_get_window (GTK_WIDGET (window))); if (retval) { return retval; } if (!XkbQueryExtension (xdisplay, NULL, NULL, NULL, NULL, NULL)) { g_warning ("Could not init XKB"); return FALSE; } XkbInitAtoms (NULL); retval = TRUE; return TRUE; }
//////////////////////////////////////////////////////////// /// Construct the wxSFMLCanvas //////////////////////////////////////////////////////////// wxSFMLCanvas::wxSFMLCanvas(wxWindow* Parent, wxWindowID Id, const wxPoint& Position, const wxSize& Size, long Style) : wxControl(Parent, Id, Position, Size, Style) { #ifdef __WXGTK__ // GTK implementation requires to go deeper to find the low-level X11 identifier of the widget gtk_widget_realize(m_wxwindow); gtk_widget_set_double_buffered(m_wxwindow, false); GdkWindow* Win = GTK_PIZZA(m_wxwindow)->bin_window; XFlush(GDK_WINDOW_XDISPLAY(Win)); sf::RenderWindow::Create(GDK_WINDOW_XWINDOW(Win)); #else // Tested under Windows XP only (should work with X11 and other Windows versions - no idea about MacOS) sf::RenderWindow::create(GetHandle()); #endif }
static void shortcut_edited_cb(GtkCellRendererText *cell, const char *path_string, guint keyval, EggVirtualModifierType mask, guint keycode, gpointer data) { Vnkb *vnkb = (Vnkb*)data; GtkTreeModel *model = GTK_TREE_MODEL(vnkb->store); GtkTreePath *path = gtk_tree_path_new_from_string (path_string); GtkTreeIter iter; KeyEntry *key_entry, tmp_key; GError *err = NULL; char *str; GdkWindow *gdkroot = gdk_get_default_root_window(); Display *display = GDK_WINDOW_XDISPLAY(gdkroot); gtk_tree_model_get_iter (model, &iter, path); gtk_tree_model_get (model, &iter, 1, &key_entry, -1); /* sanity check */ if (key_entry == NULL) { gtk_tree_path_free (path); return; } tmp_key.keyval = keyval; tmp_key.keycode = keycode; tmp_key.mask = mask; *key_entry = tmp_key; gtk_tree_model_row_changed (model, path, &iter); gtk_tree_path_free (path); vnkb->xvnkb->hotkey.state = mask; vnkb->xvnkb->hotkey.sym = XKeycodeToKeysym(display,keycode,0); if (vnkb->xvnkb->hotkey.state & VK_SHIFT) vnkb->xvnkb->hotkey.sym = toupper(vnkb->xvnkb->hotkey.sym); vnkb_xvnkb_update_switchkey(vnkb); }
/* OGLCanvas::OGLCanvas * OGLCanvas class constructor, SFML implementation *******************************************************************/ OGLCanvas::OGLCanvas(wxWindow* parent, int id, bool handle_timer) : wxControl(parent, id, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE|wxWANTS_CHARS), timer(this) { init_done = false; last_time = theApp->runTimer(); if (handle_timer) timer.Start(100); // Code taken from SFML wxWidgets integration example sf::WindowHandle handle; #ifdef __WXGTK__ // GTK implementation requires to go deeper to find the // low-level X11 identifier of the widget gtk_widget_realize(m_wxwindow); gtk_widget_set_double_buffered(m_wxwindow, false); GdkWindow* Win = gtk_widget_get_window(m_wxwindow); XFlush(GDK_WINDOW_XDISPLAY(Win)); //sf::RenderWindow::Create(GDK_WINDOW_XWINDOW(Win)); handle = GDK_WINDOW_XWINDOW(Win); #else handle = GetHandle(); #endif #if SFML_VERSION_MAJOR < 2 sf::RenderWindow::Create(handle); #else // Context settings sf::ContextSettings settings; settings.depthBits = 32; settings.stencilBits = 8; sf::RenderWindow::create(handle, settings); #endif // Bind events Bind(wxEVT_PAINT, &OGLCanvas::onPaint, this); Bind(wxEVT_ERASE_BACKGROUND, &OGLCanvas::onEraseBackground, this); //Bind(wxEVT_IDLE, &OGLCanvas::onIdle, this); if (handle_timer) Bind(wxEVT_TIMER, &OGLCanvas::onTimer, this); }
/* The plug window should completely occupy the area of the child, so we won't * get a draw event. But in case we do (the plug unmaps itself, say), this * draw handler draws with real or fake transparency. */ static gboolean na_tray_child_draw (GtkWidget *widget, cairo_t *cr) { NaTrayChild *child = NA_TRAY_CHILD (widget); if (na_tray_child_has_alpha (child)) { /* Clear to transparent */ cairo_set_source_rgba (cr, 0, 0, 0, 0); cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE); cairo_paint (cr); } else if (child->parent_relative_bg) { GdkWindow *window; cairo_surface_t *target; GdkRectangle clip_rect; window = gtk_widget_get_window (widget); target = cairo_get_group_target (cr); gdk_cairo_get_clip_rectangle (cr, &clip_rect); /* Clear to parent-relative pixmap * We need to use direct X access here because GDK doesn't know about * the parent relative pixmap. */ cairo_surface_flush (target); XClearArea (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window), clip_rect.x, clip_rect.y, clip_rect.width, clip_rect.height, False); cairo_surface_mark_dirty_rectangle (target, clip_rect.x, clip_rect.y, clip_rect.width, clip_rect.height); } return FALSE; }
void MdispGtkView::X11Annotations( bool on ) { m_isX11AnnotationsEnabled = on; if(on) { gtk_widget_queue_draw_area(m_window,0,0,1,1); } // make sur the window is mapped else if(m_window->window) { XEvent ev; ev.type = Expose; ev.xexpose.window = GDK_WINDOW_XID(m_window->window); ev.xexpose.x = 0; ev.xexpose.y = 0; ev.xexpose.width = m_window->allocation.width; ev.xexpose.height = m_window->allocation.height; XSendEvent(GDK_WINDOW_XDISPLAY(m_window->window),GDK_WINDOW_XID(m_window->window), true, ExposureMask, &ev); } }
void panel_warp_pointer (GdkWindow *gdk_window, int x, int y) { Display *display; Window window; g_return_if_fail (GDK_IS_WINDOW (gdk_window)); display = GDK_WINDOW_XDISPLAY (gdk_window); window = GDK_WINDOW_XID (gdk_window); gdk_error_trap_push (); XWarpPointer (display, None, window, 0, 0, 0, 0, x, y); #if GTK_CHECK_VERSION (3, 0, 0) gdk_error_trap_pop_ignored (); #else gdk_error_trap_pop (); #endif }
//////////////////////////////////////////////////////////// /// Construct the wxSFMLCanvas //////////////////////////////////////////////////////////// wxSFMLCanvas::wxSFMLCanvas(wxWindow *Parent, wxWindowID Id, const wxPoint &Position, const wxSize &Size, long Style) : wxControl(Parent, Id, Position, Size, Style) { #ifdef __WXGTK__ // GTK implementation requires to go deeper to find the low-level X11 // identifier of the widget gtk_widget_realize(m_wxwindow); gtk_widget_set_double_buffered(m_wxwindow, false); GtkWidget *privHandle = m_wxwindow; wxPizza *pizza = WX_PIZZA(privHandle); GtkWidget *widget = GTK_WIDGET(pizza); // Get the internal gtk window... #if GTK_CHECK_VERSION(3, 0, 0) GdkWindow *win = gtk_widget_get_window(widget); #else GdkWindow *win = widget->window; #endif XFlush(GDK_WINDOW_XDISPLAY(win)); //...and pass it to the sf::RenderWindow. #if GTK_CHECK_VERSION(3, 0, 0) sf::RenderWindow::create(GDK_WINDOW_XID(win)); #else sf::RenderWindow::create(GDK_WINDOW_XWINDOW(win)); #endif #else // Tested under Windows XP only (should work with X11 and other Windows // versions - no idea about MacOS) sf::RenderWindow::create(static_cast<sf::WindowHandle>(GetHandle())); #endif }
bool NetscapePlugin::platformPostInitializeWindowed(bool needsXEmbed, uint64_t windowID) { m_npWindow.type = NPWindowTypeWindow; if (!needsXEmbed) { notImplemented(); return false; } Display* display = x11HostDisplay(); #if PLATFORM(GTK) // 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)); 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); m_npWindow.window = GINT_TO_POINTER(gtk_socket_get_id(GTK_SOCKET(socket))); GdkWindow* window = gtk_widget_get_window(socket); NPSetWindowCallbackStruct* callbackStruct = static_cast<NPSetWindowCallbackStruct*>(m_npWindow.ws_info); callbackStruct->display = GDK_WINDOW_XDISPLAY(window); callbackStruct->visual = GDK_VISUAL_XVISUAL(gdk_window_get_visual(window)); callbackStruct->depth = gdk_visual_get_depth(gdk_window_get_visual(window)); callbackStruct->colormap = XCreateColormap(display, GDK_ROOT_WINDOW(), callbackStruct->visual, AllocNone); #else UNUSED_PARAM(windowID); #endif XFlush(display); callSetWindow(); return true; }
void gdk_property_delete (GdkWindow *window, GdkAtom property) { g_return_if_fail (!window || GDK_IS_WINDOW (window)); if (!window) { GdkScreen *screen = gdk_screen_get_default (); window = gdk_screen_get_root_window (screen); GDK_NOTE (MULTIHEAD, g_message ("gdk_property_delete(): window is NULL\n")); } if (GDK_WINDOW_DESTROYED (window)) return; XDeleteProperty (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XWINDOW (window), gdk_x11_atom_to_xatom_for_display (GDK_WINDOW_DISPLAY (window), property)); }
bool wxTopLevelWindowGTK::SetTransparent(wxByte alpha) { if (m_widget == NULL) return false; #if GTK_CHECK_VERSION(2,12,0) #ifndef __WXGTK3__ if (gtk_check_version(2,12,0) == NULL) #endif { gtk_window_set_opacity(GTK_WINDOW(m_widget), alpha / 255.0); return true; } #endif // GTK_CHECK_VERSION(2,12,0) #ifndef __WXGTK3__ #ifdef GDK_WINDOWING_X11 GdkWindow* window = gtk_widget_get_window(m_widget); if (window == NULL) return false; Display* dpy = GDK_WINDOW_XDISPLAY(window); Window win = GDK_WINDOW_XID(window); if (alpha == 0xff) XDeleteProperty(dpy, win, XInternAtom(dpy, "_NET_WM_WINDOW_OPACITY", False)); else { long opacity = alpha * 0x1010101L; XChangeProperty(dpy, win, XInternAtom(dpy, "_NET_WM_WINDOW_OPACITY", False), XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &opacity, 1L); } XSync(dpy, False); return true; #else // !GDK_WINDOWING_X11 return false; #endif // GDK_WINDOWING_X11 / !GDK_WINDOWING_X11 #endif // !__WXGTK3__ }
static void egg_tray_manager_set_orientation_property (EggTrayManager *manager) { #ifdef GDK_WINDOWING_X11 gulong data[1]; if (!manager->invisible || !manager->invisible->window) return; g_assert (manager->orientation_atom != None); data[0] = manager->orientation == GTK_ORIENTATION_HORIZONTAL ? SYSTEM_TRAY_ORIENTATION_HORZ : SYSTEM_TRAY_ORIENTATION_VERT; XChangeProperty (GDK_WINDOW_XDISPLAY (manager->invisible->window), GDK_WINDOW_XWINDOW (manager->invisible->window), manager->orientation_atom, XA_CARDINAL, 32, PropModeReplace, (guchar *) &data, 1); #endif }
// this function will make sure that everything has been initialized. nsresult nsScreenManagerGtk :: EnsureInit() { if (mCachedScreenArray.Count() > 0) return NS_OK; mRootWindow = gdk_get_default_root_window(); g_object_ref(mRootWindow); // GDK_STRUCTURE_MASK ==> StructureNotifyMask, for ConfigureNotify // GDK_PROPERTY_CHANGE_MASK ==> PropertyChangeMask, for PropertyNotify gdk_window_set_events(mRootWindow, GdkEventMask(gdk_window_get_events(mRootWindow) | GDK_STRUCTURE_MASK | GDK_PROPERTY_CHANGE_MASK)); gdk_window_add_filter(mRootWindow, root_window_event_filter, this); #ifdef MOZ_X11 mNetWorkareaAtom = XInternAtom(GDK_WINDOW_XDISPLAY(mRootWindow), "_NET_WORKAREA", False); #endif return Init(); }
/** * hildon_remote_texture_send_message: * @self: A #HildonRemoteTexture * @message_type: Message id for the remote texture message. * @l0: 1st remote texture message parameter. * @l1: 2nd remote texture message parameter. * @l2: 3rd remote texture message parameter. * @l3: 4th remote texture message parameter. * @l4: 5th remote texture message parameter. * * Sends an X11 ClientMessage event to the window manager with * the specified parameters -- id (@message_type) and data (@l0, * @l1, @l2, @l3, @l4). * * This is an internal utility function that application will * not need to call directly. * * Since: 2.2 **/ void hildon_remote_texture_send_message (HildonRemoteTexture *self, guint32 message_type, guint32 l0, guint32 l1, guint32 l2, guint32 l3, guint32 l4) { GtkWidget *widget = GTK_WIDGET (self); Display *display = GDK_WINDOW_XDISPLAY (widget->window); Window window = GDK_WINDOW_XID (widget->window); XEvent event = { 0 }; event.xclient.type = ClientMessage; event.xclient.window = window; event.xclient.message_type = (Atom)message_type; event.xclient.format = 32; event.xclient.data.l[0] = l0; event.xclient.data.l[1] = l1; event.xclient.data.l[2] = l2; event.xclient.data.l[3] = l3; event.xclient.data.l[4] = l4; #if 0 g_debug ("%lu (%lu %lu %lu %lu %lu) -> %lu\n", message_type, l0, l1, l2, l3, l4, window); #endif XSendEvent (display, window, True, StructureNotifyMask, (XEvent *)&event); }
void OGLCanvas::createSFML() { #ifdef USE_SFML_RENDERWINDOW // Code taken from SFML wxWidgets integration example sf::WindowHandle handle; #ifdef __WXGTK__ // GTK implementation requires to go deeper to find the // low-level X11 identifier of the widget gtk_widget_realize(m_wxwindow); gtk_widget_set_double_buffered(m_wxwindow, false); GdkWindow* Win = gtk_widget_get_window(m_wxwindow); XFlush(GDK_WINDOW_XDISPLAY(Win)); // sf::RenderWindow::Create(GDK_WINDOW_XWINDOW(Win)); handle = GDK_WINDOW_XWINDOW(Win); #else handle = GetHandle(); #endif // Context settings sf::ContextSettings settings; settings.depthBits = 24; settings.stencilBits = 8; sf::RenderWindow::create(handle, settings); #endif }
/** * _gtk_xembed_send_message: * @recipient: (allow-none): window to which to send the window, or %NULL * in which case nothing will be sent * @message: type of message * @detail: detail field of message * @data1: data1 field of message * @data2: data2 field of message * * Sends a generic XEMBED message to a particular window. **/ void _gtk_xembed_send_message (GdkWindow *recipient, XEmbedMessageType message, glong detail, glong data1, glong data2) { GdkDisplay *display; XClientMessageEvent xclient; if (!recipient) return; g_return_if_fail (GDK_IS_WINDOW (recipient)); display = gdk_window_get_display (recipient); GTK_NOTE (PLUGSOCKET, g_message ("Sending %s", _gtk_xembed_message_name (message))); memset (&xclient, 0, sizeof (xclient)); xclient.window = GDK_WINDOW_XID (recipient); xclient.type = ClientMessage; xclient.message_type = gdk_x11_get_xatom_by_name_for_display (display, "_XEMBED"); xclient.format = 32; xclient.data.l[0] = gtk_xembed_get_time (); xclient.data.l[1] = message; xclient.data.l[2] = detail; xclient.data.l[3] = data1; xclient.data.l[4] = data2; gdk_x11_display_error_trap_push (display); XSendEvent (GDK_WINDOW_XDISPLAY(recipient), GDK_WINDOW_XID (recipient), False, NoEventMask, (XEvent *)&xclient); gdk_x11_display_error_trap_pop_ignored (display); }
bool wxTopLevelWindowGTK::SetTransparent(wxByte alpha) { if (!m_widget || !m_widget->window) return false; Display* dpy = GDK_WINDOW_XDISPLAY (m_widget->window); // We need to get the X Window that has the root window as the immediate parent // and m_widget->window as a child. This should be the X Window that the WM manages and // from which the opacity property is checked from. Window win = wxGetTopmostWindowX11(dpy, GDK_WINDOW_XID (m_widget->window)); // Using pure Xlib to not have a GTK version check mess due to gtk2.0 not having GdkDisplay if (alpha == 0xff) XDeleteProperty(dpy, win, XInternAtom(dpy, "_NET_WM_WINDOW_OPACITY", False)); else { long opacity = alpha * 0x1010101L; XChangeProperty(dpy, win, XInternAtom(dpy, "_NET_WM_WINDOW_OPACITY", False), XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &opacity, 1L); } XSync(dpy, False); return true; }
LOCAL_SYMBOL MetaWindowMenu* meta_window_menu_new (MetaFrames *frames, MetaMenuOp ops, MetaMenuOp insensitive, Window client_xwindow, unsigned long active_workspace, int n_workspaces, MetaWindowMenuFunc func, gpointer data) { int i; MetaWindowMenu *menu; /* FIXME: Modifications to 'ops' should happen in meta_window_show_menu */ if (n_workspaces < 2) ops &= ~(META_MENU_OP_STICK | META_MENU_OP_UNSTICK | META_MENU_OP_WORKSPACES); menu = g_new (MetaWindowMenu, 1); menu->frames = frames; menu->client_xwindow = client_xwindow; menu->func = func; menu->data = data; menu->ops = ops; menu->insensitive = insensitive; menu->menu = gtk_menu_new (); gtk_menu_set_screen (GTK_MENU (menu->menu), gtk_widget_get_screen (GTK_WIDGET (frames))); for (i = 0; i < (int) G_N_ELEMENTS (menuitems); i++) { MenuItem menuitem = menuitems[i]; if (ops & menuitem.op || menuitem.op == 0) { GtkWidget *mi; MenuData *md; unsigned int key; MetaVirtualModifier mods; mi = menu_item_new (&menuitem, -1); /* Set the activeness of radiobuttons. */ switch (menuitem.op) { case META_MENU_OP_STICK: gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (mi), active_workspace == 0xFFFFFFFF); break; case META_MENU_OP_UNSTICK: gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (mi), active_workspace != 0xFFFFFFFF); break; default: break; } if (menuitem.type == MENU_ITEM_WORKSPACE_LIST) { if (ops & META_MENU_OP_WORKSPACES) { Display *display; Window xroot; GdkScreen *screen; GdkWindow *window; GtkWidget *submenu; int j; MenuItem to_another_workspace = { 0, MENU_ITEM_NORMAL, NULL, FALSE, N_("Move to Another _Workspace") }; meta_verbose ("Creating %d-workspace menu current space %lu\n", n_workspaces, active_workspace); window = gtk_widget_get_window (GTK_WIDGET (frames)); display = GDK_WINDOW_XDISPLAY (window); screen = gdk_window_get_screen (window); xroot = GDK_WINDOW_XID (gdk_screen_get_root_window (screen)); submenu = gtk_menu_new (); g_assert (mi==NULL); mi = menu_item_new (&to_another_workspace, -1); gtk_menu_item_set_submenu (GTK_MENU_ITEM (mi), submenu); for (j = 0; j < n_workspaces; j++) { char *label; MenuData *md; unsigned int key; MetaVirtualModifier mods; MenuItem moveitem; GtkWidget *submi; meta_core_get_menu_accelerator (META_MENU_OP_WORKSPACES, j + 1, &key, &mods); label = get_workspace_name_with_accel (display, xroot, j); moveitem.type = MENU_ITEM_NORMAL; moveitem.op = META_MENU_OP_WORKSPACES; moveitem.label = label; submi = menu_item_new (&moveitem, j + 1); g_free (label); if ((active_workspace == (unsigned)j) && (ops & META_MENU_OP_UNSTICK)) gtk_widget_set_sensitive (submi, FALSE); md = g_new (MenuData, 1); md->menu = menu; md->op = META_MENU_OP_WORKSPACES; g_object_set_data (G_OBJECT (submi), "workspace", GINT_TO_POINTER (j)); g_signal_connect_data (G_OBJECT (submi), "activate", G_CALLBACK (activate_cb), md, (GClosureNotify) g_free, 0); gtk_menu_shell_append (GTK_MENU_SHELL (submenu), submi); gtk_widget_show (submi); } } else meta_verbose ("not creating workspace menu\n"); } else if (menuitem.type != MENU_ITEM_SEPARATOR) { meta_core_get_menu_accelerator (menuitems[i].op, -1, &key, &mods); if (insensitive & menuitem.op) gtk_widget_set_sensitive (mi, FALSE); md = g_new (MenuData, 1); md->menu = menu; md->op = menuitem.op; g_signal_connect_data (G_OBJECT (mi), "activate", G_CALLBACK (activate_cb), md, (GClosureNotify) g_free, 0); } if (mi) { gtk_menu_shell_append (GTK_MENU_SHELL (menu->menu), mi); gtk_widget_show (mi); } } } g_signal_connect (menu->menu, "selection_done", G_CALLBACK (menu_closed), menu); return menu; }
void gu_video_create(gu_nav_page_t *gnp) { prop_courier_t *pc = gnp->gnp_gt->gt_gw->gw_gu->gu_pc; struct video_output *vo; char errbuf[256]; char buf[512]; gu_video_t *gv; gnp->gnp_pageroot = gtk_drawing_area_new(); gtk_container_add(GTK_CONTAINER(gnp->gnp_pagebin), gnp->gnp_pageroot); gtk_widget_show_all(gnp->gnp_pageroot); vo = x11_vo_create(GDK_WINDOW_XDISPLAY(gnp->gnp_pageroot->window), GDK_WINDOW_XID(gnp->gnp_pageroot->window), pc, gnp->gnp_prop, errbuf, sizeof(errbuf)); if(vo == NULL) { gtk_widget_destroy(gnp->gnp_pageroot); snprintf(buf, sizeof(buf), "Unable to start video: %s", errbuf); gnp->gnp_pageroot = gtk_label_new(buf); gtk_container_add(GTK_CONTAINER(gnp->gnp_pagebin), gnp->gnp_pageroot); gtk_widget_show_all(gnp->gnp_pageroot); return; } gv = calloc(1, sizeof(gu_video_t)); gv->gv_closeprop = prop_ref_inc(prop_create(gnp->gnp_prop, "close")); gv->gv_status_sub = prop_subscribe(0, PROP_TAG_NAME("self", "media", "playstatus"), PROP_TAG_CALLBACK_STRING, video_set_playstatus, gv, PROP_TAG_COURIER, pc, PROP_TAG_NAMED_ROOT, gnp->gnp_prop, "self", NULL); g_signal_connect(GTK_OBJECT(gnp->gnp_pageroot), "destroy", G_CALLBACK(video_destroy), gv); g_signal_connect(G_OBJECT(gnp->gnp_pageroot), "expose_event", G_CALLBACK(expose_event_callback), vo); g_signal_connect_after(G_OBJECT(gnp->gnp_pageroot), "configure_event", G_CALLBACK(configure_event_callback), vo); g_signal_connect(GTK_OBJECT(gnp->gnp_pageroot), "unrealize", G_CALLBACK(video_unrealize), vo); g_signal_connect(G_OBJECT(gnp->gnp_pageroot), "button-press-event", G_CALLBACK(mouse_press), gnp); gtk_widget_add_events(gnp->gnp_pageroot, GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK); gu_page_set_fullwindow(gnp, 1); }
static void accessx_status_applet_update(AccessxStatusApplet* sapplet, AccessxStatusNotifyType notify_type, XkbEvent* event) { GdkWindow* window; gint i; window = gtk_widget_get_window(GTK_WIDGET(sapplet->applet)); if (notify_type & ACCESSX_STATUS_MODIFIERS) { unsigned int locked_mods = 0, latched_mods = 0; if (event != NULL) { locked_mods = event->state.locked_mods; latched_mods = event->state.latched_mods; } else if (sapplet->applet && window) { XkbStateRec state; XkbGetState(GDK_WINDOW_XDISPLAY(window), XkbUseCoreKbd, &state); locked_mods = state.locked_mods; latched_mods = state.latched_mods; } /* determine which modifiers are locked, and set state accordingly */ for (i = 0; i < G_N_ELEMENTS(modifiers); ++i) { if (modifiers[i].indicator != NULL && modifiers[i].mask) { if (locked_mods & modifiers[i].mask) { gtk_widget_set_sensitive(modifiers[i].indicator, TRUE); #if GTK_CHECK_VERSION (3, 0, 0) gtk_widget_set_state_flags (modifiers[i].indicator, GTK_STATE_FLAG_SELECTED, TRUE); #else gtk_widget_set_state(modifiers[i].indicator, GTK_STATE_SELECTED); #endif } else if (latched_mods & modifiers[i].mask) { gtk_widget_set_sensitive(modifiers[i].indicator, TRUE); #if GTK_CHECK_VERSION (3, 0, 0) gtk_widget_set_state_flags (modifiers[i].indicator, GTK_STATE_FLAG_NORMAL, TRUE); #else gtk_widget_set_state(modifiers[i].indicator, GTK_STATE_NORMAL); #endif } else { gtk_widget_set_sensitive(modifiers[i].indicator, FALSE); } } } } if ((notify_type & ACCESSX_STATUS_SLOWKEYS) && (event != NULL)) { GdkPixbuf* pixbuf = accessx_status_applet_slowkeys_image(sapplet, &event->accessx); gtk_image_set_from_pixbuf(GTK_IMAGE(sapplet->slowfoo), pixbuf); g_object_unref(pixbuf); } if ((notify_type & ACCESSX_STATUS_BOUNCEKEYS) && (event != NULL)) { GdkPixbuf* pixbuf = accessx_status_applet_bouncekeys_image(sapplet, &event->accessx); gtk_image_set_from_pixbuf(GTK_IMAGE(sapplet->bouncefoo), pixbuf); g_object_unref(pixbuf); } if (notify_type & ACCESSX_STATUS_MOUSEKEYS) { GdkPixbuf* pixbuf = accessx_status_applet_mousekeys_image(sapplet, &event->state); gtk_image_set_from_pixbuf(GTK_IMAGE(sapplet->mousefoo), pixbuf); g_object_unref(pixbuf); } if (notify_type & ACCESSX_STATUS_ENABLED) { /* Update the visibility of widgets in the box */ /* XkbMouseKeysMask | XkbStickyKeysMask | XkbSlowKeysMask | XkbBounceKeysMask */ XkbGetControls(GDK_WINDOW_XDISPLAY(window), XkbAllControlsMask, sapplet->xkb); if (!(sapplet->xkb->ctrls->enabled_ctrls & (XkbMouseKeysMask | XkbStickyKeysMask | XkbSlowKeysMask | XkbBounceKeysMask))) { gtk_widget_show(sapplet->idlefoo); } else { gtk_widget_hide(sapplet->idlefoo); } if (sapplet->xkb->ctrls->enabled_ctrls & XkbMouseKeysMask) { gtk_widget_show(sapplet->mousefoo); } else { gtk_widget_hide(sapplet->mousefoo); } if (sapplet->xkb->ctrls->enabled_ctrls & XkbStickyKeysMask) { gtk_widget_show(sapplet->stickyfoo); } else { gtk_widget_hide(sapplet->stickyfoo); } if (sapplet->xkb->ctrls->enabled_ctrls & XkbSlowKeysMask) { gtk_widget_show(sapplet->slowfoo); } else { gtk_widget_hide(sapplet->slowfoo); } if (sapplet->xkb->ctrls->enabled_ctrls & XkbBounceKeysMask) { gtk_widget_show(sapplet->bouncefoo); } else { gtk_widget_hide(sapplet->bouncefoo); } } return; }
static GdkPixbuf* accessx_status_applet_slowkeys_image(AccessxStatusApplet* sapplet, XkbAccessXNotifyEvent* event) { GdkPixbuf* ret_pixbuf; GdkWindow* window; gboolean is_idle = TRUE; gchar* stock_id = SLOWKEYS_IDLE_ICON; GtkStyle* style = gtk_widget_get_style(GTK_WIDGET(sapplet->applet)); GdkColor bg = style->bg[GTK_STATE_NORMAL]; if (event != NULL) { is_idle = FALSE; switch (event->detail) { case XkbAXN_SKPress: stock_id = ACCESSX_BASE_ICON; if (_sk_timeout) { g_source_remove(_sk_timeout); _sk_timeout = 0; } break; case XkbAXN_SKAccept: stock_id = ACCESSX_ACCEPT_BASE; gdk_color_parse("#009900", &bg); break; case XkbAXN_SKReject: stock_id = ACCESSX_REJECT_BASE; gdk_color_parse("#990000", &bg); _sk_timeout = g_timeout_add_full(G_PRIORITY_HIGH_IDLE, MAX(event->sk_delay, 150), timer_reset_slowkeys_image, sapplet->slowfoo, NULL); break; case XkbAXN_SKRelease: default: stock_id = SLOWKEYS_IDLE_ICON; is_idle = TRUE; break; } } ret_pixbuf = gtk_widget_render_icon(GTK_WIDGET(sapplet->applet), stock_id, icon_size_spec, NULL); if (!is_idle) { GdkPixbuf* glyph_pixbuf; GdkPixbuf* tmp_pixbuf; GdkColor fg; gchar* glyphstring = N_("a"); tmp_pixbuf = ret_pixbuf; ret_pixbuf = gdk_pixbuf_copy(tmp_pixbuf); g_object_unref(tmp_pixbuf); window = gtk_widget_get_window(GTK_WIDGET(sapplet->applet)); if (event && window) { KeySym keysym = XKeycodeToKeysym(GDK_WINDOW_XDISPLAY(window), event->keycode, 0); glyphstring = XKeysymToString(keysym); if ((!g_utf8_validate(glyphstring, -1, NULL)) || (g_utf8_strlen(glyphstring, -1) > 1)) { glyphstring = ""; } } #if GTK_CHECK_VERSION (3, 0, 0) fg = style->fg[gtk_widget_get_state_flags (GTK_WIDGET (sapplet->applet))]; #else fg = style->fg[gtk_widget_get_state(GTK_WIDGET(sapplet->applet))]; #endif glyph_pixbuf = accessx_status_applet_get_glyph_pixbuf(sapplet, GTK_WIDGET(sapplet->applet), ret_pixbuf, &fg, &bg, glyphstring); gdk_pixbuf_composite(glyph_pixbuf, ret_pixbuf, 0, 0, gdk_pixbuf_get_width(glyph_pixbuf), gdk_pixbuf_get_height(glyph_pixbuf), 0., 0., 1.0, 1.0, GDK_INTERP_NEAREST, 255); g_object_unref(glyph_pixbuf); } return ret_pixbuf; }
GdkGrabStatus _gdk_windowing_pointer_grab (GdkWindow *window, GdkWindow *native, gboolean owner_events, GdkEventMask event_mask, GdkWindow *confine_to, GdkCursor *cursor, guint32 time) { gint return_val; GdkCursorPrivate *cursor_private; GdkDisplayX11 *display_x11; guint xevent_mask; Window xwindow; Window xconfine_to; Cursor xcursor; int i; if (confine_to) confine_to = _gdk_window_get_impl_window (confine_to); display_x11 = GDK_DISPLAY_X11 (GDK_WINDOW_DISPLAY (native)); cursor_private = (GdkCursorPrivate*) cursor; xwindow = GDK_WINDOW_XID (native); if (!confine_to || GDK_WINDOW_DESTROYED (confine_to)) xconfine_to = None; else xconfine_to = GDK_WINDOW_XID (confine_to); if (!cursor) xcursor = None; else { _gdk_x11_cursor_update_theme (cursor); xcursor = cursor_private->xcursor; } xevent_mask = 0; for (i = 0; i < _gdk_nenvent_masks; i++) { if (event_mask & (1 << (i + 1))) xevent_mask |= _gdk_event_mask_table[i]; } /* We don't want to set a native motion hint mask, as we're emulating motion * hints. If we set a native one we just wouldn't get any events. */ xevent_mask &= ~PointerMotionHintMask; return_val = _gdk_input_grab_pointer (window, native, owner_events, event_mask, confine_to, time); if (return_val == GrabSuccess || G_UNLIKELY (!display_x11->trusted_client && return_val == AlreadyGrabbed)) { if (!GDK_WINDOW_DESTROYED (native)) { #ifdef G_ENABLE_DEBUG if (_gdk_debug_flags & GDK_DEBUG_NOGRABS) return_val = GrabSuccess; else #endif return_val = XGrabPointer (GDK_WINDOW_XDISPLAY (native), xwindow, owner_events, xevent_mask, GrabModeAsync, GrabModeAsync, xconfine_to, xcursor, time); } else return_val = AlreadyGrabbed; } if (return_val == GrabSuccess) _gdk_x11_roundtrip_async (GDK_DISPLAY_OBJECT (display_x11), has_pointer_grab_callback, NULL); return gdk_x11_convert_grab_status (return_val); }
gint main (gint argc, gchar *argv[]) { Window root; //gettext bindtextdomain( "gamine", LOCALDIR ); textdomain( "gamine" ); gamine_t cb; GtkWidget *window; GdkWindow *gdkwindow; GtkWindow *gtkwindow; GdkScreen *screen; GdkPixbuf *cursor_pixbuf; GdkPixbuf *icon_pixbuf; GdkCursor *cursor; GdkColor bg_color; gchar *cursorfile; gchar *iconfile; cb.is_cairo = FALSE; gtk_init (&argc, &argv); gst_init (&argc, &argv); gconf_init(argc, argv, NULL); gst_play_background (cb.bus, "BachJSBrandenburgConcertNo2inFMajorBWV1047mvmt1.ogg", TRUE); window = gtk_window_new (GTK_WINDOW_TOPLEVEL); /* Create the drawing area and configuration */ cb.da = gtk_drawing_area_new (); bg_color.red = 65535; bg_color.green = 65535; bg_color.blue = 65535; gtk_widget_modify_bg (cb.da, GTK_STATE_NORMAL, &bg_color); gtk_container_add (GTK_CONTAINER (window), cb.da); cb.gc = gconf_client_get_default(); gtkwindow = GTK_WINDOW(window); gtk_window_set_title (gtkwindow, "Gamine"); gtk_window_set_wmclass(gtkwindow, "gamine", "Gamine"); gtk_container_set_border_width (GTK_CONTAINER (gtkwindow), 0); /* Event signals */ g_signal_connect (gtkwindow, "destroy", G_CALLBACK (gtk_main_quit), >kwindow); g_signal_connect (G_OBJECT (cb.da), "expose-event", G_CALLBACK (display_help), &cb); g_signal_connect (cb.da, "motion_notify_event", G_CALLBACK (draw_line), &cb); g_signal_connect (cb.da, "button_press_event", G_CALLBACK (draw_star), &cb); g_signal_connect (gtkwindow, "key-press-event", G_CALLBACK (gamine_on_key), &cb); gtk_widget_set_events (cb.da, gtk_widget_get_events (cb.da) | GDK_LEAVE_NOTIFY_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK); /* Set fullscreen, grab mouse/keyboard, ...*/ gtk_widget_show_all (GTK_WIDGET(gtkwindow)); gdkwindow = GDK_WINDOW(GTK_WIDGET(gtkwindow)->window); screen = gtk_widget_get_screen (cb.da); gtk_window_present (gtkwindow); gtk_window_stick(gtkwindow); //gtk_window_set_keep_above (gtkwindow), True); //gtk_window_set_transient_for (gtkwindow, NULL); //set fullscreen gdk_window_fullscreen (gdkwindow); gtk_window_fullscreen (gtkwindow); gdk_window_raise (gdkwindow); //set full screen without window manager XMoveResizeWindow(GDK_WINDOW_XDISPLAY(gdkwindow), GDK_WINDOW_XID(gdkwindow), 0, 0, gdk_screen_get_width (screen), gdk_screen_get_height (screen)); root = DefaultRootWindow(GDK_WINDOW_XDISPLAY (gdkwindow)); XGrabPointer(GDK_WINDOW_XDISPLAY (gdkwindow), root, True, PointerMotionMask, GrabModeAsync, GrabModeAsync, root, None, CurrentTime); XGrabKeyboard(GDK_WINDOW_XDISPLAY (gdkwindow), root, True, GrabModeAsync, GrabModeAsync, CurrentTime); //remove keyboard repeat XAutoRepeatOff(GDK_WINDOW_XDISPLAY (gdkwindow)); gtk_window_has_toplevel_focus (gtkwindow); /*cursor*/ cursorfile = g_build_filename(DATADIR, "pencil.png", NULL); if (!g_file_test (cursorfile, G_FILE_TEST_EXISTS)) { printf(gettext("*** error: %s does not exists***\n"), cursorfile); } else { cursor_pixbuf = gdk_pixbuf_new_from_file(cursorfile, NULL); cursor = gdk_cursor_new_from_pixbuf(gdk_display_get_default(), cursor_pixbuf, 0, 38); gdk_window_set_cursor(gdkwindow, cursor); gdk_cursor_unref(cursor); gdk_pixbuf_unref(cursor_pixbuf); } g_free(cursorfile); /*Set icon*/ iconfile = g_build_filename(DATADIR, "gamine.png", NULL); if (!g_file_test (iconfile, G_FILE_TEST_EXISTS)) printf(gettext("*** error: %s does not exists***\n"), iconfile); else { icon_pixbuf = gdk_pixbuf_new_from_file(iconfile, NULL); gtk_window_set_icon (gtkwindow, icon_pixbuf); gdk_pixbuf_unref (icon_pixbuf); } g_free(iconfile); load_conf(&cb); gtk_main (); //set keyboard repeat XAutoRepeatOn(GDK_WINDOW_XDISPLAY (gdkwindow)); XCloseDisplay(GDK_WINDOW_XDISPLAY (gdkwindow)); return 0; }
void wxOgre::createOgreRenderWindow() { // See if an Ogre::Root already exists mRoot = Ogre::Root::getSingletonPtr(); mRenderWindow = mRoot->initialise(false); // -------------------- // Create a new parameters list according to compiled OS Ogre::NameValuePairList params; Ogre::String handle; #ifdef __WXMSW__ handle = Ogre::StringConverter::toString((size_t)((HWND)GetHandle())); params["externalWindowHandle"] = handle; #elif defined(__WXGTK__) SetBackgroundStyle(wxBG_STYLE_CUSTOM); GtkWidget* privHandle = GetHandle(); // prevents flickering gtk_widget_set_double_buffered(privHandle, FALSE); // this doesn't work w. Ogre 1.6.1 maybe this will fix it? gtk_widget_realize(privHandle); // grab the window object GdkWindow* gdkWin = GTK_PIZZA(privHandle)->bin_window; Display* display = GDK_WINDOW_XDISPLAY(gdkWin); Window wid = GDK_WINDOW_XWINDOW(gdkWin); XSync(display,wid); std::stringstream str; // display str << (unsigned long)display << ':'; // screen (returns "display.screen") std::string screenStr = DisplayString(display); std::string::size_type dotPos = screenStr.find("."); screenStr = screenStr.substr(dotPos+1, screenStr.size()); str << screenStr << ':'; // XID str << wid << ':'; // retrieve XVisualInfo int attrlist[] = { GLX_RGBA, GLX_DOUBLEBUFFER, GLX_DEPTH_SIZE, 16, GLX_STENCIL_SIZE, 8, None }; XVisualInfo* vi = glXChooseVisual(display, DefaultScreen(display), attrlist); str << (unsigned long)vi; handle = str.str(); #else #error Not supported on this platform. #endif // Get wx control window size int width; int height; GetSize(&width, &height); // Create the render window mRenderWindow = Ogre::Root::getSingleton().createRenderWindow("OgreRenderWindow", width, height, false, ¶ms); // line is required, otherwise the screen does not update mRenderWindow->setActive(true); // -------------------- // Create the SceneManager, in this case a generic one mSceneMgr = mRoot->createSceneManager(Ogre::ST_GENERIC, "ExampleSMInstance"); mSceneMgr->setAmbientLight(Ogre::ColourValue(0.5f, 0.5f, 0.5f)); // -------------------- // Create the camera mCamera = mSceneMgr->createCamera("EntityCamera"); // Set up the SceneNodes to control the camera mCameraNode = mSceneMgr->getRootSceneNode()->createChildSceneNode(); mCameraNode->attachObject(mCamera); mCamera->setNearClipDistance(0.1); // Set the viewport mViewPort = mRenderWindow->addViewport(mCamera); // Set the background to match the wxWindow background color mViewPort->setBackgroundColour(Ogre::ColourValue(212.0f/255.0f, 208.0f/255.0f, 200.0f/255.0f, 1.0f)); //mLightNode = mCameraNode->createChildSceneNode(); mXLight = mSceneMgr->createLight("XLight"); mXLight->setType(Ogre::Light::LT_DIRECTIONAL); mXLight->setDiffuseColour(1.0f, 1.0f,1.0f); mXLight->setDirection(-1.0f, 0.0f, 0.0f); mYLight = mSceneMgr->createLight("YLight"); mYLight->setType(Ogre::Light::LT_DIRECTIONAL); mYLight->setDiffuseColour(1.0f, 1.0f,1.0f); mYLight->setDirection(0.0f, -1.0f, 0.0f); mZLight = mSceneMgr->createLight("ZLight"); mZLight->setType(Ogre::Light::LT_DIRECTIONAL); mZLight->setDiffuseColour(1.0f, 1.0f,1.0f); mZLight->setDirection(0.0f, 0.0f, -1.0f); }
nsresult nsPluginNativeWindowGtk::CreateXEmbedWindow(bool aEnableXtFocus) { NS_ASSERTION(!mSocketWidget,"Already created a socket widget!"); GdkDisplay *display = gdk_display_get_default(); GdkWindow *parent_win = gdk_x11_window_lookup_for_display(display, GetWindow()); mSocketWidget = gtk_socket_new(); //attach the socket to the container widget gtk_widget_set_parent_window(mSocketWidget, parent_win); // enable/disable focus event handlers, // see plugin_window_filter_func() for details g_object_set_data(G_OBJECT(mSocketWidget), "enable-xt-focus", (void *)aEnableXtFocus); // 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), nullptr); g_signal_connect(mSocketWidget, "unrealize", G_CALLBACK(socket_unrealize_cb), nullptr); g_signal_connect(mSocketWidget, "destroy", G_CALLBACK(gtk_widget_destroyed), &mSocketWidget); gpointer user_data = nullptr; 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. // TODO GTK3 #if (MOZ_WIDGET_GTK == 2) gdk_window_set_back_pixmap(gtk_widget_get_window(mSocketWidget), nullptr, FALSE); #endif // Resize before we show SetAllocation(); gtk_widget_show(mSocketWidget); gdk_flush(); SetWindow(gtk_socket_get_id(GTK_SOCKET(mSocketWidget))); // Fill out the ws_info structure. // (The windowless case is done in nsPluginFrame.cpp.) GdkWindow *gdkWindow = gdk_x11_window_lookup_for_display(display, GetWindow()); if(!gdkWindow) return NS_ERROR_FAILURE; mWsInfo.display = GDK_WINDOW_XDISPLAY(gdkWindow); #if (MOZ_WIDGET_GTK == 2) mWsInfo.colormap = GDK_COLORMAP_XCOLORMAP(gdk_drawable_get_colormap(gdkWindow)); GdkVisual* gdkVisual = gdk_drawable_get_visual(gdkWindow); mWsInfo.depth = gdkVisual->depth; #else mWsInfo.colormap = None; GdkVisual* gdkVisual = gdk_window_get_visual(gdkWindow); mWsInfo.depth = gdk_visual_get_depth(gdkVisual); #endif mWsInfo.visual = GDK_VISUAL_XVISUAL(gdkVisual); return NS_OK; }
void my_gdk_draw_text(GdkDrawable *drawable, GdkFont *font, GdkGC *gc, gint x, gint y, const gchar *text, gint text_length) { #ifdef MOZ_WIDGET_GTK GdkWindowPrivate *drawable_private; GdkFontPrivate *font_private; GdkGCPrivate *gc_private; #endif /* MOZ_WIDGET_GTK */ g_return_if_fail (drawable != NULL); g_return_if_fail (font != NULL); g_return_if_fail (gc != NULL); g_return_if_fail (text != NULL); #ifdef MOZ_WIDGET_GTK drawable_private = (GdkWindowPrivate*) drawable; if (drawable_private->destroyed) return; gc_private = (GdkGCPrivate*) gc; font_private = (GdkFontPrivate*) font; #endif /* MOZ_WIDGET_GTK */ #ifdef MOZ_WIDGET_GTK2 if (GDK_IS_WINDOW(drawable) && GDK_WINDOW_OBJECT(drawable)->destroyed) return; #endif /* MOZ_WIDGET_GTK2 */ if (font->type == GDK_FONT_FONT) { #ifdef MOZ_WIDGET_GTK XFontStruct *xfont = (XFontStruct *) font_private->xfont; #endif /* MOZ_WIDGET_GTK */ #ifdef MOZ_WIDGET_GTK2 XFontStruct *xfont = (XFontStruct *) GDK_FONT_XFONT(font); #endif /* MOZ_WIDGET_GTK2 */ // gdk does this... we don't need it.. // XSetFont(drawable_private->xdisplay, gc_private->xgc, xfont->fid); // We clamp the sizes down to 32768 which is the maximum width of // a window. Even if a font was 1 pixel high and started at the // left, the maximum size of a draw request could only be 32k. if ((xfont->min_byte1 == 0) && (xfont->max_byte1 == 0)) { #ifdef MOZ_WIDGET_GTK XDrawString (drawable_private->xdisplay, drawable_private->xwindow, gc_private->xgc, x, y, text, MIN(text_length, 32768)); #endif /* MOZ_WIDGET_GTK */ #ifdef MOZ_WIDGET_GTK2 XDrawString (GDK_WINDOW_XDISPLAY(drawable), GDK_DRAWABLE_XID(drawable), GDK_GC_XGC(gc), x, y, text, MIN(text_length, 32768)); #endif /* MOZ_WIDGET_GTK2 */ } else { #ifdef MOZ_WIDGET_GTK XDrawString16 (drawable_private->xdisplay, drawable_private->xwindow, gc_private->xgc, x, y, (XChar2b *) text, MIN((text_length / 2), 32768)); #endif /* MOZ_WIDGET_GTK */ #ifdef MOZ_WIDGET_GTK2 XDrawString16 (GDK_WINDOW_XDISPLAY(drawable), GDK_DRAWABLE_XID(drawable), GDK_GC_XGC(gc), x, y, (XChar2b *) text, MIN((text_length / 2), 32768)); #endif /* MOZ_WIDGET_GTK2 */ } } else if (font->type == GDK_FONT_FONTSET) { #ifdef MOZ_WIDGET_GTK XFontSet fontset = (XFontSet) font_private->xfont; XmbDrawString (drawable_private->xdisplay, drawable_private->xwindow, fontset, gc_private->xgc, x, y, text, text_length); #endif /* MOZ_WIDGET_GTK */ #ifdef MOZ_WIDGET_GTK2 XFontSet fontset = (XFontSet) GDK_FONT_XFONT(font); XmbDrawString (GDK_WINDOW_XDISPLAY(drawable), GDK_DRAWABLE_XID(drawable), fontset, GDK_GC_XGC(gc), x, y, text, text_length); #endif /* MOZ_WIDGET_GTK2 */ } else g_error("undefined font type\n"); }