예제 #1
0
static gboolean
manager_maybe_grab_window (GSManager *manager,
                           GSWindow  *window)
{
	GdkDisplay *display;
	GdkDevice  *device;
	GdkMonitor *monitor;
	int         x, y;
	gboolean    grabbed;

	display = gdk_display_get_default ();
	device = gdk_seat_get_pointer (gdk_display_get_default_seat (display));
	gdk_device_get_position (device, NULL, &x, &y);
	monitor = gdk_display_get_monitor_at_point (display, x, y);

	gdk_display_flush (display);
	grabbed = FALSE;
	if (gs_window_get_display (window) == display &&
	    gs_window_get_monitor (window) == monitor)
	{
		gs_debug ("Initiate grab move to %p", window);
		gs_grab_move_to_window (manager->priv->grab,
		                        gs_window_get_gdk_window (window),
		                        gs_window_get_display (window),
		                        FALSE, FALSE);
		grabbed = TRUE;
	}

	return grabbed;
}
예제 #2
0
static GtkWidget *create_video_window(LinphoneCall *call, LinphoneCallState cstate) {
	GtkWidget *video_window;
	GdkDisplay *display;
	GdkColor color;
	MSVideoSize vsize = MS_VIDEO_SIZE_CIF;
	const char *cstate_str;
	char *title;
	stats* counters = get_stats(call->core);

	cstate_str = linphone_call_state_to_string(cstate);
	title = g_strdup_printf("%s", cstate_str);
	video_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	gtk_window_set_title(GTK_WINDOW(video_window), title);
	g_free(title);
	gtk_window_resize(GTK_WINDOW(video_window), vsize.width, vsize.height);
	gdk_color_parse("black", &color);
	gtk_widget_modify_bg(video_window, GTK_STATE_NORMAL, &color);
	gtk_widget_show(video_window);
	g_object_set_data(G_OBJECT(video_window), "call", call);
#if GTK_CHECK_VERSION(2,24,0)
	display = gdk_window_get_display(gtk_widget_get_window(video_window));
#else // backward compatibility with Debian 6 and Centos 6
	display = gdk_drawable_get_display(gtk_widget_get_window(video_window));
#endif
	gdk_display_flush(display);
	counters->number_of_video_windows_created++;
	return video_window;
}
예제 #3
0
static void
gdk_broadway_device_ungrab (GdkDevice *device,
			    guint32    time_)
{
  GdkDisplay *display;
  GdkBroadwayDisplay *broadway_display;
  GdkDeviceGrabInfo *grab;
  guint32 serial;

  display = gdk_device_get_display (device);
  broadway_display = GDK_BROADWAY_DISPLAY (display);

  if (gdk_device_get_source (device) == GDK_SOURCE_KEYBOARD)
    {
      /* Device is a keyboard */
    }
  else
    {
      /* Device is a pointer */

      if (broadway_display->output)
	{
	  serial = broadway_output_ungrab_pointer (broadway_display->output, time_);

	  gdk_display_flush (display);

	  grab = _gdk_display_get_last_device_grab (display, device);
	  if (grab &&
	      (time_ == GDK_CURRENT_TIME ||
	       grab->time == GDK_CURRENT_TIME ||
	       !TIME_IS_LATER (grab->time, time_)))
	    grab->serial_end = serial;
	}
    }
}
예제 #4
0
void WPkgGtk::set_clock_cursor()
{
  if ( !clock_cursor)
    clock_cursor = gdk_cursor_new_for_display( gtk_widget_get_display(toplevel), GDK_WATCH);

  gdk_window_set_cursor( toplevel->window, clock_cursor);
  gdk_display_flush( gtk_widget_get_display(toplevel));
}
예제 #5
0
void XNavGtk::set_clock_cursor()
{
  if (!clock_cursor)
    clock_cursor = gdk_cursor_new_for_display(
        gtk_widget_get_display(form_widget), GDK_WATCH);

  gdk_window_set_cursor(form_widget->window, clock_cursor);
  gdk_display_flush(gtk_widget_get_display(form_widget));
}
예제 #6
0
/* This function queries the _XROOTPMAP_ID property from the root window
 * to determine the current root window background pixmap and returns a
 * surface to draw directly to it.
 * If _XROOTPMAP_ID is not set, then NULL returned.
 */
static cairo_surface_t *
get_root_pixmap_id_surface (GdkDisplay *display)
{
	GdkScreen       *screen;
	Display         *xdisplay;
	Visual          *xvisual;
	Window           xroot;
	Atom             type;
	int              format, result;
	unsigned long    nitems, bytes_after;
	unsigned char   *data;
	cairo_surface_t *surface = NULL;

	g_return_val_if_fail (display != NULL, NULL);

	screen   = gdk_display_get_default_screen (display);
	xdisplay = GDK_DISPLAY_XDISPLAY (display);
	xvisual  = GDK_VISUAL_XVISUAL (gdk_screen_get_system_visual (screen));
	xroot    = RootWindow (xdisplay, GDK_SCREEN_XNUMBER (screen));

	result = XGetWindowProperty (xdisplay, xroot,
				     gdk_x11_get_xatom_by_name ("_XROOTPMAP_ID"),
				     0L, 1L, False, XA_PIXMAP,
				     &type, &format, &nitems, &bytes_after,
				     &data);

	if (result != Success || type != XA_PIXMAP ||
	    format != 32 || nitems != 1) {
		XFree (data);
		data = NULL;
	}

	if (data != NULL) {
		Pixmap pixmap = *(Pixmap *) data;
		Window root_ret;
		int x_ret, y_ret;
		unsigned int w_ret, h_ret, bw_ret, depth_ret;

		gdk_x11_display_error_trap_push (display);
		if (XGetGeometry (xdisplay, pixmap, &root_ret,
		                  &x_ret, &y_ret, &w_ret, &h_ret,
		                  &bw_ret, &depth_ret))
		{
			surface = cairo_xlib_surface_create (xdisplay,
			                                     pixmap, xvisual,
			                                     w_ret, h_ret);
		}

		gdk_x11_display_error_trap_pop_ignored (display);
		XFree (data);
	}

	gdk_display_flush (display);
	return surface;
}
static gboolean flush (gpointer data __attribute__((unused)))
{
  gdk_threads_enter ();

  gdk_display_flush (gdk_display_get_default ());
  flush_scheduled = 0;

  gdk_threads_leave ();

  return FALSE;
}
예제 #8
0
bool WebEmberX11::initSDL(FB::PluginWindow *pluginwindow)
{
	assert(!mPluginWindow);
	mPluginWindow = static_cast<FB::PluginWindowX11*>(pluginwindow);

	GtkWidget* widget = mPluginWindow->getWidget();

	// Fixes BadWindow error in SDL_SetVideoMode
	gdk_display_flush(gtk_widget_get_display(widget));

	char tmp[64];
	sprintf(tmp, "SDL_WINDOWID=%lu", (unsigned long)mPluginWindow->getWindow());
	putenv(tmp);
	//putenv("SDL_DEBUG=1");

	if (SDL_Init(SDL_INIT_VIDEO) < 0) {
		FBLOG_FATAL("WebEmberX11::initSDL", "Couldn't initialize SDL: " << SDL_GetError());
		return true;
	}

	if (!SDL_SetVideoMode(800, 600, 0, 0)) {
		FBLOG_FATAL("WebEmberX11::initSDL", "Couldn't create SDL window: " << SDL_GetError());
		return true;
	}

	SDL_SysWMinfo info;
	XSetWindowAttributes attributes;

	SDL_VERSION(&info.version); // this is important!
	SDL_GetWMInfo(&info);
	mDisplaySDL = info.info.x11.display;
	mWindow = info.info.x11.window;
	// Select the events, what SDL should receive.
	// SDL will not receive any messages when SDL_WINDOWID is set.
	{
		attributes.event_mask =
			//KeyPressMask | KeyReleaseMask | //ButtonPressMask | //ButtonReleaseMask |
			PropertyChangeMask// | StructureNotifyMask | //KeymapStateMask |
			//EnterWindowMask  | LeaveWindowMask | ExposureMask | PointerMotionMask |
			//VisibilityChangeMask// | PointerMotionHintMask |
			//FocusChangeMask
			;

		//select events, what SDL should receive.
		XSelectInput(mDisplaySDL, mWindow, attributes.event_mask);

		// Get the atom.
		//Atom WM_DELETE_WINDOW = XInternAtom(mDisplaySDL, "WM_DELETE_WINDOW", False);

		// Send window destory event to SDL to shut down properly.
		//XSetWMProtocols(mDisplaySDL, mWindow, &WM_DELETE_WINDOW, 1);
	}
	return false;
}
예제 #9
0
파일: util.c 프로젝트: cql1983/hardinfo
void widget_set_cursor(GtkWidget * widget, GdkCursorType cursor_type)
{
    GdkCursor *cursor;

    if ((cursor = gdk_cursor_new(cursor_type))) {
        gdk_window_set_cursor(GDK_WINDOW(widget->window), cursor);
        gdk_display_flush(gtk_widget_get_display(widget));
        gdk_cursor_unref(cursor);
    }

    while (gtk_events_pending())
	gtk_main_iteration();
}
/* Sets dialog busy state according to busy
 *
 * When busy:
 *	Sets the cursor to busy
 *  Disables the interface to prevent that the user interferes
 * Reverts all this when non-busy
 *
 * Note that this function takes into account the
 * authentication state of the dialog. So setting the
 * dialog to busy and then back to normal should leave
 * the dialog unchanged.
 */
static void
passdlg_set_busy (PasswordDialog *pdialog, gboolean busy)
{
	GtkBuilder *dialog;
	GtkWidget  *toplevel;
	GdkCursor  *cursor = NULL;
	GdkDisplay *display;

	dialog = pdialog->ui;

	/* Set cursor */
	toplevel = WID ("change-password");
	display = gtk_widget_get_display (toplevel);
	if (busy) {
		cursor = gdk_cursor_new_for_display (display, GDK_WATCH);
	}

	gdk_window_set_cursor (gtk_widget_get_window (toplevel), cursor);
	gdk_display_flush (display);

	if (busy) {
#if GTK_CHECK_VERSION (3, 0, 0)
		g_object_unref (cursor);
#else
		gdk_cursor_unref (cursor);
#endif
	}

	/* Disable/Enable UI */
	if (pdialog->authenticated) {
		/* Authenticated state */

		/* Enable/disable new password section */
		g_object_set (pdialog->new_password, "sensitive", !busy, NULL);
		g_object_set (pdialog->retyped_password, "sensitive", !busy, NULL);
		g_object_set (WID ("new-password-label"), "sensitive", !busy, NULL);
		g_object_set (WID ("retyped-password-label"), "sensitive", !busy, NULL);

		/* Enable/disable change password button */
		g_object_set (WID ("change-password-button"), "sensitive", !busy, NULL);

	} else {
		/* Not-authenticated state */

		/* Enable/disable auth section state */
		g_object_set (pdialog->current_password, "sensitive", !busy, NULL);
		g_object_set (WID ("authenticate-button"), "sensitive", !busy, NULL);
		g_object_set (WID ("current-password-label"), "sensitive", !busy, NULL);
	}
}
예제 #11
0
void wxBeginBusyCursor(const wxCursor* cursor)
{
    if (gs_busyCount++ > 0)
        return;

    wxASSERT_MSG( !gs_savedCursor.IsOk(),
                  wxT("forgot to call wxEndBusyCursor, will leak memory") );

    gs_savedCursor = g_globalCursor;
    g_globalCursor = *cursor;
    GdkDisplay* display = NULL;
    UpdateCursors(&display);
    if (display)
        gdk_display_flush(display);
}
static void
accept_password_dialog (GtkButton        *button,
                        UmPasswordDialog *um)
{
        const gchar *password;

        password = gtk_entry_get_text (GTK_ENTRY (um->password_entry));

        switch (um->password_mode) {
                act_user_set_password_mode (um->user, ACT_USER_PASSWORD_MODE_REGULAR);
                case ACT_USER_PASSWORD_MODE_REGULAR:
                        if (act_user_get_uid (um->user) == getuid ()) {
                                GdkDisplay *display;
                                GdkCursor *cursor;

                                /* When setting a password for the current user,
                                 * use passwd directly, to preserve the audit trail
                                 * and to e.g. update the keyring password.
                                 */
                                passwd_change_password (um->passwd_handler, password,
                                                        (PasswdCallback) password_changed_cb, um);
                                gtk_widget_set_sensitive (um->dialog, FALSE);
                                display = gtk_widget_get_display (um->dialog);
                                cursor = gdk_cursor_new_for_display (display, GDK_WATCH);
                                gdk_window_set_cursor (gtk_widget_get_window (um->dialog), cursor);
                                gdk_display_flush (display);
                                g_object_unref (cursor);
                                return;
                        }

                        act_user_set_password (um->user, password, "");
                        break;

                case ACT_USER_PASSWORD_MODE_SET_AT_LOGIN:
                        act_user_set_password_mode (um->user,  um->password_mode);
                        act_user_set_automatic_login (um->user, FALSE);
                        break;

                default:
                        g_assert_not_reached ();
        }

        finish_password_change (um);
}
예제 #13
0
static void
gimp_dialog_dispose (GObject *object)
{
  GdkDisplay *display = NULL;

  if (g_main_depth () == 0)
    {
      display = gtk_widget_get_display (GTK_WIDGET (object));
      g_object_ref (display);
    }

  G_OBJECT_CLASS (parent_class)->dispose (object);

  if (display)
    {
      gdk_display_flush (display);
      g_object_unref (display);
    }
}
예제 #14
0
static gboolean growwidgetgtk_event( GtkWidget *glow, GdkEvent *event)
{
  if ( event->type == GDK_MOTION_NOTIFY) {
    gdk_display_flush( ((GlowDrawGtk *)((GrowCtx *)((GrowWidgetGtk *)glow)->grow_ctx)->gdraw)->display);
    GdkEvent *next = gdk_event_peek();
    if ( next && next->type == GDK_MOTION_NOTIFY) {
      gdk_event_free( next);
      return TRUE;
    }
    else if ( next)
      gdk_event_free( next);
  }
  else if ( event->type == GDK_CONFIGURE) {
    ((GrowWidgetGtk *)glow)->scroll_configure = 1;
  }

  ((GlowDrawGtk *)((GrowCtx *)((GrowWidgetGtk *)glow)->grow_ctx)->gdraw)->event_handler( *event);
  return TRUE;
}
예제 #15
0
static void
check_manager_window (GdkX11Screen *x11_screen,
                      gboolean      notify_changes)
{
  GdkDisplay *display;
  Display *xdisplay;
  Window manager_window_xid;

  display = x11_screen->display;
  xdisplay = gdk_x11_display_get_xdisplay (display);

  if (x11_screen->xsettings_manager_window)
    {
      gdk_window_remove_filter (x11_screen->xsettings_manager_window, gdk_xsettings_manager_window_filter, x11_screen);
      g_object_unref (x11_screen->xsettings_manager_window);
    }

  gdk_x11_display_grab (display);

  manager_window_xid = XGetSelectionOwner (xdisplay, get_selection_atom (x11_screen));
  x11_screen->xsettings_manager_window = gdk_x11_window_foreign_new_for_display (display,
                                                                   manager_window_xid);
  /* XXX: Can't use gdk_window_set_events() here because the first call to this
   * function happens too early in gdk_init() */
  if (x11_screen->xsettings_manager_window)
    XSelectInput (xdisplay,
                  gdk_x11_window_get_xid (x11_screen->xsettings_manager_window),
                  PropertyChangeMask | StructureNotifyMask);

  gdk_x11_display_ungrab (display);
  
  gdk_display_flush (display);

  if (x11_screen->xsettings_manager_window)
    {
      gdk_window_add_filter (x11_screen->xsettings_manager_window, gdk_xsettings_manager_window_filter, x11_screen);
    }
      
  read_settings (x11_screen, notify_changes);
}
예제 #16
0
파일: gimpcursor.c 프로젝트: dawei5405/gimp
void
gimp_cursor_set (GtkWidget          *widget,
                 GimpHandedness      cursor_handedness,
                 GimpCursorType      cursor_type,
                 GimpToolCursorType  tool_cursor,
                 GimpCursorModifier  modifier)
{
  GdkCursor *cursor;

  g_return_if_fail (GTK_IS_WIDGET (widget));
  g_return_if_fail (gtk_widget_get_realized (widget));

  cursor = gimp_cursor_new (gtk_widget_get_display (widget),
                            cursor_handedness,
                            cursor_type,
                            tool_cursor,
                            modifier);
  gdk_window_set_cursor (gtk_widget_get_window (widget), cursor);
  gdk_cursor_unref (cursor);

  gdk_display_flush (gtk_widget_get_display (widget));
}
예제 #17
0
static void
on_display_monitor_removed (GdkDisplay *display,
                            GdkMonitor *monitor,
                            GSManager  *manager)
{
	GSList     *l;
	int         n_monitors;

	n_monitors = gdk_display_get_n_monitors (display);

	gs_debug ("Monitor removed on display %s, now there are %d",
	          gdk_display_get_name (display), n_monitors);

	gdk_x11_grab_server ();

	/* remove the now extra window */
	l = manager->priv->windows;
	while (l != NULL)
	{
		GdkDisplay *this_display;
		GdkMonitor *this_monitor;
		GSList     *next = l->next;

		this_display = gs_window_get_display (GS_WINDOW (l->data));
		this_monitor = gs_window_get_monitor (GS_WINDOW (l->data));
		if (this_display == display && this_monitor == monitor)
		{
			manager_maybe_stop_job_for_window (manager,
			                                   GS_WINDOW (l->data));
			g_hash_table_remove (manager->priv->jobs, l->data);
			gs_window_destroy (GS_WINDOW (l->data));
			manager->priv->windows = g_slist_delete_link (manager->priv->windows, l);
		}
		l = next;
	}

	gdk_display_flush (display);
	gdk_x11_ungrab_server ();
}
static void
accept_password_dialog (GtkButton        *button,
                        UmPasswordDialog *um)
{
        GtkTreeModel *model;
        GtkTreeIter iter;
        gint mode;
        const gchar *hint;
        const gchar *password;

        model = gtk_combo_box_get_model (GTK_COMBO_BOX (um->action_combo));
        gtk_combo_box_get_active_iter (GTK_COMBO_BOX (um->action_combo), &iter);
        gtk_tree_model_get (model, &iter, 1, &mode, -1);

        password = gtk_entry_get_text (GTK_ENTRY (um->password_entry));
        hint = gtk_entry_get_text (GTK_ENTRY (um->normal_hint_entry));

        if (mode == 0 && um_user_get_uid (um->user) == getuid ()) {
                GdkDisplay *display;
                GdkCursor *cursor;

                /* When setting a password for the current user,
                 * use passwd directly, to preserve the audit trail
                 * and to e.g. update the keyring password.
                 */
                passwd_change_password (um->passwd_handler, password, (PasswdCallback) password_changed_cb, um);
                gtk_widget_set_sensitive (um->dialog, FALSE);
                display = gtk_widget_get_display (um->dialog);
                cursor = gdk_cursor_new_for_display (display, GDK_WATCH);
                gdk_window_set_cursor (gtk_widget_get_window (um->dialog), cursor);
                gdk_display_flush (display);
                g_object_unref (cursor);
        }
        else {
                um_user_set_password (um->user, mode, password, hint);
                finish_password_change (um);
        }
}
예제 #19
0
static gboolean curvewidgetgtk_event( GtkWidget *glow, GdkEvent *event)
{
  if ( !((CurveWidgetGtk *)glow)->curve_ctx)
    // Navigator not yet created
    return TRUE;

  if ( event->type == GDK_MOTION_NOTIFY) {
    gdk_display_flush( ((GlowDrawGtk *)((CurveCtx *)((CurveWidgetGtk *)glow)->curve_ctx)->gdraw)->display);
    GdkEvent *next = gdk_event_peek();
    if ( next && next->type == GDK_MOTION_NOTIFY) {
      gdk_event_free( next);
      return TRUE;
    }
    else if ( next)
      gdk_event_free( next);
  }
  else if ( event->type == GDK_CONFIGURE) {
    ((CurveWidgetGtk *)glow)->scroll_configure = 1;
  }

  ((GlowDrawGtk *)((CurveCtx *)((CurveWidgetGtk *)glow)->curve_ctx)->gdraw)->event_handler( *event);
  return TRUE;
}
예제 #20
0
static VALUE
rg_flush(VALUE self)
{
    gdk_display_flush(_SELF(self));
    return self;
}
예제 #21
0
/*#
    @method flush GdkDisplay
    @brief Flushes any requests queued for the windowing system.

    This happens automatically when the main loop blocks waiting for new events,
    but if your application is drawing without returning control to the main loop,
    you may need to call this function explicitely. A common case where this
    function needs to be called is when an application is executing drawing
    commands from a thread other than the thread where the main loop is running.

    This is most useful for X11. On windowing systems where requests are handled
    synchronously, this function will do nothing.
 */
FALCON_FUNC Display::flush( VMARG )
{
    NO_ARGS
    gdk_display_flush( GET_DISPLAY( vm->self() ) );
}
예제 #22
0
void WPkgGtk::reset_cursor()
{
  gdk_window_set_cursor( toplevel->window, NULL);
  gdk_display_flush( gtk_widget_get_display(toplevel));
}
예제 #23
0
void MdispGtkView::InitializeOverlay()
   {
   MIL_TEXT_CHAR chText[80]; 

   // Initialize overlay if not already done
   if ((!m_isOverlayInitialized) && (m_MilDisplay))
      {
      //Only do it on a valid windowed display [CALL TO MIL]
      if (m_MilImage && m_MilDisplay )
         {
         // Prepare overlay buffer //
         ////////////////////////////

         // Enable display overlay annotations.
         MdispControl(m_MilDisplay, M_OVERLAY, M_ENABLE);

         // Inquire the Overlay buffer associated with the displayed buffer [CALL TO MIL]
         MdispInquire(m_MilDisplay, M_OVERLAY_ID, &m_MilOverlayImage);

         // Clear the overlay to transparent.
         MdispControl(m_MilDisplay, M_OVERLAY_CLEAR, M_DEFAULT);
         
         // Disable the overlay display update to accelerate annotations.
         MdispControl(m_MilDisplay, M_OVERLAY_SHOW, M_DISABLE);


         // Draw MIL monochrome overlay annotation *
         //*****************************************

         // Inquire MilOverlayImage size x and y [CALL TO MIL]
         long imageWidth  = MbufInquire(m_MilOverlayImage,M_SIZE_X,M_NULL);
         long imageHeight = MbufInquire(m_MilOverlayImage,M_SIZE_Y,M_NULL);

         // Set graphic text to transparent background. [CALL TO MIL]
         MgraControl(M_DEFAULT, M_BACKGROUND_MODE, M_TRANSPARENT);

         // Set drawing color to white. [CALL TO MIL]
         MgraColor(M_DEFAULT, M_COLOR_WHITE);

         // Print a string in the overlay image buffer. [CALL TO MIL]
         MgraText(M_DEFAULT, m_MilOverlayImage, imageWidth/9, imageHeight/5,    " -------------------- ");
         MgraText(M_DEFAULT, m_MilOverlayImage, imageWidth/9, imageHeight/5+25, " - MIL Overlay Text - ");
         MgraText(M_DEFAULT, m_MilOverlayImage, imageWidth/9, imageHeight/5+50, " -------------------- ");

         // Print a green string in the green component overlay image buffer. [CALL TO MIL]
         MgraColor(M_DEFAULT, M_COLOR_GREEN);
         MgraText(M_DEFAULT, m_MilOverlayImage, imageWidth*11/18, imageHeight/5,    " -------------------- ");
         MgraText(M_DEFAULT, m_MilOverlayImage, imageWidth*11/18, imageHeight/5+25, " - MIL Overlay Text - ");
         MgraText(M_DEFAULT, m_MilOverlayImage, imageWidth*11/18, imageHeight/5+50, " -------------------- ");

         // Draw GDI color overlay annotation *
         //************************************

         // Disable hook to MIL error because control might not be supported
         MappControl(M_ERROR_HOOKS, M_DISABLE);

         // Create a device context to draw in the overlay buffer with GDI.  [CALL TO MIL]
         MbufControl(m_MilOverlayImage, M_XPIXMAP_ALLOC, M_COMPENSATION_ENABLE);

         // Reenable hook to MIL error
         MappControl(M_ERROR_HOOKS, M_ENABLE);

         // Retrieve the XPIXMAP of the overlay [CALL TO MIL]
         Pixmap XPixmap = (Pixmap)MbufInquire(m_MilOverlayImage, M_XPIXMAP_HANDLE, M_NULL);

         /* convert it to gdkpixmap */
         GdkPixmap *gdkpixmap = gdk_pixmap_foreign_new(XPixmap);
            
         if(gdkpixmap)
            {
            GdkPoint Hor[2];
            GdkPoint Ver[2];
            GdkColor color[3];               
            GdkFont *font = NULL;
            font = gdk_font_load ("-misc-*-*-r-*-*-*-140-*-*-*-*-*-1");
            int i;
            
            /* get graphic context from pixmap*/
            GdkGC *gc = gdk_gc_new(gdkpixmap);
            
            /* allocate colors */
            gdk_color_parse("blue",&color[0]);
            gdk_color_parse("red",&color[1]);
            gdk_color_parse("yellow",&color[2]);
            for(i=0;i<3;i++)
               gdk_color_alloc(gdk_colormap_get_system(), &color[i]);
            
            /* set the foreground to our color */
            gdk_gc_set_foreground(gc, &color[0]);
            // Draw a blue cross in the overlay buffer.
            Hor[0].x = 0;
            Hor[0].y = imageHeight/2;
            Hor[1].x = imageWidth;
            Hor[1].y = imageHeight/2;
            gdk_draw_lines(gdkpixmap,gc,Hor,2);
            
            Ver[0].x = imageWidth/2;
            Ver[0].y = 0;
            Ver[1].x = imageWidth/2;
            Ver[1].y = imageHeight;
            gdk_draw_lines(gdkpixmap,gc,Ver,2);
            

            // Write Red text in the overlay buffer. 
            MosStrcpy(chText, 80, "X Overlay Text "); 
            gdk_gc_set_foreground(gc, &color[1]);
            gdk_draw_string(gdkpixmap, 
                            font,
                            gc, 
                            imageWidth*3/18,
                            imageHeight*4/6,
                            chText);
            
            // Write Yellow text in the overlay buffer. 
            gdk_gc_set_foreground(gc, &color[2]);
            gdk_draw_string(gdkpixmap, 
                            font,
                            gc, 
                            imageWidth*12/18,
                            imageHeight*4/6,
                            chText);
            
            /* flush */
            gdk_display_flush(gdk_display_get_default());
            
            /* Free graphic context.*/
            g_object_unref(gc);

            // Delete created Pixmap.  [CALL TO MIL]
            MbufControl(m_MilOverlayImage, M_XPIXMAP_FREE, M_DEFAULT);
            
            // Signal MIL that the overlay buffer was modified. [CALL TO MIL]
            MbufControl(m_MilOverlayImage, M_MODIFIED, M_DEFAULT);
            }

         // Now that overlay buffer is correctly prepared, we can show it [CALL TO MIL]
         MdispControl(m_MilDisplay, M_OVERLAY_SHOW, M_ENABLE);

         // Overlay is now initialized
         m_isOverlayInitialized = true;
         }
      }
   }
예제 #24
0
void WPkgGtk::flush()
{
  gdk_display_flush( gtk_widget_get_display(toplevel));
}
static void
accept_password_dialog (GtkButton        *button,
                        UmPasswordDialog *um)
{
        GtkTreeModel *model;
        GtkTreeIter iter;
        gint mode;
        const gchar *hint;
        const gchar *password;

        model = gtk_combo_box_get_model (GTK_COMBO_BOX (um->action_combo));
        gtk_combo_box_get_active_iter (GTK_COMBO_BOX (um->action_combo), &iter);
        gtk_tree_model_get (model, &iter, 1, &mode, -1);

        password = gtk_entry_get_text (GTK_ENTRY (um->password_entry));
        hint = NULL;

        switch (mode) {
                case UM_PASSWORD_DIALOG_MODE_NORMAL:
                        if (act_user_get_uid (um->user) == getuid ()) {
                                GdkDisplay *display;
                                GdkCursor *cursor;

                                /* When setting a password for the current user,
                                 * use passwd directly, to preserve the audit trail
                                 * and to e.g. update the keyring password.
                                 */
                                passwd_change_password (um->passwd_handler, password,
                                                        (PasswdCallback) password_changed_cb, um);
                                gtk_widget_set_sensitive (um->dialog, FALSE);
                                display = gtk_widget_get_display (um->dialog);
                                cursor = gdk_cursor_new_for_display (display, GDK_WATCH);
                                gdk_window_set_cursor (gtk_widget_get_window (um->dialog), cursor);
                                gdk_display_flush (display);
                                g_object_unref (cursor);
                                return;
                        }

                        act_user_set_password (um->user, password, hint);
                        break;

                case UM_PASSWORD_DIALOG_MODE_SET_AT_LOGIN:
                        act_user_set_password_mode (um->user, ACT_USER_PASSWORD_MODE_SET_AT_LOGIN);
                        break;

                case UM_PASSWORD_DIALOG_MODE_NO_PASSWORD:
                        act_user_set_password_mode (um->user, ACT_USER_PASSWORD_MODE_NONE);
                        break;

                case UM_PASSWORD_DIALOG_MODE_LOCK_ACCOUNT:
                        act_user_set_locked (um->user, TRUE);
                        break;

                case UM_PASSWORD_DIALOG_MODE_UNLOCK_ACCOUNT:
                        act_user_set_locked (um->user, FALSE);
                        break;

                default:
                        g_assert_not_reached ();
        }

        finish_password_change (um);
}