Exemplo n.º 1
0
static VALUE
rg_m_pointer_ungrab(VALUE self, VALUE time)
{
    gdk_pointer_ungrab(NUM2INT(time));
    return self;
}
static GdkRectangle *
select_area ()
{
  GdkWindow               *root;
  GdkCursor               *cursor;
  select_area_filter_data  data;
  GdkGCValues              values;
  GdkColor                 color;
  GdkRectangle            *rectangle;

  root   = gdk_get_default_root_window ();
  cursor = gdk_cursor_new (GDK_CROSSHAIR);

  if (gdk_pointer_grab (root, FALSE,
                        GDK_POINTER_MOTION_MASK|GDK_BUTTON_PRESS_MASK|GDK_BUTTON_RELEASE_MASK,
                        NULL, cursor,
                        GDK_CURRENT_TIME) != GDK_GRAB_SUCCESS)
    {
      gdk_cursor_unref (cursor);
      return FALSE;
    }

  gdk_keyboard_grab (root, FALSE, GDK_CURRENT_TIME);

  gdk_window_add_filter (root, (GdkFilterFunc) select_area_filter, &data);

  gdk_flush ();

  data.rect.x = 0;
  data.rect.y = 0;
  data.rect.width  = 0;
  data.rect.height = 0;
  data.button_pressed = FALSE;
  data.root = root;

  values.function = GDK_XOR;
  values.fill = GDK_SOLID;
  values.clip_mask = NULL;
  values.subwindow_mode = GDK_INCLUDE_INFERIORS;
  values.clip_x_origin = 0;
  values.clip_y_origin = 0;
  values.graphics_exposures = 0;
  values.line_width = 0;
  values.line_style = GDK_LINE_SOLID;
  values.cap_style = GDK_CAP_BUTT;
  values.join_style = GDK_JOIN_MITER;

  data.gc = gdk_gc_new_with_values (root, &values,
                                    GDK_GC_FUNCTION | GDK_GC_FILL |
                                    GDK_GC_CLIP_MASK | GDK_GC_SUBWINDOW |
                                    GDK_GC_CLIP_X_ORIGIN |
                                    GDK_GC_CLIP_Y_ORIGIN | GDK_GC_EXPOSURES |
                                    GDK_GC_LINE_WIDTH | GDK_GC_LINE_STYLE |
                                    GDK_GC_CAP_STYLE | GDK_GC_JOIN_STYLE);
  gdk_color_parse ("white", &color);
  gdk_gc_set_rgb_fg_color (data.gc, &color);
  gdk_color_parse ("black", &color);
  gdk_gc_set_rgb_bg_color (data.gc, &color);

  gtk_main ();

  g_object_unref (data.gc);

  gdk_window_remove_filter (root, (GdkFilterFunc) select_area_filter, &data);

  gdk_keyboard_ungrab (GDK_CURRENT_TIME);
  gdk_pointer_ungrab (GDK_CURRENT_TIME);
  gdk_cursor_unref (cursor);

  if (data.rect.width == 0 && data.rect.height == 0)
    return NULL;

  rectangle = g_new0 (GdkRectangle, 1);
  rectangle->x = data.rect.x;
  rectangle->y = data.rect.y;
  rectangle->width  = data.rect.width + 1;
  rectangle->height = data.rect.height + 1;

  return rectangle;
}
Exemplo n.º 3
0
static int
passphrase_dialog(char *message)
{
    const char *failed;
    char *passphrase, *local;
    int result, grab_tries, grab_server, grab_pointer;
    GtkWidget *dialog, *entry;
    GdkGrabStatus status;

    grab_server = (getenv("GNOME_SSH_ASKPASS_GRAB_SERVER") != NULL);
    grab_pointer = (getenv("GNOME_SSH_ASKPASS_GRAB_POINTER") != NULL);
    grab_tries = 0;

    dialog = gtk_message_dialog_new(NULL, 0,
                                    GTK_MESSAGE_QUESTION,
                                    GTK_BUTTONS_OK_CANCEL,
                                    "%s",
                                    message);

    entry = gtk_entry_new();
    gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), entry, FALSE,
                       FALSE, 0);
    gtk_entry_set_visibility(GTK_ENTRY(entry), FALSE);
    gtk_widget_grab_focus(entry);
    gtk_widget_show(entry);

    gtk_window_set_title(GTK_WINDOW(dialog), "OpenSSH");
    gtk_window_set_position (GTK_WINDOW(dialog), GTK_WIN_POS_CENTER);
    gtk_window_set_keep_above(GTK_WINDOW(dialog), TRUE);
    gtk_label_set_line_wrap(GTK_LABEL((GTK_MESSAGE_DIALOG(dialog))->label),
                            TRUE);

    /* Make <enter> close dialog */
    gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_OK);
    g_signal_connect(G_OBJECT(entry), "activate",
                     G_CALLBACK(ok_dialog), dialog);

    gtk_window_set_keep_above(GTK_WINDOW(dialog), TRUE);

    /* Grab focus */
    gtk_widget_show_now(dialog);
    if (grab_pointer) {
        for(;;) {
            status = gdk_pointer_grab(
                         (GTK_WIDGET(dialog))->window, TRUE, 0, NULL,
                         NULL, GDK_CURRENT_TIME);
            if (status == GDK_GRAB_SUCCESS)
                break;
            usleep(GRAB_WAIT * 1000);
            if (++grab_tries > GRAB_TRIES) {
                failed = "mouse";
                goto nograb;
            }
        }
    }
    for(;;) {
        status = gdk_keyboard_grab((GTK_WIDGET(dialog))->window,
                                   FALSE, GDK_CURRENT_TIME);
        if (status == GDK_GRAB_SUCCESS)
            break;
        usleep(GRAB_WAIT * 1000);
        if (++grab_tries > GRAB_TRIES) {
            failed = "keyboard";
            goto nograbkb;
        }
    }
    if (grab_server) {
        gdk_x11_grab_server();
    }

    result = gtk_dialog_run(GTK_DIALOG(dialog));

    /* Ungrab */
    if (grab_server)
        XUngrabServer(GDK_DISPLAY());
    if (grab_pointer)
        gdk_pointer_ungrab(GDK_CURRENT_TIME);
    gdk_keyboard_ungrab(GDK_CURRENT_TIME);
    gdk_flush();

    /* Report passphrase if user selected OK */
    passphrase = g_strdup(gtk_entry_get_text(GTK_ENTRY(entry)));
    if (result == GTK_RESPONSE_OK) {
        local = g_locale_from_utf8(passphrase, strlen(passphrase),
                                   NULL, NULL, NULL);
        if (local != NULL) {
            puts(local);
            memset(local, '\0', strlen(local));
            g_free(local);
        } else {
            puts(passphrase);
        }
    }

    /* Zero passphrase in memory */
    memset(passphrase, '\b', strlen(passphrase));
    gtk_entry_set_text(GTK_ENTRY(entry), passphrase);
    memset(passphrase, '\0', strlen(passphrase));
    g_free(passphrase);

    gtk_widget_destroy(dialog);
    return (result == GTK_RESPONSE_OK ? 0 : -1);

    /* At least one grab failed - ungrab what we got, and report
       the failure to the user.  Note that XGrabServer() cannot
       fail.  */
nograbkb:
    gdk_pointer_ungrab(GDK_CURRENT_TIME);
nograb:
    if (grab_server)
        XUngrabServer(GDK_DISPLAY());
    gtk_widget_destroy(dialog);

    report_failed_grab(failed);

    return (-1);
}
Exemplo n.º 4
0
void logbox(char *title, int width, char *default_text)
{
    GtkWidget *window;
    GtkWidget *vbox;
    GtkWidget *hbox, *button1;
    GtkWidget *label, *separator;
    GtkWidget *ctext;
    GtkWidget *text;
    struct logfile_instance_t *log_c;

    FILE *handle;
    struct wave_logfile_lines_t *wlog_head=NULL, *wlog_curr=NULL;
    int wlog_size = 0;

    handle = fopen(default_text, "rb");
    if(!handle)
	{
	char *buf = malloc_2(strlen(default_text)+128);
	sprintf(buf, "Could not open logfile '%s'\n", default_text);
	status_text(buf);
	free_2(buf);
	return;
	}

    /* fix problem where ungrab doesn't occur if button pressed + simultaneous accelerator key occurs */
    if(GLOBALS->in_button_press_wavewindow_c_1) { gdk_pointer_ungrab(GDK_CURRENT_TIME); }

#if defined(WAVE_USE_GTK2) && !defined(GTK_ENABLE_BROKEN)
/* nothing */
#else
    if(!GLOBALS->font_logfile_c_1) 
	{
	if(GLOBALS->fontname_logfile)
		{
		GLOBALS->font_logfile_c_1=gdk_font_load(GLOBALS->fontname_logfile);
		}

	if(!GLOBALS->font_logfile_c_1)
		{
#ifndef __CYGWIN__
		 GLOBALS->font_logfile_c_1=gdk_font_load(GLOBALS->use_big_fonts 
				? "-*-courier-*-r-*-*-18-*-*-*-*-*-*-*"
				: "-*-courier-*-r-*-*-10-*-*-*-*-*-*-*");
#else
		 GLOBALS->font_logfile_c_1=gdk_font_load(GLOBALS->use_big_fonts 
				? "-misc-fixed-*-*-*-*-18-*-*-*-*-*-*-*"
				: "-misc-fixed-*-*-*-*-10-*-*-*-*-*-*-*");

#endif
		}
	}
#endif

    /* create a new nonmodal window */
    window = gtk_window_new(GLOBALS->disable_window_manager ? GTK_WINDOW_POPUP : GTK_WINDOW_TOPLEVEL);
    if(GLOBALS->use_big_fonts || GLOBALS->fontname_logfile)
	{
    	gtk_widget_set_usize( GTK_WIDGET (window), width*1.8, 600);
	}
	else
	{
    	gtk_widget_set_usize( GTK_WIDGET (window), width, 400);
	}
    gtk_window_set_title(GTK_WINDOW (window), title);

    gtk_signal_connect(GTK_OBJECT (window), "delete_event", (GtkSignalFunc) destroy_callback, window);

    vbox = gtk_vbox_new (FALSE, 0);
    gtk_container_add (GTK_CONTAINER (window), vbox);
    gtk_widget_show (vbox);

    label=gtk_label_new(default_text);
    gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
    gtk_widget_show (label);

    separator = gtk_hseparator_new ();
    gtk_box_pack_start (GTK_BOX (vbox), separator, FALSE, TRUE, 0);
    gtk_widget_show (separator);

    ctext=create_log_text(&text);
    gtk_box_pack_start (GTK_BOX (vbox), ctext, TRUE, TRUE, 0);
    gtk_widget_show (ctext);

    separator = gtk_hseparator_new ();
    gtk_box_pack_start (GTK_BOX (vbox), separator, FALSE, TRUE, 0);
    gtk_widget_show (separator);

    hbox = gtk_hbox_new (FALSE, 1);
    gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
    gtk_widget_show (hbox);

    button1 = gtk_button_new_with_label ("Close Logfile");
    gtk_widget_set_usize(button1, 100, -1);
    gtk_signal_connect(GTK_OBJECT (button1), "clicked", GTK_SIGNAL_FUNC(ok_callback), window);
    gtk_widget_show (button1);
    gtk_container_add (GTK_CONTAINER (hbox), button1);  
    GTK_WIDGET_SET_FLAGS (button1, GTK_CAN_DEFAULT);
    gtk_signal_connect_object (GTK_OBJECT (button1), "realize", (GtkSignalFunc) gtk_widget_grab_default, GTK_OBJECT (button1));

    gtk_widget_show(window);

    log_text_bold(text, NULL, "Click-select");
    log_text(text, NULL, " on numbers to jump to that time value in the wave viewer.\n");
    log_text(text, NULL, " \n");

    while(!feof(handle))
	{
	char *pnt = fgetmalloc(handle);
	if(pnt)
		{
		struct wave_logfile_lines_t *w = calloc_2(1, sizeof(struct wave_logfile_lines_t));

		wlog_size += (GLOBALS->fgetmalloc_len+1);
		w->text = pnt;
		if(!wlog_curr) { wlog_head = wlog_curr = w; } else { wlog_curr->next = w; wlog_curr = w; }
		}
	}

    if(wlog_curr)
	{
	struct wave_logfile_lines_t *w = wlog_head;
	struct wave_logfile_lines_t *wt;
	char *pnt = malloc_2(wlog_size + 1);
	char *pnt2 = pnt;

	while(w)
		{
		int len = strlen(w->text);
		memcpy(pnt2, w->text, len);
		pnt2 += len;
		*pnt2 = '\n';
		pnt2++;

		free_2(w->text);
		wt = w;
		w = w->next;
		free_2(wt);
		}
	/* wlog_head = */ wlog_curr = NULL; /* scan-build */
	*pnt2 = 0;
	log_text(text, GLOBALS->font_logfile_c_1, pnt);
	free_2(pnt);
	}

    fclose(handle);

    log_c = calloc(1, sizeof(struct logfile_instance_t) + strlen(default_text));  /* deliberately not calloc_2, needs to be persistent! */
    strcpy(log_c->default_text, default_text);
    log_c->window = window;
    log_c->text = text;
    log_c->next = log_collection;
#if defined(WAVE_USE_GTK2) && !defined(GTK_ENABLE_BROKEN)
    log_c->bold_tag = GLOBALS->bold_tag_logfile_c_2;
    log_c->mono_tag = GLOBALS->mono_tag_logfile_c_1;
    log_c->size_tag = GLOBALS->size_tag_logfile_c_1;
#else
    log_c->font_logfile = GLOBALS->font_logfile_c_1;
#endif
    log_collection = log_c;
}
Exemplo n.º 5
0
static gint
process_event (GtkWidget *widget, GdkEvent *event, gpointer data G_GNUC_UNUSED)
{
  static GtkWidget *original_widget = NULL;
  static GdkCursor *cursor = NULL;

  switch (event->type) {
    case GDK_BUTTON_PRESS:
		if (event->button.button != gstroke_get_mouse_button()) {
			/* Similar to the bug below catch when any other button is
			 * clicked after the middle button is clicked (but possibly
			 * not released)
			 */
			gstroke_cancel(event);	
			original_widget = NULL;
			break;
		}

      original_widget = widget; /* remeber the widget where
                                   the stroke started */

      gstroke_invisible_window_init (widget);

      record_stroke_segment (widget);

	  if (cursor == NULL)
		  cursor = gdk_cursor_new(GDK_PENCIL);

      gdk_pointer_grab (widget->window, FALSE,
			GDK_BUTTON_RELEASE_MASK, NULL, cursor,
			event->button.time);
      timer_id = g_timeout_add (GSTROKE_TIMEOUT_DURATION,
				  gstroke_timeout, widget);
      return TRUE;

    case GDK_BUTTON_RELEASE:
      if ((event->button.button != gstroke_get_mouse_button())
	  || (original_widget == NULL)) {

		/* Nice bug when you hold down one button and press another. */
		/* We'll just cancel the gesture instead. */
		gstroke_cancel(event);
		original_widget = NULL;
		break;
	  }

      last_mouse_position.invalid = TRUE;
      original_widget = NULL;
      g_source_remove (timer_id);
      gdk_pointer_ungrab (event->button.time);
      timer_id = 0;

      {
	char result[GSTROKE_MAX_SEQUENCE];
	struct gstroke_metrics *metrics;

	metrics = (struct gstroke_metrics *)g_object_get_data(G_OBJECT (widget),
														  GSTROKE_METRICS);
		if (gstroke_draw_strokes()) {
			/* get rid of the invisible stroke window */
			XUnmapWindow (gstroke_disp, gstroke_window);
			XFlush (gstroke_disp);
		}

	_gstroke_canonical (result, metrics);
	gstroke_execute (widget, result);
	return FALSE;
      }
      return TRUE;
    default:
      break;
  }

  return FALSE;
}
Exemplo n.º 6
0
void playlist_list_button_press_cb(GtkWidget * widget, GdkEventButton * event, PlayList_List * pl)
{
	if (event->button == 1 && pl->pl_fheight &&
	    inside_widget(event->x, event->y, &pl->pl_widget))
	{
		int nr, y;

		y = event->y - pl->pl_widget.y;
		nr = (y / pl->pl_fheight) + pl->pl_first;
		if (nr >= get_playlist_length())
			nr = get_playlist_length() - 1;
		if (!(event->state & GDK_CONTROL_MASK))
			playlist_select_all(FALSE);
		
		if (event->state & GDK_SHIFT_MASK && pl->pl_prev_selected != -1)
		{
			playlist_select_range(pl->pl_prev_selected, nr, TRUE);
			pl->pl_prev_min = pl->pl_prev_selected;
			pl->pl_prev_max = nr;
			pl->pl_drag_pos = nr - pl->pl_first;
		}
		else
		{
			if (playlist_select_invert(nr))
			{
				if (event->state & GDK_CONTROL_MASK)
				{
					if (pl->pl_prev_min == -1)
					{
						pl->pl_prev_min =
							pl->pl_prev_selected;
						pl->pl_prev_max =
							pl->pl_prev_selected;
					}
					if (nr < pl->pl_prev_min)
						pl->pl_prev_min = nr;
					else if (nr > pl->pl_prev_max)
						pl->pl_prev_max = nr;
				}
				else
					pl->pl_prev_min = -1;
				pl->pl_prev_selected = nr;
				pl->pl_drag_pos = nr - pl->pl_first;
			}
		}
		if (event->type == GDK_2BUTTON_PRESS)
		{
			/*
			 * Ungrab the pointer to prevent us from
			 * hanging on to it during the sometimes slow
			 * playlist_play().
			 */
			gdk_pointer_ungrab(GDK_CURRENT_TIME);
			gdk_flush();
			playlist_set_position(nr);
			if (!get_input_playing())
				playlist_play();
		}
		pl->pl_dragging = TRUE;
		playlistwin_update_list();
	}
}
Exemplo n.º 7
0
static void
modify_button_release(ModifyTool *tool, GdkEventButton *event,
		      DDisplay *ddisp)
{
  Point *dest_pos, to;
  GList *list;
  int i;
  ObjectChange *objchange;
  
  tool->break_connections = FALSE;
  ddisplay_set_all_cursor(default_cursor);

  /* remove position from status bar */
  {
    GtkStatusbar *statusbar = GTK_STATUSBAR (ddisp->modified_status);
    guint context_id = gtk_statusbar_get_context_id (statusbar, "ObjectPos");
    gtk_statusbar_pop (statusbar, context_id);
  }
  switch (tool->state) {
  case STATE_MOVE_OBJECT:
    /* Return to normal state */
    gdk_pointer_ungrab (event->time);

    ddisplay_untransform_coords(ddisp, event->x, event->y, &to.x, &to.y);
    if (!modify_move_already(tool, ddisp, &to)) {
      tool->orig_pos = NULL;
      tool->state = STATE_NONE;
      return;
    }

    diagram_update_connections_selection(ddisp->diagram);

    if (tool->orig_pos != NULL) {
      /* consider the non-selected children affected */
      list = parent_list_affected(ddisp->diagram->data->selected);
      dest_pos = g_new(Point, g_list_length(list));
      i=0;
      while (list != NULL) {
	DiaObject *obj = (DiaObject *)  list->data;
	dest_pos[i] = obj->position;
	list = g_list_next(list); i++;
      }

      undo_move_objects(ddisp->diagram, tool->orig_pos, dest_pos,
			parent_list_affected(ddisp->diagram->data->selected));
    }
    
    ddisplay_connect_selected(ddisp); /* pushes UNDO info */
    diagram_update_extents(ddisp->diagram);
    diagram_modified(ddisp->diagram);
    diagram_flush(ddisp->diagram);

    undo_set_transactionpoint(ddisp->diagram->undo);

    tool->orig_pos = NULL;
    tool->state = STATE_NONE;
    break;
  case STATE_MOVE_HANDLE:
    gdk_pointer_ungrab (event->time);
    tool->state = STATE_NONE;

    if (tool->orig_pos != NULL) {
      undo_move_handle(ddisp->diagram, tool->handle, tool->object,
		       *tool->orig_pos, tool->last_to);
    }
    
    /* Final move: */
    object_add_updates(tool->object, ddisp->diagram);
    objchange = tool->object->ops->move_handle(tool->object, tool->handle,
					       &tool->last_to, NULL,
					       HANDLE_MOVE_USER_FINAL,gdk_event_to_dia_ModifierKeys(event->state));
    if (objchange != NULL) {
      undo_object_change(ddisp->diagram, tool->object, objchange);
    }

    object_add_updates(tool->object, ddisp->diagram);

    /* Connect if possible: */
    if (tool->handle->connect_type != HANDLE_NONCONNECTABLE) {
      object_connect_display(ddisp, tool->object, tool->handle, TRUE); /* pushes UNDO info */
      diagram_update_connections_selection(ddisp->diagram);
    }
    
    highlight_reset_all(ddisp->diagram);
    diagram_flush(ddisp->diagram);
    
    diagram_modified(ddisp->diagram);
    diagram_update_extents(ddisp->diagram);

    undo_set_transactionpoint(ddisp->diagram->undo);

    if (tool->orig_pos != NULL) {
      g_free(tool->orig_pos);
      tool->orig_pos = NULL;
    }

    break;
  case STATE_BOX_SELECT:
    
    gdk_pointer_ungrab (event->time);
    /* Remove last box: */
    if (!tool->auto_scrolled) {
      gdk_draw_rectangle (gtk_widget_get_window (ddisp->canvas), tool->gc, FALSE,
			tool->x1, tool->y1,
			tool->x2 - tool->x1, tool->y2 - tool->y1);
    }

    {
      GList *list, *list_to_free;

      list = list_to_free = find_selected_objects(ddisp, tool);
      
      if (selection_style == SELECT_REPLACE &&
          !(event->state & GDK_SHIFT_MASK)) {
        /* Not Multi-select => Remove all selected */
        diagram_remove_all_selected(ddisp->diagram, TRUE);
      }

      if (selection_style == SELECT_INTERSECTION) {
        GList *intersection = NULL;

        while (list != NULL) {
          DiaObject *obj = (DiaObject *)list->data;
          
          if (diagram_is_selected(ddisp->diagram, obj)) {
            intersection = g_list_append(intersection, obj);
          }
          
          list = g_list_next(list);
        }
        list = intersection;
        diagram_remove_all_selected(ddisp->diagram, TRUE);
        while (list != NULL) {
          DiaObject *obj = (DiaObject *)list->data;

          diagram_select(ddisp->diagram, obj);

          list = g_list_next(list);
        }
        g_list_free(intersection);
      } else {
        while (list != NULL) {
          DiaObject *obj = (DiaObject *)list->data;
          
          if (selection_style == SELECT_REMOVE) {
            if (diagram_is_selected(ddisp->diagram, obj))
              diagram_unselect_object(ddisp->diagram, obj);
          } else if (selection_style == SELECT_INVERT) { 
            if (diagram_is_selected(ddisp->diagram, obj))
              diagram_unselect_object(ddisp->diagram, obj);
            else
              diagram_select(ddisp->diagram, obj);
          } else {
            if (!diagram_is_selected(ddisp->diagram, obj))
              diagram_select(ddisp->diagram, obj);
          }
          
          list = g_list_next(list);
        }
      }

      g_list_free(list_to_free);
      
    }
    
    ddisplay_do_update_menu_sensitivity(ddisp);
    ddisplay_flush(ddisp);

    tool->state = STATE_NONE;
    break;
  case STATE_NONE:
    break;
  default:
    message_error("Internal error: Strange state in modify_tool\n");
      
  }
}
Exemplo n.º 8
0
bool wxPopupTransientWindow::Show( bool show )
{
#ifdef __WXGTK__
    if (!show)
    {
#ifdef __WXGTK3__
        GdkDisplay* display = gtk_widget_get_display(m_widget);
#ifdef __WXGTK4__
        gdk_seat_ungrab(gdk_display_get_default_seat(display));
#else
        wxGCC_WARNING_SUPPRESS(deprecated-declarations)
        GdkDeviceManager* manager = gdk_display_get_device_manager(display);
        GdkDevice* device = gdk_device_manager_get_client_pointer(manager);
        gdk_device_ungrab(device, unsigned(GDK_CURRENT_TIME));
        wxGCC_WARNING_RESTORE()
#endif
#else
        gdk_pointer_ungrab( (guint32)GDK_CURRENT_TIME );
#endif

        gtk_grab_remove( m_widget );
    }
#endif

#ifdef __WXX11__
    if (!show)
    {
        XUngrabPointer( wxGlobalDisplay(), CurrentTime );
    }
#endif

#if defined( __WXMSW__ ) || defined( __WXMAC__)
    if (!show && m_child && m_child->HasCapture())
    {
        m_child->ReleaseMouse();
    }
#endif

    bool ret = wxPopupWindow::Show( show );

#ifdef __WXGTK__
    if (show)
    {
        gtk_grab_add( m_widget );

        GdkWindow* window = gtk_widget_get_window(m_widget);
#ifdef __WXGTK4__
        GdkDisplay* display = gdk_window_get_display(window);
        GdkSeat* seat = gdk_display_get_default_seat(display);
        gdk_seat_grab(seat, window, GDK_SEAT_CAPABILITY_POINTER, false, NULL, NULL, NULL, 0);
#else
        const GdkEventMask mask = GdkEventMask(
            GDK_BUTTON_PRESS_MASK |
            GDK_BUTTON_RELEASE_MASK |
            GDK_POINTER_MOTION_HINT_MASK |
            GDK_POINTER_MOTION_MASK);
#ifdef __WXGTK3__
        GdkDisplay* display = gdk_window_get_display(window);
        wxGCC_WARNING_SUPPRESS(deprecated-declarations)
        GdkDeviceManager* manager = gdk_display_get_device_manager(display);
        GdkDevice* device = gdk_device_manager_get_client_pointer(manager);
        gdk_device_grab(device, window,
            GDK_OWNERSHIP_NONE, true, mask, NULL, unsigned(GDK_CURRENT_TIME));
        wxGCC_WARNING_RESTORE()
#else
        gdk_pointer_grab( window, true,
                          mask,
                          NULL,
                          NULL,
                          (guint32)GDK_CURRENT_TIME );
#endif
#endif // !__WXGTK4__
    }
#endif

#ifdef __WXX11__
    if (show)
    {
        Window xwindow = (Window) m_clientWindow;

        /* int res =*/ XGrabPointer(wxGlobalDisplay(), xwindow,
            True,
            ButtonPressMask | ButtonReleaseMask | ButtonMotionMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask,
            GrabModeAsync,
            GrabModeAsync,
            None,
            None,
            CurrentTime );
    }
#endif

#if defined( __WXMSW__ ) || defined( __WXMAC__)
    if (show && m_child)
    {
        // Assume that the mouse is outside the popup to begin with
        m_child->CaptureMouse();
    }
#endif

    return ret;
}
Exemplo n.º 9
0
static gboolean grab_key_callback(GtkWidget* widget, GdkEventKey* event, void* data)
{
	GdkModifierType accel_mods = 0;
	guint accel_keyval;
	EggCellRendererKeys *keys;
	char *path;
	gboolean edited;
	gboolean cleared;
	GdkModifierType consumed_modifiers;
	guint upper;
	GdkModifierType ignored_modifiers;

	keys = EGG_CELL_RENDERER_KEYS(data);

	if (is_modifier(event->hardware_keycode))
	{
		return TRUE;
	}

	edited = FALSE;
	cleared = FALSE;

	consumed_modifiers = 0;
	gdk_keymap_translate_keyboard_state(gdk_keymap_get_default(),
		event->hardware_keycode,
		event->state,
		event->group,
		NULL, NULL, NULL, &consumed_modifiers);

	upper = event->keyval;
	accel_keyval = gdk_keyval_to_lower(upper);

	if (accel_keyval == GDK_KEY_ISO_Left_Tab)
	{
		accel_keyval = GDK_KEY_Tab;
	}

	/* Put shift back if it changed the case of the key, not otherwise. */
	if (upper != accel_keyval && (consumed_modifiers & GDK_SHIFT_MASK))
	{
		consumed_modifiers &= ~(GDK_SHIFT_MASK);
	}

	egg_keymap_resolve_virtual_modifiers(gdk_keymap_get_default(),
		EGG_VIRTUAL_NUM_LOCK_MASK |
		EGG_VIRTUAL_SCROLL_LOCK_MASK |
		EGG_VIRTUAL_LOCK_MASK,
		&ignored_modifiers);

	/* http://bugzilla.gnome.org/show_bug.cgi?id=139605
	 * mouse keys should effect keybindings */
	ignored_modifiers |= GDK_BUTTON1_MASK |
		GDK_BUTTON2_MASK |
		GDK_BUTTON3_MASK |
		GDK_BUTTON4_MASK |
		GDK_BUTTON5_MASK;

	/* filter consumed/ignored modifiers */
	if (keys->accel_mode == EGG_CELL_RENDERER_KEYS_MODE_GTK)
	{
		accel_mods = event->state & GDK_MODIFIER_MASK & ~(consumed_modifiers | ignored_modifiers);
	}
	else if (keys->accel_mode == EGG_CELL_RENDERER_KEYS_MODE_X)
	{
		accel_mods = event->state & GDK_MODIFIER_MASK & ~(ignored_modifiers);
	}
	else
	{
		g_assert_not_reached();
	}

	if (accel_mods == 0 && accel_keyval == GDK_KEY_Escape)
	{
		goto out; /* cancel */
	}

	/* clear the accelerator on Backspace */
	if (accel_mods == 0 && accel_keyval == GDK_KEY_BackSpace)
	{
		cleared = TRUE;
		goto out;
	}

	if (keys->accel_mode == EGG_CELL_RENDERER_KEYS_MODE_GTK)
	{
		if (!gtk_accelerator_valid (accel_keyval, accel_mods))
		{
			accel_keyval = 0;
			accel_mods = 0;
		}
	}

	edited = TRUE;

	out:

	gdk_keyboard_ungrab(event->time);
	gdk_pointer_ungrab(event->time);

	path = g_strdup(g_object_get_data(G_OBJECT(keys->edit_widget), EGG_CELL_RENDERER_TEXT_PATH));

	gtk_cell_editable_editing_done(GTK_CELL_EDITABLE(keys->edit_widget));
	gtk_cell_editable_remove_widget(GTK_CELL_EDITABLE(keys->edit_widget));
	keys->edit_widget = NULL;
	keys->grab_widget = NULL;

	if (edited)
	{
		g_signal_emit_by_name(G_OBJECT(keys), "accel_edited", path, accel_keyval, accel_mods, event->hardware_keycode);
	}
	else if (cleared)
	{
		g_signal_emit_by_name(G_OBJECT(keys), "accel_cleared", path);
	}

	g_free (path);
	return TRUE;
}
Exemplo n.º 10
0
/* This is a _horrible_ hack to have this here. This needs to be added to the
 * GTK+ menuing code in some manner.
 */
static void
drag_end_menu_cb (GtkWidget *widget, GdkDragContext     *context)
{
  GtkWidget *xgrab_shell;
  GtkWidget *parent;

  /* Find the last viewable ancestor, and make an X grab on it
   */
  parent = gtk_widget_get_parent (widget);
  xgrab_shell = NULL;

  /* FIXME: workaround for a possible gtk+ bug
   *    See bugs #92085(gtk+) and #91184(panel) for details.
   */
  g_object_set (widget, "has-tooltip", TRUE, NULL);

  while (parent)
    {
      gboolean viewable = TRUE;
      GtkWidget *tmp = parent;

      while (tmp)
	{
	  if (!gtk_widget_get_mapped (tmp))
	    {
	      viewable = FALSE;
	      break;
	    }
	  tmp = gtk_widget_get_parent (tmp);
	}

      if (viewable)
	xgrab_shell = parent;

#if GTK_CHECK_VERSION (3, 0, 0)
      parent = gtk_menu_shell_get_parent_shell (GTK_MENU_SHELL (parent));
#else
      parent = GTK_MENU_SHELL (parent)->parent_menu_shell;
#endif
    }

#if GTK_CHECK_VERSION (3, 0, 0)
  if (xgrab_shell)
#else
  if (xgrab_shell && !gtk_menu_get_tearoff_state (GTK_MENU(xgrab_shell)))
#endif
    {
#if GTK_CHECK_VERSION (3, 0, 0)
      gboolean status;
      GdkDisplay *display;
      GdkDevice *pointer;
      GdkDevice *keyboard;
#if GTK_CHECK_VERSION(3, 20, 0)
      GdkSeat *seat;
#else
      GdkDeviceManager *device_manager;
#endif
#endif
      GdkWindow *window = gtk_widget_get_window (xgrab_shell);
      GdkCursor *cursor = gdk_cursor_new_for_display (gdk_display_get_default (),
                                                      GDK_ARROW);

#if GTK_CHECK_VERSION (3, 0, 0)
      display = gdk_window_get_display (window);
#if GTK_CHECK_VERSION(3, 20, 0)
      seat = gdk_display_get_default_seat (display);
      pointer = gdk_seat_get_pointer (seat);
#else
      device_manager = gdk_display_get_device_manager (display);
      pointer = gdk_device_manager_get_client_pointer (device_manager);
#endif
      keyboard = gdk_device_get_associated_device (pointer);

      /* FIXMEgpoo: Not sure if report to GDK_OWNERSHIP_WINDOW
         or GDK_OWNERSHIP_APPLICATION Idem for the
         keyboard below */
      status = gdk_device_grab (pointer, window,
                                GDK_OWNERSHIP_WINDOW, TRUE,
                                GDK_BUTTON_PRESS_MASK
                                | GDK_BUTTON_RELEASE_MASK
                                | GDK_ENTER_NOTIFY_MASK
                                | GDK_LEAVE_NOTIFY_MASK
                                | GDK_POINTER_MOTION_MASK,
                                cursor, GDK_CURRENT_TIME);

      if (!status)
        {
	  if (gdk_device_grab (keyboard, window,
			       GDK_OWNERSHIP_WINDOW, TRUE,
			       GDK_KEY_PRESS | GDK_KEY_RELEASE,
			       NULL, GDK_CURRENT_TIME) == GDK_GRAB_SUCCESS)
	    {
#else
      if ((gdk_pointer_grab (window, TRUE,
			     GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK |
			     GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK |
			     GDK_POINTER_MOTION_MASK,
			     NULL, cursor, GDK_CURRENT_TIME) == 0))
	{
	  if (gdk_keyboard_grab (window, TRUE,
				 GDK_CURRENT_TIME) == 0)
	    {
#endif
/* FIXME fix for GTK3 */
#if !GTK_CHECK_VERSION (3, 0, 0)
          GTK_MENU_SHELL (xgrab_shell)->have_xgrab = TRUE;
#endif
	    }
	  else
	    {
#if GTK_CHECK_VERSION (3, 0, 0)
	      gdk_device_ungrab (pointer, GDK_CURRENT_TIME);
	    }
	}

      g_object_unref (cursor);
#else
	      gdk_pointer_ungrab (GDK_CURRENT_TIME);
	    }
	}

      gdk_cursor_unref (cursor);
#endif
    }
}
Exemplo n.º 11
0
static gchar*
passphrase_mbox (const gchar *desc)
{
    gchar *the_passphrase = NULL;
    GtkWidget *vbox;
    GtkWidget *table;
    GtkWidget *pass_label;
    GtkWidget *confirm_box;
    GtkWidget *window;
    GtkWidget *pass_entry;
    GtkWidget *ok_button;
    GtkWidget *cancel_button;

    window = gtk_window_new(GTK_WINDOW_DIALOG);
    gtk_window_set_title(GTK_WINDOW(window), _("Passphrase"));
    gtk_widget_set_usize(window, 450, -1);
    gtk_container_set_border_width(GTK_CONTAINER(window), 4);
    gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
    gtk_window_set_modal(GTK_WINDOW(window), TRUE);
    gtk_window_set_policy(GTK_WINDOW(window), FALSE, FALSE, FALSE);
    gtk_signal_connect(GTK_OBJECT(window), "delete_event",
                       GTK_SIGNAL_FUNC(passphrase_deleted), NULL);
    gtk_signal_connect(GTK_OBJECT(window), "key_press_event",
                       GTK_SIGNAL_FUNC(passphrase_key_pressed), NULL);
    MANAGE_WINDOW_SIGNALS_CONNECT(window);
    manage_window_set_transient(GTK_WINDOW(window));

    vbox = gtk_vbox_new(FALSE, 8);
    gtk_container_add(GTK_CONTAINER(window), vbox);

    if (desc) {
        GtkWidget *label;
        label = create_description (desc);
        gtk_box_pack_start (GTK_BOX(vbox), label, TRUE, TRUE, 0);
    }

    table = gtk_table_new(2, 2, FALSE);
    gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0);
    gtk_container_set_border_width(GTK_CONTAINER(table), 8);
    gtk_table_set_row_spacings(GTK_TABLE(table), 12);
    gtk_table_set_col_spacings(GTK_TABLE(table), 8);


    pass_label = gtk_label_new("");
    gtk_table_attach (GTK_TABLE(table), pass_label, 0, 1, 0, 1,
                      GTK_FILL, GTK_EXPAND|GTK_FILL, 0, 0);
    gtk_misc_set_alignment (GTK_MISC (pass_label), 1, 0.5);

    pass_entry = gtk_entry_new();
    gtk_table_attach (GTK_TABLE(table), pass_entry, 1, 2, 0, 1,
                      GTK_EXPAND|GTK_SHRINK|GTK_FILL, 0, 0, 0);
    gtk_entry_set_visibility (GTK_ENTRY(pass_entry), FALSE);
    gtk_widget_grab_focus (pass_entry);


    confirm_box = gtk_hbutton_box_new ();
    gtk_button_box_set_layout (GTK_BUTTON_BOX(confirm_box), GTK_BUTTONBOX_END);
    gtk_button_box_set_spacing (GTK_BUTTON_BOX(confirm_box), 5);

    ok_button = gtk_button_new_with_label (_("OK"));
    GTK_WIDGET_SET_FLAGS (ok_button, GTK_CAN_DEFAULT);
    gtk_box_pack_start (GTK_BOX(confirm_box), ok_button, TRUE, TRUE, 0);

    cancel_button = gtk_button_new_with_label (_("Cancel"));
    GTK_WIDGET_SET_FLAGS (cancel_button, GTK_CAN_DEFAULT);
    gtk_box_pack_start(GTK_BOX(confirm_box), cancel_button, TRUE, TRUE, 0);

    gtk_box_pack_end(GTK_BOX(vbox), confirm_box, FALSE, FALSE, 0);
    gtk_widget_grab_default (ok_button);

    gtk_signal_connect(GTK_OBJECT(ok_button), "clicked",
                       GTK_SIGNAL_FUNC(passphrase_ok_cb), NULL);
    gtk_signal_connect(GTK_OBJECT(pass_entry), "activate",
                       GTK_SIGNAL_FUNC(passphrase_ok_cb), NULL);
    gtk_signal_connect(GTK_OBJECT(cancel_button), "clicked",
                       GTK_SIGNAL_FUNC(passphrase_cancel_cb), NULL);

    if (grab_all)
        gtk_object_set (GTK_OBJECT(window), "type", GTK_WINDOW_POPUP, NULL);
    gtk_window_set_position (GTK_WINDOW(window), GTK_WIN_POS_CENTER);
    if (grab_all)   
        gtk_window_set_policy (GTK_WINDOW(window), FALSE, FALSE, TRUE);
    
    gtk_widget_show_all(window);

    /* don't use XIM on entering passphrase */
    gtkut_editable_disable_im(GTK_EDITABLE(pass_entry));

    if (grab_all) {
        XGrabServer(GDK_DISPLAY());
        if ( gdk_pointer_grab ( window->window, TRUE, 0,
                                NULL, NULL, GDK_CURRENT_TIME)) {
            XUngrabServer ( GDK_DISPLAY() );
            g_warning ("OOPS: Could not grab mouse\n");
            gtk_widget_destroy (window);
            return NULL;
        }
        if ( gdk_keyboard_grab( window->window, FALSE, GDK_CURRENT_TIME )) {
            gdk_pointer_ungrab (GDK_CURRENT_TIME);
            XUngrabServer ( GDK_DISPLAY() );
            g_warning ("OOPS: Could not grab keyboard\n");
            gtk_widget_destroy (window);
            return NULL;
        }
    }

    gtk_main();

    if (grab_all) {
        XUngrabServer (GDK_DISPLAY());
        gdk_pointer_ungrab (GDK_CURRENT_TIME);
        gdk_keyboard_ungrab (GDK_CURRENT_TIME);
        gdk_flush();
    }

    manage_window_focus_out(window, NULL, NULL);

    if (pass_ack) {
        the_passphrase = gtk_entry_get_text(GTK_ENTRY(pass_entry));
        if (the_passphrase) /* Hmmm: Do we really need this? */
            the_passphrase = g_strdup (the_passphrase);
    }
    gtk_widget_destroy (window);

    return the_passphrase;
}
Exemplo n.º 12
0
void
compzillaWindow::SendMouseEvent (int eventType, nsIDOMMouseEvent *mouseEv, bool isScroll)
{
    DOMTimeStamp timestamp;
    PRUint16 button;
    int x, y;
    int x_root, y_root;
    PRBool ctrl, shift, alt, meta;
    int state = 0;

    mouseEv->GetTimeStamp (&timestamp);
    if (!timestamp) {
        timestamp = gtk_get_current_event_time (); // CurrentTime;
    }

    mouseEv->GetScreenX (&x_root);
    mouseEv->GetScreenY (&y_root);
    mouseEv->GetClientX (&x);
    mouseEv->GetClientY (&y);

#if USE_IFRAME
    nsIDOMEventTarget *target;
    mouseEv->GetTarget (&target);
    TranslateClientXYToWindow (&x, &y, target);
#else
    /*
     * Use the cached Xwindow properties.  These may be incorrect due to a bug
     * we have where the window isn't moved after initially being shown.
     */
    x -= mAttr.x;
    y -= mAttr.y;
#endif

    mouseEv->GetButton (&button);

    if (isScroll) {
        /* 
         * For button down/up GetDetail is the number of clicks.  For
         * DOMMouseScroll, it's the scroll amount as +3/-3.
         */
        PRInt32 evDetail = 0;
        mouseEv->GetDetail (&evDetail);

        if (evDetail < 0) {
            button = 3; // Turns into button 4
        } else if (evDetail > 0) {
            button = 4; // Turns into button 5
        }
    }

    mouseEv->GetCtrlKey (&ctrl);
    mouseEv->GetShiftKey (&shift);
    mouseEv->GetAltKey (&alt);
    mouseEv->GetMetaKey (&meta);

    if (ctrl) {
        state |= ControlMask;
    }
    if (shift) {
        state |= ShiftMask;
    }
    if (alt) {
        state |= Mod1Mask;
    }
    if (meta) {
        state |= Mod2Mask;
    }

    Window destChild = GetSubwindowAtPoint (&x, &y);

    if (destChild != mLastEntered && (eventType != EnterNotify)) {
        if (mLastEntered) {
            XEvent xev = { 0 };
            xev.xcrossing.type = LeaveNotify;
            xev.xcrossing.serial = 0;
            xev.xcrossing.display = mDisplay;
            xev.xcrossing.window = mLastEntered;
            xev.xcrossing.root = mAttr.root;
            xev.xcrossing.time = timestamp;
            xev.xcrossing.state = state;
            xev.xcrossing.x = x;
            xev.xcrossing.y = y;
            xev.xcrossing.x_root = x_root;
            xev.xcrossing.y_root = y_root;
            xev.xcrossing.same_screen = True;

            XSendEvent (mDisplay, mLastEntered, True, LeaveWindowMask, &xev);
        }
        
        mLastEntered = destChild;
        SendMouseEvent (EnterNotify, mouseEv);
    }

    // Build up the XEvent we will send
    XEvent xev = { 0 };
    xev.xany.type = eventType;

    switch (eventType) {
    case ButtonPress:
    case ButtonRelease:
        xev.xbutton.display = mDisplay;
        xev.xbutton.window = destChild;
	//xev.xbutton.window = mWindow;
        //xev.xbutton.subwindow = destChild;
	xev.xbutton.root = mAttr.root;
	xev.xbutton.time = timestamp;
	xev.xbutton.state = eventType == ButtonRelease ? Button1Mask << button : 0;
	xev.xbutton.button = button + 1; // DOM buttons start at 0
	xev.xbutton.x = x;
	xev.xbutton.y = y;
	xev.xbutton.x_root = x_root;
	xev.xbutton.y_root = y_root;
	xev.xbutton.same_screen = True;
	break;
    case MotionNotify:
        xev.xmotion.display = mDisplay;
        xev.xmotion.window = destChild;
	//xev.xmotion.window = mWindow;
        //xev.xmotion.subwindow = destChild;
	xev.xmotion.root = mAttr.root;
	xev.xmotion.time = timestamp;
	xev.xmotion.state = state;
	xev.xmotion.x = x;
	xev.xmotion.y = y;
	xev.xmotion.x_root = x_root;
	xev.xmotion.y_root = y_root;
	xev.xmotion.same_screen = True;
	break;
    case EnterNotify:
    case LeaveNotify:
        xev.xcrossing.display = mDisplay;
        xev.xcrossing.window = destChild;
        //xev.xcrossing.window = mWindow;
        //xev.xcrossing.subwindow = destChild;
	xev.xcrossing.root = mAttr.root;
	xev.xcrossing.time = timestamp;
	xev.xcrossing.state = state;
	xev.xcrossing.x = x;
	xev.xcrossing.y = y;
	xev.xcrossing.x_root = x_root;
	xev.xcrossing.y_root = y_root;
	xev.xcrossing.same_screen = True;
	break;
    default:
        NS_NOTREACHED ("Unknown eventType");
	return;
    }

    // Figure out who to send to
    long xevMask;

    switch (eventType) {
    case ButtonPress:
	xevMask = ButtonPressMask;
	break;
    case ButtonRelease:
	xevMask = ButtonReleaseMask;
	break;
    case MotionNotify:
	xevMask = (PointerMotionMask | PointerMotionHintMask);
	if (button) {
            xevMask |= ButtonMotionMask;
            xevMask |= Button1MotionMask << button;
	}
	break;
    case EnterNotify:
	xevMask = EnterWindowMask;
	break;
    case LeaveNotify:
	xevMask = LeaveWindowMask;
	break;
    default:
        NS_NOTREACHED ("Unknown eventType");
	return;
    }

    SPEW_EVENT ("SendMouseEvent: win=%p, child=%p, x=%d, y=%d, state=%p, "
                "button=%u, timestamp=%d\n", 
                mWindow, destChild, x, y, state, button + 1, timestamp);

    if (eventType == ButtonPress) {
        gdk_pointer_ungrab (GDK_CURRENT_TIME);
        gdk_keyboard_ungrab (GDK_CURRENT_TIME);

        // Start a passive grab.  The window's app can override this.
        XGrabButton (mDisplay, AnyButton, AnyModifier, 
                     mWindow, True, 
                     (ButtonPressMask |
                      ButtonReleaseMask |
                      EnterWindowMask | 
                      LeaveWindowMask |
                      PointerMotionMask),
                     GrabModeAsync, 
                     GrabModeAsync, 
                     None,
                     None);

        XGrabKey (mDisplay, AnyKey, AnyModifier, 
                  mWindow, True, 
                  GrabModeAsync, 
                  GrabModeAsync);
    }

    XSendEvent (mDisplay, destChild, True, xevMask, &xev);

    // Stop processing event
    if (eventType != MotionNotify) {
        mouseEv->StopPropagation ();
        mouseEv->PreventDefault ();
    }
}
Exemplo n.º 13
0
static void
gtk_color_combo_update (GtkWidget * widget, GtkColorCombo * color_combo)
{
  gint i,j;
  gint focus_row = -1, focus_col = -1;
  gint new_row = -1, new_col = -1;
  gint new_selection=FALSE;
  gint row,column;

  row=color_combo->row;
  column=color_combo->column;

  for(i=0 ; i<color_combo->nrows; i++)
    for(j=0; j<color_combo->ncols; j++){    
      if(GTK_WIDGET_HAS_FOCUS(color_combo->button[i][j])){
            focus_row=i;
            focus_col=j;
      }
      if(color_combo->button[i][j]->state==GTK_STATE_ACTIVE){
        if(i != row || j != column){
            new_selection=TRUE;
            new_row=i;
            new_col=j;
        }
      }
    }

  if(!new_selection && focus_row >= 0 && focus_col >= 0){
     if(focus_row != row && focus_col != column){
       new_selection = TRUE;
       new_row=focus_row;
       new_col=focus_col;
     }
  }

  if(new_selection){
      if(row >= 0 && column >= 0){
          GTK_BUTTON(color_combo->button[row][column])->button_down=FALSE; 
          GTK_TOGGLE_BUTTON(color_combo->button[row][column])->active=FALSE;
          gtk_widget_set_state(color_combo->button[row][column], GTK_STATE_NORMAL);
          gtk_widget_queue_draw(color_combo->button[row][column]);
      }
      color_combo->row=new_row;
      color_combo->column=new_col;
      
      gtk_signal_emit (GTK_OBJECT(color_combo), color_combo_signals[CHANGED],
                  new_row * color_combo->ncols + new_col,
                  color_combo->color_name[new_row*color_combo->ncols+new_col]);

  }

  if(!new_selection && row >= 0 && column >= 0){
          GTK_BUTTON(color_combo->button[row][column])->button_down=TRUE;     
          GTK_TOGGLE_BUTTON(color_combo->button[row][column])->active=TRUE;
          gtk_widget_set_state(color_combo->button[row][column], GTK_STATE_ACTIVE);
          gtk_widget_queue_draw(color_combo->button[row][column]);

          gtk_signal_emit (GTK_OBJECT(color_combo), 
                           color_combo_signals[CHANGED],
                           row * color_combo->ncols + column,
                        color_combo->color_name[row*color_combo->ncols+column]);

  }



  gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(GTK_COMBO_BOX(color_combo)->arrow), FALSE);

  gtk_grab_remove(GTK_COMBO_BOX(color_combo)->popwin);
  gdk_pointer_ungrab(GDK_CURRENT_TIME);
  gtk_widget_hide(GTK_COMBO_BOX(color_combo)->popwin);
  return;
}