/* from GtkMenu sources */
static GdkWindow *menu_grab_transfer_window_get (MenuStart *menu)
{
	GdkWindow *window = g_object_get_data
		(G_OBJECT (menu), "gtk-menu-transfer-window");

	if (!window) {
		GdkWindowAttr attributes;
		gint attributes_mask;

		attributes.x = -100;
		attributes.y = -100;
		attributes.width = 10;
		attributes.height = 10;
		attributes.window_type = GDK_WINDOW_TEMP;
		attributes.wclass = GDK_INPUT_ONLY;
		attributes.override_redirect = TRUE;
		attributes.event_mask = 0;

		attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_NOREDIR;

		window = gdk_window_new (gtk_widget_get_root_window
					 (GTK_WIDGET (menu)), &attributes,
					 attributes_mask);
		gdk_window_set_user_data (window, menu);

		gdk_window_show (window);

		g_object_set_data
			(G_OBJECT (menu), "gtk-menu-transfer-window", window);
	}

	return window;
}
Exemple #2
0
/* -----------------------------------------------------------------------------
 * Initialize the drawing structures
 */
void viewInitialize(GtkWidget* parent)
{
	g_message("in viewInitialize");
	GdkWindow* window = gtk_widget_get_root_window(parent);
	int j, k;
	for (j=0; j<13; j++)
	{
		for (k=0; k<3; k++)
		{
		  gc[j][k] = gdk_gc_new(window);
		  gdk_gc_set_rgb_fg_color(gc[j][k], &color[j][k]);
			
		}
	}
	lightGreyGC = gdk_gc_new(window);
	gdk_gc_set_rgb_fg_color(lightGreyGC, &lightGrey);
	gdk_gc_set_line_attributes(lightGreyGC,
                               2, /* line_width, */
                               GDK_LINE_SOLID,
                               GDK_CAP_BUTT,
                               GDK_JOIN_MITER);
	darkGreyGC = gdk_gc_new(window);
	gdk_gc_set_rgb_fg_color(darkGreyGC, &darkGrey);
	gdk_gc_set_line_attributes(darkGreyGC,
                               1, /* line_width, */
                               GDK_LINE_SOLID,
                               GDK_CAP_BUTT,
                               GDK_JOIN_MITER);
	backgrounds = gdk_pixmap_create_from_xpm(window,
                                             NULL,
                                             NULL,
                                             "screens.xpm");
}
/* Replace a property on the root window. */
static void change_root_property(GtkWidget* w, const char* prop_name, const char* value)
{
    GdkDisplay* dpy = gtk_widget_get_display(w);
    GdkWindow* root = gtk_widget_get_root_window(w);
    XChangeProperty(GDK_DISPLAY_XDISPLAY(dpy), GDK_WINDOW_XID(root),
                      XInternAtom(GDK_DISPLAY_XDISPLAY(dpy), prop_name, False), XA_STRING, 8,
                      PropModeReplace, (unsigned char*) value, strlen(value) + 1);
}
Exemple #4
0
/* 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);
    }
}
Exemple #5
0
void aquire_hotkey(const char* widget_name,
		   PrefsData *data) {
  gint resp, action;
  GtkWidget  *diag = data->hotkey_dialog;

  action = 
    (!strcmp(widget_name,"mute_eventbox"))?
    0:
    (!strcmp(widget_name,"up_eventbox"))?
    1:
    (!strcmp(widget_name,"down_eventbox"))?
    2:-1;

  if (action < 0) {
    report_error("Invalid widget passed to aquire_hotkey: %s",widget_name);
    return;
  }

  switch(action) {
  case 0:
    gtk_label_set_text(GTK_LABEL(data->hotkey_key_label),_("Mute/Unmute"));
    break;
  case 1:
    gtk_label_set_text(GTK_LABEL(data->hotkey_key_label),_("Volume Up"));
    break;
  case 2:
    gtk_label_set_text(GTK_LABEL(data->hotkey_key_label),_("Volume Down"));
    break;
  default:
    break;
  }

  // grab keyboard
  if (G_LIKELY(gdk_keyboard_grab(gtk_widget_get_root_window(GTK_WIDGET(diag)), TRUE, GDK_CURRENT_TIME) == GDK_GRAB_SUCCESS)) {
    resp = gtk_dialog_run(GTK_DIALOG(diag));
    gdk_keyboard_ungrab (GDK_CURRENT_TIME);
    if (resp == GTK_RESPONSE_OK) {
      const gchar* key_name = gtk_label_get_text(GTK_LABEL(data->hotkey_key_label));
      switch(action) {
      case 0:
	gtk_label_set_text(GTK_LABEL(data->mute_hotkey_label),key_name);
	break;
      case 1:
	gtk_label_set_text(GTK_LABEL(data->up_hotkey_label),key_name);
	break;
      case 2:
	gtk_label_set_text(GTK_LABEL(data->down_hotkey_label),key_name);
	break;
      default:
	break;
      }
    }
  }
  else
    report_error("%s", _("Could not grab the keyboard."));
  gtk_widget_hide(diag);
}
GdkPixmap *make_pixmap(GtkScrollbox *self, gchar *value)
{
        GdkWindow *rootwin;
        PangoLayout *pl;
        gint width, height, middle;
        GdkPixmap *pixmap;
        GtkRequisition widgsize = {0, }; 
        GtkWidget *widget = (GtkWidget *)self;
        

	/* If we can't draw yet, don't do anything to avoid screwing things */
	if (!GDK_IS_GC(widget->style->bg_gc[0]))
		return NULL;

        rootwin = gtk_widget_get_root_window(widget);

        pl = gtk_widget_create_pango_layout(widget, NULL);
        pango_layout_set_markup(pl, value, -1);

        pango_layout_get_pixel_size(pl, &width, &height);

        pixmap = gdk_pixmap_new(GDK_DRAWABLE(rootwin), width, height, -1);

        gdk_draw_rectangle(GDK_DRAWABLE(pixmap), 
                        widget->style->bg_gc[0],
                        TRUE, 0, 0, width, height);

        gdk_draw_layout(GDK_DRAWABLE(pixmap), widget->style->fg_gc[0], 0, 0, pl);

        g_object_unref(pl);

        gtk_widget_size_request(widget, &widgsize);

        if (width <= widgsize.width)
                width = widgsize.width;

        if (height <= widgsize.height)
                height = widgsize.height;
        else
                self->draw_maxoffset = -height;

        if (width != widgsize.width || height != widgsize.height)
                gtk_widget_set_size_request(widget, width, height);

        middle = width / 2;
        if (self->draw_maxmiddle < middle)
                self->draw_maxmiddle = middle;

        return pixmap;
}
Exemple #7
0
static gboolean
on_motion_notify (GtkWidget* dropzone,
				  GdkEventMotion *event,
				  gpointer user_data)
{

	gint curx, cury;
	GdkModifierType state;

	gdk_window_get_device_position (gtk_widget_get_root_window(dropzone),
									event->device, &curx, &cury, &state);

	if (state & GDK_BUTTON1_MASK) {
		gtk_window_move (GTK_WINDOW(dropzone), curx - prevx, cury- prevy);
	}

	return TRUE;
}
Exemple #8
0
static int setup_fonts(void)
{
  int width, height;
  GdkDrawable *drawable=GDK_DRAWABLE(gtk_widget_get_root_window(GTK_WIDGET(GLOBALS->mainwindow)));
  GdkScreen *fonts_screen = gdk_drawable_get_screen (drawable);
  GLOBALS->fonts_renderer = gdk_pango_renderer_get_default (fonts_screen);
  gdk_pango_renderer_set_drawable (GDK_PANGO_RENDERER (GLOBALS->fonts_renderer), drawable);

  GLOBALS->fonts_gc = gdk_gc_new (drawable);
  gdk_pango_renderer_set_gc (GDK_PANGO_RENDERER (GLOBALS->fonts_renderer), GLOBALS->fonts_gc);

  gdk_drawable_get_size (drawable, &width, &height);

  GLOBALS->fonts_context = gdk_pango_context_get_for_screen (fonts_screen);
  GLOBALS->fonts_layout = pango_layout_new (GLOBALS->fonts_context);

  return 0;
}
FloatRect screenAvailableRect(Widget* widget)
{
    if (!widget)
        return FloatRect();

#if PLATFORM(X11)
    GtkWidget* container = GTK_WIDGET(widget->root()->hostWindow()->platformPageClient());
    if (!container)
        return FloatRect();

    if (!gtk_widget_get_realized(container))
        return screenRect(widget);

    GdkDrawable* rootWindow = GDK_DRAWABLE(gtk_widget_get_root_window(container));
    GdkDisplay* display = gdk_drawable_get_display(rootWindow);
    Atom xproperty = gdk_x11_get_xatom_by_name_for_display(display, "_NET_WORKAREA");

    Atom retType;
    int retFormat;
    long *workAreaPos = NULL;
    unsigned long retNItems;
    unsigned long retAfter;
    int xRes = XGetWindowProperty(GDK_DISPLAY_XDISPLAY(display), GDK_WINDOW_XWINDOW(rootWindow), xproperty,
        0, 4, FALSE, XA_CARDINAL, &retType, &retFormat, &retNItems, &retAfter, (guchar**)&workAreaPos);

    FloatRect rect;
    if (xRes == Success && workAreaPos != NULL && retType == XA_CARDINAL && retNItems == 4 && retFormat == 32) {
        rect = FloatRect(workAreaPos[0], workAreaPos[1], workAreaPos[2], workAreaPos[3]);
        // rect contains the available space in the whole screen not just in the monitor
        // containing the widget, so we intersect it with the monitor rectangle.
        rect.intersect(screenRect(widget));
    } else
        rect = screenRect(widget);

    if (workAreaPos)
        XFree(workAreaPos);

    return rect;
#else
    return screenRect(widget);
#endif
}
Exemple #10
0
static void ygtk_popup_window_frame_position (GtkWidget *widget, gint *x,  gint *y)
{	// don't let it go outside the screen
	GtkRequisition req;
	gtk_widget_get_preferred_size(widget, &req, NULL);

	GdkScreen *screen = gtk_widget_get_screen (widget);
	gint monitor_num = gdk_screen_get_monitor_at_window (screen, gtk_widget_get_root_window (widget));
	GdkRectangle monitor;
	gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);

	if (*x < monitor.x)
		*x = monitor.x;
	else if (*x + req.width > monitor.x + monitor.width)
		*x = monitor.x + monitor.width - req.width;

	if (*y < monitor.y)
		*y = monitor.y;
	else if (*y + req.height > monitor.y + monitor.height)
		*y = monitor.y + monitor.height - req.height;
}
Exemple #11
0
  bool show(Display* parent) override {
    static std::string s_lastUsedDir;
    if (s_lastUsedDir.empty())
      s_lastUsedDir = g_get_user_special_dir(G_USER_DIRECTORY_DESKTOP);

    const char* okLabel;
    GtkFileChooserAction action;

    switch (m_type) {
      case Type::OpenFile:
      case Type::OpenFiles:
        action = GTK_FILE_CHOOSER_ACTION_OPEN;
        okLabel = "_Open";
        break;
      case Type::OpenFolder:
        action = GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER;
        okLabel = "_Open Folder";
        break;
      case Type::SaveFile:
        action = GTK_FILE_CHOOSER_ACTION_SAVE;
        okLabel = "_Save";
        break;
    }

    // GtkWindow* gtkParent = nullptr;
    GtkWidget* dialog = gtk_file_chooser_dialog_new(
      m_title.c_str(),
      nullptr,
      action,
      "_Cancel", GTK_RESPONSE_CANCEL,
      okLabel, GTK_RESPONSE_ACCEPT,
      nullptr);

    gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_OK);

    GtkFileChooser* chooser = GTK_FILE_CHOOSER(dialog);
    m_chooser = chooser;

    if (m_type == Type::SaveFile)
      gtk_file_chooser_set_do_overwrite_confirmation(chooser, TRUE);
    else if (m_type == Type::OpenFiles)
      gtk_file_chooser_set_select_multiple(chooser, true);

    if (m_type != Type::OpenFolder) {
      setupFilters(base::get_file_extension(m_filename));
      setupPreview();
    }

    if (m_initialDir.empty())
      gtk_file_chooser_set_current_folder(chooser, s_lastUsedDir.c_str());
    else
      gtk_file_chooser_set_current_folder(chooser, m_initialDir.c_str());

    if (!m_filename.empty()) {
      std::string fn = m_filename;
      // Add default extension
      if (m_type == Type::SaveFile && base::get_file_extension(fn).empty()) {
        fn.push_back('.');
        fn += m_defExtension;
      }
      gtk_file_chooser_set_current_name(chooser, fn.c_str());
    }

    // Setup the "parent" display as the parent of the dialog (we've
    // to convert a X11 Window into a GdkWindow to do this).
    GdkWindow* gdkParentWindow = nullptr;
    if (parent) {
      GdkWindow* gdkWindow = gtk_widget_get_root_window(dialog);

      gdkParentWindow =
        gdk_x11_window_foreign_new_for_display(
          gdk_window_get_display(gdkWindow),
          (::Window)parent->nativeHandle());

      gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_CENTER_ON_PARENT);
      gdk_window_set_transient_for(gdkWindow, gdkParentWindow);
    }
    else {
      gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_CENTER);
    }

    // Show the dialog
    gint res = gtk_dialog_run(GTK_DIALOG(dialog));
    if (res == GTK_RESPONSE_ACCEPT) {
      s_lastUsedDir = gtk_file_chooser_get_current_folder(chooser);
      m_filename = gtk_file_chooser_get_filename(chooser);

      if (m_type == Type::OpenFiles) {
        GSList* list = gtk_file_chooser_get_filenames(chooser);
        g_slist_foreach(
          list,
          [](void* fn, void* userdata){
            auto self = (FileDialogGTK*)userdata;
            self->m_filenames.push_back((char*)fn);
            g_free(fn);
          }, this);
        g_slist_free(list);
      }
    }

    gtk_widget_destroy(dialog);
    if (gdkParentWindow)
      g_object_unref(gdkParentWindow);

    // Pump gtk+ events to finally hide the dialog from the screen
    while (gtk_events_pending())
      gtk_main_iteration();

    return (res == GTK_RESPONSE_ACCEPT);
  }
Exemple #12
0
static void
gtk_mirror_bin_realize (GtkWidget *widget)
{
  GtkMirrorBin *bin = GTK_MIRROR_BIN (widget);
  GdkWindowAttr attributes;
  gint attributes_mask;
  gint border_width;
  GtkRequisition child_requisition;

  gtk_widget_set_realized (widget, TRUE);

  border_width = GTK_CONTAINER (widget)->border_width;

  attributes.x = widget->allocation.x + border_width;
  attributes.y = widget->allocation.y + border_width;
  attributes.width = widget->allocation.width - 2 * border_width;
  attributes.height = widget->allocation.height - 2 * border_width;
  attributes.window_type = GDK_WINDOW_CHILD;
  attributes.event_mask = gtk_widget_get_events (widget)
                        | GDK_EXPOSURE_MASK
                        | GDK_POINTER_MOTION_MASK
                        | GDK_BUTTON_PRESS_MASK
                        | GDK_BUTTON_RELEASE_MASK
                        | GDK_SCROLL_MASK
                        | GDK_ENTER_NOTIFY_MASK
                        | GDK_LEAVE_NOTIFY_MASK;

  attributes.visual = gtk_widget_get_visual (widget);
  attributes.colormap = gtk_widget_get_colormap (widget);
  attributes.wclass = GDK_INPUT_OUTPUT;

  attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;

  widget->window = gdk_window_new (gtk_widget_get_parent_window (widget),
                                   &attributes, attributes_mask);
  gdk_window_set_user_data (widget->window, widget);
  g_signal_connect (widget->window, "pick-embedded-child",
                    G_CALLBACK (pick_offscreen_child), bin);

  attributes.window_type = GDK_WINDOW_OFFSCREEN;

  child_requisition.width = child_requisition.height = 0;
  if (bin->child && gtk_widget_get_visible (bin->child))
    {
      attributes.width = bin->child->allocation.width;
      attributes.height = bin->child->allocation.height;
    }
  bin->offscreen_window = gdk_window_new (gtk_widget_get_root_window (widget),
                                          &attributes, attributes_mask);
  gdk_window_set_user_data (bin->offscreen_window, widget);
  if (bin->child)
    gtk_widget_set_parent_window (bin->child, bin->offscreen_window);
  gdk_offscreen_window_set_embedder (bin->offscreen_window, widget->window);
  g_signal_connect (bin->offscreen_window, "to-embedder",
                    G_CALLBACK (offscreen_window_to_parent), bin);
  g_signal_connect (bin->offscreen_window, "from-embedder",
                    G_CALLBACK (offscreen_window_from_parent), bin);

  widget->style = gtk_style_attach (widget->style, widget->window);

  gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL);
  gtk_style_set_background (widget->style, bin->offscreen_window, GTK_STATE_NORMAL);
  gdk_window_show (bin->offscreen_window);
}
Exemple #13
0
bool wxTopLevelWindowGTK::ShowFullScreen(bool show, long)
{
    if (show == m_fsIsShowing)
        return false; // return what?

    m_fsIsShowing = show;

#ifdef GDK_WINDOWING_X11
    Display* xdpy = GDK_DISPLAY_XDISPLAY(gtk_widget_get_display(m_widget));
    Window xroot = GDK_WINDOW_XID(gtk_widget_get_root_window(m_widget));
    wxX11FullScreenMethod method = wxGetFullScreenMethodX11(xdpy, (WXWindow)xroot);

    // NB: gtk_window_fullscreen() uses freedesktop.org's WMspec extensions
    //     to switch to fullscreen, which is not always available. We must
    //     check if WM supports the spec and use legacy methods if it
    //     doesn't.
    if ( method == wxX11_FS_WMSPEC )
#endif // GDK_WINDOWING_X11
    {
        if (show)
            gtk_window_fullscreen( GTK_WINDOW( m_widget ) );
        else
            gtk_window_unfullscreen( GTK_WINDOW( m_widget ) );
    }
#ifdef GDK_WINDOWING_X11
    else
    {
        GdkWindow* window = gtk_widget_get_window(m_widget);
        Window xid = GDK_WINDOW_XID(window);

        if (show)
        {
            GetPosition( &m_fsSaveFrame.x, &m_fsSaveFrame.y );
            GetSize( &m_fsSaveFrame.width, &m_fsSaveFrame.height );

            GdkScreen* screen = gtk_widget_get_screen(m_widget);
            const int screen_width = gdk_screen_get_width(screen);
            const int screen_height = gdk_screen_get_height(screen);

            gint client_x, client_y, root_x, root_y;
            gint width, height;

            m_fsSaveGdkFunc = m_gdkFunc;
            m_fsSaveGdkDecor = m_gdkDecor;
            m_gdkFunc = m_gdkDecor = 0;
            gdk_window_set_decorations(window, (GdkWMDecoration)0);
            gdk_window_set_functions(window, (GdkWMFunction)0);

            gdk_window_get_origin(window, &root_x, &root_y);
            gdk_window_get_geometry(window, &client_x, &client_y, &width, &height);

            gdk_window_move_resize(
                window, -client_x, -client_y, screen_width + 1, screen_height + 1);

            wxSetFullScreenStateX11(xdpy,
                                    (WXWindow)xroot,
                                    (WXWindow)xid,
                                    show, &m_fsSaveFrame, method);
        }
        else // hide
        {
            m_gdkFunc = m_fsSaveGdkFunc;
            m_gdkDecor = m_fsSaveGdkDecor;
            gdk_window_set_decorations(window, (GdkWMDecoration)m_gdkDecor);
            gdk_window_set_functions(window, (GdkWMFunction)m_gdkFunc);

            wxSetFullScreenStateX11(xdpy,
                                    (WXWindow)xroot,
                                    (WXWindow)xid,
                                    show, &m_fsSaveFrame, method);

            SetSize(m_fsSaveFrame.x, m_fsSaveFrame.y,
                    m_fsSaveFrame.width, m_fsSaveFrame.height);
        }
    }
#endif // GDK_WINDOWING_X11

    // documented behaviour is to show the window if it's still hidden when
    // showing it full screen
    if (show)
        Show();

    return true;
}
Exemple #14
0
void
gimp_overlay_child_realize (GimpOverlayBox   *box,
                            GimpOverlayChild *child)
{
  GtkWidget     *widget;
  GdkDisplay    *display;
  GdkScreen     *screen;
  GdkColormap   *colormap;
  GtkAllocation  child_allocation;
  GdkWindowAttr  attributes;
  gint           attributes_mask;

  g_return_if_fail (GIMP_IS_OVERLAY_BOX (box));
  g_return_if_fail (child != NULL);

  widget = GTK_WIDGET (box);

  display = gtk_widget_get_display (widget);
  screen  = gtk_widget_get_screen (widget);

  colormap = gdk_screen_get_rgba_colormap (screen);
  if (colormap)
    gtk_widget_set_colormap (child->widget, colormap);

  gtk_widget_get_allocation (child->widget, &child_allocation);

  if (gtk_widget_get_visible (child->widget))
    {
      attributes.width  = child_allocation.width;
      attributes.height = child_allocation.height;
    }
  else
    {
      attributes.width  = 1;
      attributes.height = 1;
    }

  attributes.x           = child_allocation.x;
  attributes.y           = child_allocation.y;
  attributes.window_type = GDK_WINDOW_OFFSCREEN;
  attributes.wclass      = GDK_INPUT_OUTPUT;
  attributes.visual      = gtk_widget_get_visual (child->widget);
  attributes.colormap    = gtk_widget_get_colormap (child->widget);
  attributes.event_mask  = GDK_EXPOSURE_MASK;
  attributes.cursor      = gdk_cursor_new_for_display (display, GDK_LEFT_PTR);

  attributes_mask = (GDK_WA_X        |
                     GDK_WA_Y        |
                     GDK_WA_VISUAL   |
                     GDK_WA_COLORMAP |
                     GDK_WA_CURSOR);

  child->window = gdk_window_new (gtk_widget_get_root_window (widget),
                                  &attributes, attributes_mask);
  gdk_window_set_user_data (child->window, widget);
  gtk_widget_set_parent_window (child->widget, child->window);
  gdk_offscreen_window_set_embedder (child->window,
                                     gtk_widget_get_window (widget));

  gdk_cursor_unref (attributes.cursor);

  g_signal_connect (child->window, "from-embedder",
                    G_CALLBACK (gimp_overlay_child_from_embedder),
                    child);
  g_signal_connect (child->window, "to-embedder",
                    G_CALLBACK (gimp_overlay_child_to_embedder),
                    child);

  gtk_style_set_background (gtk_widget_get_style (widget),
                            child->window, GTK_STATE_NORMAL);
  gdk_window_show (child->window);
}
Exemple #15
0
static VALUE
rg_root_window(VALUE self)
{
    return GOBJ2RVAL(gtk_widget_get_root_window(_SELF(self)));
}
Exemple #16
0
static void
gtk_offscreen_box_realize (GtkWidget *widget)
{
  GtkOffscreenBox *offscreen_box = GTK_OFFSCREEN_BOX (widget);
  GdkWindowAttr attributes;
  gint attributes_mask;
  gint border_width;
  GtkRequisition child_requisition;
  int start_y = 0;

  gtk_widget_set_realized (widget, TRUE);

  border_width = GTK_CONTAINER (widget)->border_width;

  attributes.x = widget->allocation.x + border_width;
  attributes.y = widget->allocation.y + border_width;
  attributes.width = widget->allocation.width - 2 * border_width;
  attributes.height = widget->allocation.height - 2 * border_width;
  attributes.window_type = GDK_WINDOW_CHILD;
  attributes.event_mask = gtk_widget_get_events (widget)
			| GDK_EXPOSURE_MASK
			| GDK_POINTER_MOTION_MASK
			| GDK_BUTTON_PRESS_MASK
			| GDK_BUTTON_RELEASE_MASK
			| GDK_SCROLL_MASK
			| GDK_ENTER_NOTIFY_MASK
			| GDK_LEAVE_NOTIFY_MASK;

  attributes.visual = gtk_widget_get_visual (widget);
  attributes.colormap = gtk_widget_get_colormap (widget);
  attributes.wclass = GDK_INPUT_OUTPUT;

  attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;

  widget->window = gdk_window_new (gtk_widget_get_parent_window (widget),
				   &attributes, attributes_mask);
  gdk_window_set_user_data (widget->window, widget);

  g_signal_connect (widget->window, "pick-embedded-child",
		    G_CALLBACK (pick_offscreen_child), offscreen_box);

  attributes.window_type = GDK_WINDOW_OFFSCREEN;

  /* Child 1 */
  attributes.x = attributes.y = 0;
  if (offscreen_box->child1 && gtk_widget_get_visible (offscreen_box->child1))
    {
      attributes.width = offscreen_box->child1->allocation.width;
      attributes.height = offscreen_box->child1->allocation.height;
      start_y += offscreen_box->child1->allocation.height;
    }
  offscreen_box->offscreen_window1 = gdk_window_new (gtk_widget_get_root_window (widget),
						     &attributes, attributes_mask);
  gdk_window_set_user_data (offscreen_box->offscreen_window1, widget);
  if (offscreen_box->child1)
    gtk_widget_set_parent_window (offscreen_box->child1, offscreen_box->offscreen_window1);

  gdk_offscreen_window_set_embedder (offscreen_box->offscreen_window1,
				     widget->window);
  
  g_signal_connect (offscreen_box->offscreen_window1, "to-embedder",
		    G_CALLBACK (offscreen_window_to_parent1), offscreen_box);
  g_signal_connect (offscreen_box->offscreen_window1, "from-embedder",
		    G_CALLBACK (offscreen_window_from_parent1), offscreen_box);

  /* Child 2 */
  attributes.y = start_y;
  child_requisition.width = child_requisition.height = 0;
  if (offscreen_box->child2 && gtk_widget_get_visible (offscreen_box->child2))
    {
      attributes.width = offscreen_box->child2->allocation.width;
      attributes.height = offscreen_box->child2->allocation.height;
    }
  offscreen_box->offscreen_window2 = gdk_window_new (gtk_widget_get_root_window (widget),
						     &attributes, attributes_mask);
  gdk_window_set_user_data (offscreen_box->offscreen_window2, widget);
  if (offscreen_box->child2)
    gtk_widget_set_parent_window (offscreen_box->child2, offscreen_box->offscreen_window2);
  gdk_offscreen_window_set_embedder (offscreen_box->offscreen_window2,
				     widget->window);
  g_signal_connect (offscreen_box->offscreen_window2, "to-embedder",
		    G_CALLBACK (offscreen_window_to_parent2), offscreen_box);
  g_signal_connect (offscreen_box->offscreen_window2, "from-embedder",
		    G_CALLBACK (offscreen_window_from_parent2), offscreen_box);

  widget->style = gtk_style_attach (widget->style, widget->window);

  gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL);
  gtk_style_set_background (widget->style, offscreen_box->offscreen_window1, GTK_STATE_NORMAL);
  gtk_style_set_background (widget->style, offscreen_box->offscreen_window2, GTK_STATE_NORMAL);

  gdk_window_show (offscreen_box->offscreen_window1);
  gdk_window_show (offscreen_box->offscreen_window2);
}
Exemple #17
0
void wxGetMousePosition( int* x, int* y )
{
    gdk_window_get_pointer(gtk_widget_get_root_window(wxGetRootWindow()), x, y, NULL);
}
Exemple #18
0
AssistantBase::AssistantBase(const ustring& title, const gchar * helptopic)
// Base class for each assistant.
{
  // Variables.
  process_id = 0;
  topic = helptopic;

  // If no help is given, take a default one.
  if (!topic) {
    topic = _("none");
  }
  
  // Signalling button.
  signal_button = gtk_button_new ();

  // Create the assistant.
  assistant = gtk_assistant_new();
  gtk_widget_show (assistant);
  gtk_window_set_modal (GTK_WINDOW (assistant), true);
  gtk_window_set_title (GTK_WINDOW (assistant), title.c_str());

  // Let it remain above other windows.
  gdk_window_set_keep_above (gtk_widget_get_root_window (assistant), true);
  
  // Introduction.
  label_intro = gtk_label_new (title.c_str());
  gtk_widget_show (label_intro);
  gtk_assistant_append_page (GTK_ASSISTANT (assistant), label_intro);
  gtk_label_set_line_wrap (GTK_LABEL (label_intro), TRUE);

  gtk_assistant_set_page_title (GTK_ASSISTANT (assistant), label_intro, _("Introduction"));
  gtk_assistant_set_page_type (GTK_ASSISTANT (assistant), label_intro, GTK_ASSISTANT_PAGE_INTRO);
  gtk_assistant_set_page_complete (GTK_ASSISTANT (assistant), label_intro, true);

  // Help button.
  //button_help = gtk_button_new();
  //gtk_widget_show(button_help);
  //gtk_assistant_add_action_widget (GTK_ASSISTANT (assistant), button_help);

  //GtkWidget *alignment = gtk_alignment_new(0.5, 0.5, 0, 0);
  //gtk_widget_show(alignment);
  //gtk_container_add(GTK_CONTAINER(button_help), alignment);

  //GtkWidget *hbox = gtk_hbox_new(FALSE, 2);
  //gtk_widget_show(hbox);
  //gtk_container_add(GTK_CONTAINER(alignment), hbox);

  //GtkWidget *image = gtk_image_new_from_stock("gtk-help", GTK_ICON_SIZE_BUTTON);
  //gtk_widget_show(image);
  //gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, FALSE, 0);

  //GtkWidget *label = gtk_label_new_with_mnemonic(_("_Help"));
  //gtk_widget_show(label);
  //gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
  
  // Signal handlers.
  //g_signal_connect((gpointer) button_help, "clicked", G_CALLBACK(on_button_help_activated), gpointer(this));
  g_signal_connect (G_OBJECT (assistant), "cancel", G_CALLBACK (on_assistant_cancel_signal), gpointer(this));
  g_signal_connect (G_OBJECT (assistant), "close", G_CALLBACK (on_assistant_close_signal), gpointer(this));
  // g_signal_connect (G_OBJECT (assistant), "delete_event", G_CALLBACK(on_assistant_delete_event), gpointer(this));
}