summaryrefslogtreecommitdiff
path: root/gtk
diff options
context:
space:
mode:
authorOwen Taylor <otaylor@redhat.com>2000-07-03 19:00:23 +0000
committerOwen Taylor <otaylor@src.gnome.org>2000-07-03 19:00:23 +0000
commit01212ce1709bc85d03576969c45397cf20c3dcc1 (patch)
tree15c04ebfb74db73f1e1030ef42adf6b0eb7dea96 /gtk
parent0c2240ba379ceb5f3773171cc80a8c640f34e839 (diff)
downloadgtk+-01212ce1709bc85d03576969c45397cf20c3dcc1.tar.gz
Ignore calls with <= width or height.
Mon Jul 3 14:24:16 2000 Owen Taylor <otaylor@redhat.com> * gtk/gtkwidget.c (gtk_widget_draw): Ignore calls with <= width or height. * gtk/gtktable.c (gtk_table_attach): Fix missed merge from 1.2 for parent/child states. * gdk/gdkgc.c (gdk_gc_set_rgb_fg/bg_color): Fix a couple of typos. * gdk/gdkevents.[ch]: Remove press/xtilt/ytilt fields of event structures, replace with a generic axes field. Replace deviceid/source with GdkDevice *device. * gdk/gdkevents.[ch] (gdk_event_get_axis): Add function to extract particular axis use value from event. (Also can be used for normal X/Y.) * gdk/gdkinput.h gdk/x11/gdkinput*: Major revision; allow for arbitrary number of axes, namespace everything as gdk_device_*. Replace guint32 deviceid with GdkDevice * everywhere. * gdk/x11/{gdkmain-x11.c,gdkevent-x11.c,gdkinput*}: Get rid of the gdk_input_vtable setup if favor of simply defining the functions in gdkinput-none/gxi/xfree.c in a similar fashion to the way that the port structure is done. * gtk/gtkdnd.c: Fix fields of synthesized button press event for new event structures. * gtk/gtkinputdialog.c gtk/testinput.c: Revise to match new device interfaces.
Diffstat (limited to 'gtk')
-rw-r--r--gtk/gtkdnd.c7
-rw-r--r--gtk/gtkinputdialog.c128
-rw-r--r--gtk/gtkinputdialog.h6
-rw-r--r--gtk/gtktable.c17
-rw-r--r--gtk/gtkwidget.c7
-rw-r--r--gtk/testinput.c120
6 files changed, 129 insertions, 156 deletions
diff --git a/gtk/gtkdnd.c b/gtk/gtkdnd.c
index 5f21feff8f..d3e0925205 100644
--- a/gtk/gtkdnd.c
+++ b/gtk/gtkdnd.c
@@ -2716,13 +2716,10 @@ gtk_drag_end (GtkDragSourceInfo *info, guint32 time)
send_event.button.time = time;
send_event.button.x = 0;
send_event.button.y = 0;
- send_event.button.pressure = 0.;
- send_event.button.xtilt = 0.;
- send_event.button.ytilt = 0.;
+ send_event.button.axes = NULL;
send_event.button.state = 0;
send_event.button.button = info->button;
- send_event.button.source = GDK_SOURCE_PEN;
- send_event.button.deviceid = GDK_CORE_POINTER;
+ send_event.button.device = gdk_core_pointer;
send_event.button.x_root = 0;
send_event.button.y_root = 0;
diff --git a/gtk/gtkinputdialog.c b/gtk/gtkinputdialog.c
index aca1170558..6e6836295f 100644
--- a/gtk/gtkinputdialog.c
+++ b/gtk/gtkinputdialog.c
@@ -77,45 +77,32 @@ enum
/* Forward declarations */
-static void gtk_input_dialog_class_init (GtkInputDialogClass *klass);
-static void gtk_input_dialog_init (GtkInputDialog *inputd);
-static GdkDeviceInfo *gtk_input_dialog_get_device_info(guint32 deviceid);
-static void gtk_input_dialog_set_device(GtkWidget *widget, gpointer data);
-static void gtk_input_dialog_set_mapping_mode(GtkWidget *w,
- gpointer data);
-static void gtk_input_dialog_set_axis(GtkWidget *widget, gpointer data);
-static void gtk_input_dialog_fill_axes (GtkInputDialog *inputd,
- GdkDeviceInfo *info);
-static void gtk_input_dialog_set_key (GtkInputKeyInfo *key,
- guint keyval,
- GdkModifierType modifiers);
-static gint gtk_input_dialog_key_press (GtkWidget *widget,
- GdkEventKey *event,
- GtkInputKeyInfo *key);
-static void gtk_input_dialog_clear_key (GtkWidget *widget,
- GtkInputKeyInfo *key);
-static void gtk_input_dialog_destroy_key (GtkWidget *widget,
- GtkInputKeyInfo *key);
-static void gtk_input_dialog_fill_keys (GtkInputDialog *inputd,
- GdkDeviceInfo *info);
+static void gtk_input_dialog_class_init (GtkInputDialogClass *klass);
+static void gtk_input_dialog_init (GtkInputDialog *inputd);
+static void gtk_input_dialog_set_device (GtkWidget *widget,
+ gpointer data);
+static void gtk_input_dialog_set_mapping_mode (GtkWidget *w,
+ gpointer data);
+static void gtk_input_dialog_set_axis (GtkWidget *widget,
+ gpointer data);
+static void gtk_input_dialog_fill_axes (GtkInputDialog *inputd,
+ GdkDevice *info);
+static void gtk_input_dialog_set_key (GtkInputKeyInfo *key,
+ guint keyval,
+ GdkModifierType modifiers);
+static gint gtk_input_dialog_key_press (GtkWidget *widget,
+ GdkEventKey *event,
+ GtkInputKeyInfo *key);
+static void gtk_input_dialog_clear_key (GtkWidget *widget,
+ GtkInputKeyInfo *key);
+static void gtk_input_dialog_destroy_key (GtkWidget *widget,
+ GtkInputKeyInfo *key);
+static void gtk_input_dialog_fill_keys (GtkInputDialog *inputd,
+ GdkDevice *info);
static GtkObjectClass *parent_class = NULL;
static guint input_dialog_signals[LAST_SIGNAL] = { 0 };
-static GdkDeviceInfo *
-gtk_input_dialog_get_device_info(guint32 deviceid)
-{
- GList *tmp_list = gdk_input_list_devices();
- while (tmp_list)
- {
- if (((GdkDeviceInfo *)tmp_list->data)->deviceid == deviceid)
- return (GdkDeviceInfo *)tmp_list->data;
- tmp_list = tmp_list->next;
- }
-
- return NULL;
-}
-
GtkType
gtk_input_dialog_get_type (void)
{
@@ -156,16 +143,16 @@ gtk_input_dialog_class_init (GtkInputDialogClass *klass)
GTK_RUN_LAST,
GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkInputDialogClass, enable_device),
- gtk_marshal_NONE__INT,
- GTK_TYPE_NONE, 1, GTK_TYPE_INT);
+ gtk_marshal_NONE__POINTER,
+ GTK_TYPE_NONE, 1, GTK_TYPE_POINTER);
input_dialog_signals[DISABLE_DEVICE] =
gtk_signal_new ("disable_device",
GTK_RUN_LAST,
GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkInputDialogClass, disable_device),
- gtk_marshal_NONE__INT,
- GTK_TYPE_NONE, 1, GTK_TYPE_INT);
+ gtk_marshal_NONE__POINTER,
+ GTK_TYPE_NONE, 1, GTK_TYPE_POINTER);
gtk_object_class_add_signals (object_class, input_dialog_signals,
LAST_SIGNAL);
@@ -191,7 +178,7 @@ gtk_input_dialog_init (GtkInputDialog *inputd)
GList *tmp_list;
GList *device_info;
- device_info = gdk_input_list_devices();
+ device_info = gdk_devices_list ();
/* shell and main vbox */
@@ -215,8 +202,8 @@ gtk_input_dialog_init (GtkInputDialog *inputd)
device_menu = gtk_menu_new ();
for (tmp_list = device_info; tmp_list; tmp_list = tmp_list->next) {
- GdkDeviceInfo *info = (GdkDeviceInfo *)(tmp_list->data);
- if (info->deviceid != GDK_CORE_POINTER)
+ GdkDevice *info = (GdkDevice *)(tmp_list->data);
+ if (info != gdk_core_pointer)
{
menuitem = gtk_menu_item_new_with_label(info->name);
@@ -225,7 +212,7 @@ gtk_input_dialog_init (GtkInputDialog *inputd)
gtk_object_set_user_data (GTK_OBJECT (menuitem), inputd);
gtk_signal_connect (GTK_OBJECT (menuitem), "activate",
(GtkSignalFunc) gtk_input_dialog_set_device,
- GUINT_TO_POINTER(info->deviceid));
+ info);
}
}
@@ -333,8 +320,7 @@ gtk_input_dialog_init (GtkInputDialog *inputd)
/* ...set_device expects to get input dialog from widget user data */
gtk_object_set_user_data (GTK_OBJECT (inputd), inputd);
- gtk_input_dialog_set_device(GTK_WIDGET(inputd),
- GUINT_TO_POINTER (((GdkDeviceInfo *)device_info->data)->deviceid));
+ gtk_input_dialog_set_device (GTK_WIDGET(inputd), device_info->data);
}
@@ -374,44 +360,42 @@ gtk_input_dialog_new (void)
static void
gtk_input_dialog_set_device(GtkWidget *widget, gpointer data)
{
- guint32 deviceid = GPOINTER_TO_UINT(data);
- GdkDeviceInfo *info;
+ GdkDevice *device = data;
GtkInputDialog *inputd = GTK_INPUT_DIALOG(
gtk_object_get_user_data(GTK_OBJECT(widget)));
- inputd->current_device = deviceid;
- info = gtk_input_dialog_get_device_info (deviceid);
+ inputd->current_device = device;
- gtk_input_dialog_fill_axes(inputd, info);
- gtk_input_dialog_fill_keys(inputd, info);
+ gtk_input_dialog_fill_axes(inputd, device);
+ gtk_input_dialog_fill_keys(inputd, device);
gtk_option_menu_set_history(GTK_OPTION_MENU(inputd->mode_optionmenu),
- info->mode);
+ device->mode);
}
static void
-gtk_input_dialog_set_mapping_mode(GtkWidget *w,
- gpointer data)
+gtk_input_dialog_set_mapping_mode (GtkWidget *w,
+ gpointer data)
{
GtkInputDialog *inputd = GTK_INPUT_DIALOG(
gtk_object_get_user_data(GTK_OBJECT(w)));
- GdkDeviceInfo *info = gtk_input_dialog_get_device_info (inputd->current_device);
+ GdkDevice *info = inputd->current_device;
GdkInputMode old_mode = info->mode;
GdkInputMode mode = GPOINTER_TO_INT (data);
if (mode != old_mode)
{
- if (gdk_input_set_mode(inputd->current_device, mode))
+ if (gdk_device_set_mode (inputd->current_device, mode))
{
if (mode == GDK_MODE_DISABLED)
gtk_signal_emit (GTK_OBJECT (inputd),
input_dialog_signals[DISABLE_DEVICE],
- info->deviceid);
+ info);
else
gtk_signal_emit (GTK_OBJECT (inputd),
input_dialog_signals[ENABLE_DEVICE],
- info->deviceid);
+ info);
}
else
gtk_option_menu_set_history (GTK_OPTION_MENU (inputd->mode_optionmenu),
@@ -428,7 +412,7 @@ gtk_input_dialog_set_axis(GtkWidget *widget, gpointer data)
GdkAxisUse old_use;
GdkAxisUse *new_axes;
GtkInputDialog *inputd = GTK_INPUT_DIALOG (gtk_object_get_user_data (GTK_OBJECT (widget)));
- GdkDeviceInfo *info = gtk_input_dialog_get_device_info (inputd->current_device);
+ GdkDevice *info = inputd->current_device;
gint axis = (GPOINTER_TO_INT(data) >> 16) - 1;
gint old_axis;
@@ -438,13 +422,13 @@ gtk_input_dialog_set_axis(GtkWidget *widget, gpointer data)
old_axis = -1;
for (i=0;i<info->num_axes;i++)
{
- new_axes[i] = info->axes[i];
- if (info->axes[i] == use)
+ new_axes[i] = info->axes[i].use;
+ if (info->axes[i].use == use)
old_axis = i;
}
if (axis != -1)
- old_use = info->axes[axis];
+ old_use = info->axes[axis].use;
else
old_use = GDK_AXIS_IGNORE;
@@ -462,10 +446,10 @@ gtk_input_dialog_set_axis(GtkWidget *widget, gpointer data)
else
{
if (axis != -1)
- new_axes[axis] = use;
+ gdk_device_set_axis_use (info, axis, use);
if (old_axis != -1)
- new_axes[old_axis] = old_use;
+ gdk_device_set_axis_use (info, old_axis, old_use);
if (old_use != GDK_AXIS_IGNORE)
{
@@ -473,14 +457,13 @@ gtk_input_dialog_set_axis(GtkWidget *widget, gpointer data)
GTK_OPTION_MENU (inputd->axis_items[old_use]),
old_axis + 1);
}
- gdk_input_set_axes (info->deviceid, new_axes);
}
g_free (new_axes);
}
static void
-gtk_input_dialog_fill_axes(GtkInputDialog *inputd, GdkDeviceInfo *info)
+gtk_input_dialog_fill_axes(GtkInputDialog *inputd, GdkDevice *info)
{
static const char *axis_use_strings[GDK_AXIS_LAST] =
{
@@ -489,7 +472,8 @@ gtk_input_dialog_fill_axes(GtkInputDialog *inputd, GdkDeviceInfo *info)
N_("Y"),
N_("Pressure"),
N_("X Tilt"),
- N_("Y Tilt")
+ N_("Y Tilt"),
+ N_("Wheel")
};
int i,j;
@@ -550,7 +534,7 @@ gtk_input_dialog_fill_axes(GtkInputDialog *inputd, GdkDeviceInfo *info)
gtk_widget_show (option_menu);
gtk_option_menu_set_menu (GTK_OPTION_MENU (option_menu), menu);
for (j = 0; j < info->num_axes; j++)
- if (info->axes[j] == (GdkAxisUse) i)
+ if (info->axes[j].use == (GdkAxisUse) i)
{
gtk_option_menu_set_history (GTK_OPTION_MENU (option_menu), j+1);
break;
@@ -564,7 +548,7 @@ static void
gtk_input_dialog_clear_key (GtkWidget *widget, GtkInputKeyInfo *key)
{
gtk_entry_set_text (GTK_ENTRY(key->entry), _("(disabled)"));
- gdk_input_set_key (key->inputd->current_device, key->index, 0, 0);
+ gdk_device_set_key (key->inputd->current_device, key->index, 0, 0);
}
static void
@@ -609,8 +593,8 @@ gtk_input_dialog_key_press (GtkWidget *widget,
GtkInputKeyInfo *key)
{
gtk_input_dialog_set_key (key, event->keyval, event->state & 0xFF);
- gdk_input_set_key (key->inputd->current_device, key->index,
- event->keyval, event->state & 0xFF);
+ gdk_device_set_key (key->inputd->current_device, key->index,
+ event->keyval, event->state & 0xFF);
gtk_signal_emit_stop_by_name (GTK_OBJECT(widget), "key_press_event");
@@ -624,7 +608,7 @@ gtk_input_dialog_destroy_key (GtkWidget *widget, GtkInputKeyInfo *key)
}
static void
-gtk_input_dialog_fill_keys(GtkInputDialog *inputd, GdkDeviceInfo *info)
+gtk_input_dialog_fill_keys(GtkInputDialog *inputd, GdkDevice *info)
{
int i;
GtkWidget *label;
diff --git a/gtk/gtkinputdialog.h b/gtk/gtkinputdialog.h
index b7d417b052..0d5ea00e23 100644
--- a/gtk/gtkinputdialog.h
+++ b/gtk/gtkinputdialog.h
@@ -60,7 +60,7 @@ struct _GtkInputDialog
GtkWidget *save_button;
GtkWidget *axis_items[GDK_AXIS_LAST];
- guint32 current_device;
+ GdkDevice *current_device;
GtkWidget *keys_list;
GtkWidget *keys_listbox;
@@ -71,9 +71,9 @@ struct _GtkInputDialogClass
GtkDialogClass parent_class;
void (* enable_device) (GtkInputDialog *inputd,
- guint32 devid);
+ GdkDevice *device);
void (* disable_device) (GtkInputDialog *inputd,
- guint32 devid);
+ GdkDevice *device);
};
diff --git a/gtk/gtktable.c b/gtk/gtktable.c
index 51cda7a228..ef41d085d5 100644
--- a/gtk/gtktable.c
+++ b/gtk/gtktable.c
@@ -538,19 +538,16 @@ gtk_table_attach (GtkTable *table,
gtk_widget_set_parent (child, GTK_WIDGET (table));
- if (GTK_WIDGET_VISIBLE (GTK_WIDGET (table)))
+ if (GTK_WIDGET_REALIZED (child->parent))
+ gtk_widget_realize (child);
+
+ if (GTK_WIDGET_VISIBLE (child->parent) && GTK_WIDGET_VISIBLE (child))
{
- if (GTK_WIDGET_REALIZED (GTK_WIDGET (table)) &&
- !GTK_WIDGET_REALIZED (child))
- gtk_widget_realize (child);
-
- if (GTK_WIDGET_MAPPED (GTK_WIDGET (table)) &&
- !GTK_WIDGET_MAPPED (child))
+ if (GTK_WIDGET_MAPPED (child->parent))
gtk_widget_map (child);
+
+ gtk_widget_queue_resize (child);
}
-
- if (GTK_WIDGET_VISIBLE (child) && GTK_WIDGET_VISIBLE (table))
- gtk_widget_queue_resize (child);
}
void
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 65735a6b1a..257227a5b3 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -1848,7 +1848,12 @@ gtk_widget_draw (GtkWidget *widget,
if (GTK_WIDGET_DRAWABLE (widget))
{
- if (!area)
+ if (area)
+ {
+ if (area->width <= 0 || area->height <= 0)
+ return;
+ }
+ else
{
if (GTK_WIDGET_NO_WINDOW (widget))
{
diff --git a/gtk/testinput.c b/gtk/testinput.c
index b2e9e17df8..36cb6fc93b 100644
--- a/gtk/testinput.c
+++ b/gtk/testinput.c
@@ -33,44 +33,19 @@ static GdkPixmap *pixmap = NULL;
/* Information about cursor */
-static gint need_cursor = FALSE;
static gint cursor_proximity = TRUE;
static gdouble cursor_x;
static gdouble cursor_y;
/* Unique ID of current device */
-static guint32 current_device = GDK_CORE_POINTER;
-
-/* Check to see if we need to draw a cursor for current device */
-static void
-check_cursor (void)
-{
- GList *tmp_list;
-
- /* gdk_input_list_devices returns an internal list, so we shouldn't
- free it afterwards */
- tmp_list = gdk_input_list_devices();
-
- while (tmp_list)
- {
- GdkDeviceInfo *info = (GdkDeviceInfo *)tmp_list->data;
-
- if (info->deviceid == current_device)
- {
- need_cursor = !info->has_cursor;
- break;
- }
-
- tmp_list = tmp_list->next;
- }
-}
+static GdkDevice *current_device;
/* Erase the old cursor, and/or draw a new one, if necessary */
static void
update_cursor (GtkWidget *widget, gdouble x, gdouble y)
{
static gint cursor_present = 0;
- gint state = need_cursor && cursor_proximity;
+ gint state = !current_device->has_cursor && cursor_proximity;
if (pixmap != NULL)
{
@@ -170,21 +145,36 @@ draw_brush (GtkWidget *widget, GdkInputSource source,
static guint32 motion_time;
-static gint
-button_press_event (GtkWidget *widget, GdkEventButton *event)
+static void
+print_axes (GdkDevice *device, gdouble *axes)
{
- if (event->deviceid != current_device)
+ int i;
+
+ if (axes)
{
- current_device = event->deviceid;
- check_cursor ();
+ g_print ("%s ", device->name);
+
+ for (i=0; i<device->num_axes; i++)
+ g_print ("%g ", axes[i]);
+
+ g_print ("\n");
}
+}
+static gint
+button_press_event (GtkWidget *widget, GdkEventButton *event)
+{
+ current_device = event->device;
cursor_proximity = TRUE;
if (event->button == 1 && pixmap != NULL)
{
- draw_brush (widget, event->source, event->x, event->y,
- event->pressure);
+ gdouble pressure = 0.5;
+
+ print_axes (event->device, event->axes);
+ gdk_event_get_axis ((GdkEvent *)event, GDK_AXIS_PRESSURE, &pressure);
+ draw_brush (widget, event->device->source, event->x, event->y, pressure);
+
motion_time = event->time;
}
@@ -207,47 +197,47 @@ key_press_event (GtkWidget *widget, GdkEventKey *event)
static gint
motion_notify_event (GtkWidget *widget, GdkEventMotion *event)
{
- GdkTimeCoord *coords;
- int nevents;
+ GdkTimeCoord **events;
+ int n_events;
int i;
- if (event->deviceid != current_device)
- {
- current_device = event->deviceid;
- check_cursor ();
- }
-
+ current_device = event->device;
cursor_proximity = TRUE;
if (event->state & GDK_BUTTON1_MASK && pixmap != NULL)
{
- coords = gdk_input_motion_events (event->window, event->deviceid,
- motion_time, event->time,
- &nevents);
- motion_time = event->time;
- if (coords)
+ if (gdk_device_get_history (event->device, event->window,
+ motion_time, event->time,
+ &events, &n_events))
{
- for (i=0; i<nevents; i++)
- draw_brush (widget, event->source, coords[i].x, coords[i].y,
- coords[i].pressure);
- g_free (coords);
+ for (i=0; i<n_events; i++)
+ {
+ double x = 0, y = 0, pressure = 0.5;
+
+ gdk_device_get_axis (event->device, events[i]->axes, GDK_AXIS_X, &x);
+ gdk_device_get_axis (event->device, events[i]->axes, GDK_AXIS_Y, &y);
+ gdk_device_get_axis (event->device, events[i]->axes, GDK_AXIS_PRESSURE, &pressure);
+ draw_brush (widget, event->device->source, x, y, pressure);
+
+ print_axes (event->device, events[i]->axes);
+ }
+ gdk_device_free_history (events, n_events);
}
else
{
- if (event->is_hint)
- gdk_input_window_get_pointer (event->window, event->deviceid,
- NULL, NULL, NULL, NULL, NULL, NULL);
- draw_brush (widget, event->source, event->x, event->y,
- event->pressure);
+ double pressure = 0.5;
+
+ gdk_event_get_axis ((GdkEvent *)event, GDK_AXIS_PRESSURE, &pressure);
+
+ draw_brush (widget, event->device->source, event->x, event->y, pressure);
}
- }
- else
- {
- gdk_input_window_get_pointer (event->window, event->deviceid,
- &event->x, &event->y,
- NULL, NULL, NULL, NULL);
+ motion_time = event->time;
}
+ if (event->is_hint)
+ gdk_device_get_state (event->device, event->window, NULL, NULL);
+
+ print_axes (event->device, event->axes);
update_cursor (widget, event->x, event->y);
return TRUE;
@@ -293,10 +283,8 @@ create_input_dialog (void)
"clicked",
(GtkSignalFunc)gtk_widget_hide,
GTK_OBJECT(inputd));
- gtk_widget_hide ( GTK_INPUT_DIALOG(inputd)->save_button);
+ gtk_widget_hide (GTK_INPUT_DIALOG(inputd)->save_button);
- gtk_signal_connect (GTK_OBJECT(inputd), "enable_device",
- (GtkSignalFunc)check_cursor, NULL);
gtk_widget_show (inputd);
}
else
@@ -325,6 +313,8 @@ main (int argc, char *argv[])
gtk_init (&argc, &argv);
+ current_device = gdk_core_pointer;
+
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_widget_set_name (window, "Test Input");