annotate plugins/gestures/stroke-draw.c @ 10958:90d22e1b68df

[gaim-migrate @ 12759] This is part of Levi's patch that I'd left off. I was considering removing gaim_conv_chat_remove_users because it isn't used anywhere, but I figured it was better to leave it. committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Wed, 01 Jun 2005 00:26:40 +0000
parents 364a2ef907ae
children 2c7e79b6d7b2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4390
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1 /*
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2 GNOME stroke implementation
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
3 Copyright (c) 2000, 2001 Dan Nicolaescu
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
4 See the file COPYING for distribution information.
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
5 */
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
6
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
7 #include "config.h"
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
8
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
9 #include <unistd.h>
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
10 #include <stdlib.h>
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
11 #include <stdio.h>
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
12 #include <glib.h>
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
13 #include <gtk/gtk.h>
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
14
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
15 #include <gdk/gdkx.h>
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
16 #include "gstroke.h"
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
17 #include "gstroke-internal.h"
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
18
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
19 #include <X11/Xlib.h>
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
20 #include <X11/Xutil.h>
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
21
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
22
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
23 static void gstroke_invisible_window_init (GtkWidget *widget);
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
24 /*FIXME: Maybe these should be put in a structure, and not static...*/
4529
f630a793b9d4 [gaim-migrate @ 4807]
Christian Hammond <chipx86@chipx86.com>
parents: 4432
diff changeset
25 static Display * gstroke_disp = NULL;
4390
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
26 static Window gstroke_window;
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
27 static GC gstroke_gc;
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
28 static int mouse_button = 2;
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
29 static gboolean draw_strokes = FALSE;
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
30
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
31 #define GSTROKE_TIMEOUT_DURATION 10
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
32
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
33 #define GSTROKE_SIGNALS "gstroke_signals"
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
34
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
35 struct gstroke_func_and_data {
9855
b23e6f9c4d2e [gaim-migrate @ 10734]
Mark Doliner <mark@kingant.net>
parents: 9843
diff changeset
36 void (*func)(GtkWidget *, void *);
b23e6f9c4d2e [gaim-migrate @ 10734]
Mark Doliner <mark@kingant.net>
parents: 9843
diff changeset
37 gpointer data;
4390
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
38 };
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
39
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
40
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
41 /*FIXME: maybe it's better to just make 2 static variables, not a
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
42 structure */
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
43 struct mouse_position {
9855
b23e6f9c4d2e [gaim-migrate @ 10734]
Mark Doliner <mark@kingant.net>
parents: 9843
diff changeset
44 struct s_point last_point;
b23e6f9c4d2e [gaim-migrate @ 10734]
Mark Doliner <mark@kingant.net>
parents: 9843
diff changeset
45 gboolean invalid;
4390
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
46 };
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
47
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
48
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
49 static struct mouse_position last_mouse_position;
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
50 static guint timer_id;
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
51
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
52 static void gstroke_execute (GtkWidget *widget, const gchar *name);
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
53
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
54 static void
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
55 record_stroke_segment (GtkWidget *widget)
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
56 {
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
57 gint x, y;
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
58 struct gstroke_metrics *metrics;
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
59
9843
19fd43d52d18 [gaim-migrate @ 10721]
Luke Schierer <lschiere@pidgin.im>
parents: 8555
diff changeset
60 g_return_if_fail( widget != NULL );
19fd43d52d18 [gaim-migrate @ 10721]
Luke Schierer <lschiere@pidgin.im>
parents: 8555
diff changeset
61
4390
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
62 gtk_widget_get_pointer (widget, &x, &y);
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
63
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
64 if (last_mouse_position.invalid)
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
65 last_mouse_position.invalid = FALSE;
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
66 else if (gstroke_draw_strokes())
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
67 {
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
68 #if 1
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
69 XDrawLine (gstroke_disp, gstroke_window, gstroke_gc,
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
70 last_mouse_position.last_point.x,
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
71 last_mouse_position.last_point.y,
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
72 x, y);
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
73 /* XFlush (gstroke_disp); */
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
74 #else
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
75 /* FIXME: this does not work. It will only work if we create a
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
76 corresponding GDK window for stroke_window and draw on
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
77 that... */
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
78 gdk_draw_line (widget->window, widget->style->fg_gc[GTK_STATE_NORMAL],
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
79 last_mouse_position.last_point.x,
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
80 last_mouse_position.last_point.y,
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
81 x,
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
82 y);
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
83 #endif
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
84 }
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
85
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
86 if (last_mouse_position.last_point.x != x
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
87 || last_mouse_position.last_point.y != y)
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
88 {
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
89 last_mouse_position.last_point.x = x;
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
90 last_mouse_position.last_point.y = y;
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
91 metrics = (struct gstroke_metrics *)g_object_get_data(G_OBJECT(widget),
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
92 GSTROKE_METRICS);
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
93 _gstroke_record (x, y, metrics);
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
94 }
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
95 }
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
96
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
97 static gint
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
98 gstroke_timeout (gpointer data)
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
99 {
9855
b23e6f9c4d2e [gaim-migrate @ 10734]
Mark Doliner <mark@kingant.net>
parents: 9843
diff changeset
100 GtkWidget *widget;
b23e6f9c4d2e [gaim-migrate @ 10734]
Mark Doliner <mark@kingant.net>
parents: 9843
diff changeset
101
b23e6f9c4d2e [gaim-migrate @ 10734]
Mark Doliner <mark@kingant.net>
parents: 9843
diff changeset
102 g_return_val_if_fail(data != NULL, FALSE);
4390
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
103
9855
b23e6f9c4d2e [gaim-migrate @ 10734]
Mark Doliner <mark@kingant.net>
parents: 9843
diff changeset
104 widget = GTK_WIDGET (data);
b23e6f9c4d2e [gaim-migrate @ 10734]
Mark Doliner <mark@kingant.net>
parents: 9843
diff changeset
105 record_stroke_segment (widget);
b23e6f9c4d2e [gaim-migrate @ 10734]
Mark Doliner <mark@kingant.net>
parents: 9843
diff changeset
106
b23e6f9c4d2e [gaim-migrate @ 10734]
Mark Doliner <mark@kingant.net>
parents: 9843
diff changeset
107 return TRUE;
4390
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
108 }
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
109
9843
19fd43d52d18 [gaim-migrate @ 10721]
Luke Schierer <lschiere@pidgin.im>
parents: 8555
diff changeset
110 static void gstroke_cancel(GdkEvent *event)
19fd43d52d18 [gaim-migrate @ 10721]
Luke Schierer <lschiere@pidgin.im>
parents: 8555
diff changeset
111 {
19fd43d52d18 [gaim-migrate @ 10721]
Luke Schierer <lschiere@pidgin.im>
parents: 8555
diff changeset
112 last_mouse_position.invalid = TRUE;
19fd43d52d18 [gaim-migrate @ 10721]
Luke Schierer <lschiere@pidgin.im>
parents: 8555
diff changeset
113
19fd43d52d18 [gaim-migrate @ 10721]
Luke Schierer <lschiere@pidgin.im>
parents: 8555
diff changeset
114 if (timer_id > 0)
19fd43d52d18 [gaim-migrate @ 10721]
Luke Schierer <lschiere@pidgin.im>
parents: 8555
diff changeset
115 g_source_remove (timer_id);
19fd43d52d18 [gaim-migrate @ 10721]
Luke Schierer <lschiere@pidgin.im>
parents: 8555
diff changeset
116
19fd43d52d18 [gaim-migrate @ 10721]
Luke Schierer <lschiere@pidgin.im>
parents: 8555
diff changeset
117 timer_id = 0;
19fd43d52d18 [gaim-migrate @ 10721]
Luke Schierer <lschiere@pidgin.im>
parents: 8555
diff changeset
118
19fd43d52d18 [gaim-migrate @ 10721]
Luke Schierer <lschiere@pidgin.im>
parents: 8555
diff changeset
119 if( event != NULL )
19fd43d52d18 [gaim-migrate @ 10721]
Luke Schierer <lschiere@pidgin.im>
parents: 8555
diff changeset
120 gdk_pointer_ungrab (event->button.time);
19fd43d52d18 [gaim-migrate @ 10721]
Luke Schierer <lschiere@pidgin.im>
parents: 8555
diff changeset
121
19fd43d52d18 [gaim-migrate @ 10721]
Luke Schierer <lschiere@pidgin.im>
parents: 8555
diff changeset
122
19fd43d52d18 [gaim-migrate @ 10721]
Luke Schierer <lschiere@pidgin.im>
parents: 8555
diff changeset
123 if (gstroke_draw_strokes() && gstroke_disp != NULL) {
19fd43d52d18 [gaim-migrate @ 10721]
Luke Schierer <lschiere@pidgin.im>
parents: 8555
diff changeset
124 /* get rid of the invisible stroke window */
19fd43d52d18 [gaim-migrate @ 10721]
Luke Schierer <lschiere@pidgin.im>
parents: 8555
diff changeset
125 XUnmapWindow (gstroke_disp, gstroke_window);
19fd43d52d18 [gaim-migrate @ 10721]
Luke Schierer <lschiere@pidgin.im>
parents: 8555
diff changeset
126 XFlush (gstroke_disp);
19fd43d52d18 [gaim-migrate @ 10721]
Luke Schierer <lschiere@pidgin.im>
parents: 8555
diff changeset
127 }
19fd43d52d18 [gaim-migrate @ 10721]
Luke Schierer <lschiere@pidgin.im>
parents: 8555
diff changeset
128
19fd43d52d18 [gaim-migrate @ 10721]
Luke Schierer <lschiere@pidgin.im>
parents: 8555
diff changeset
129 }
19fd43d52d18 [gaim-migrate @ 10721]
Luke Schierer <lschiere@pidgin.im>
parents: 8555
diff changeset
130
4390
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
131 static gint
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
132 process_event (GtkWidget *widget, GdkEvent *event, gpointer data G_GNUC_UNUSED)
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
133 {
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
134 static GtkWidget *original_widget = NULL;
5861
711db8ff91dd [gaim-migrate @ 6292]
Christian Hammond <chipx86@chipx86.com>
parents: 5227
diff changeset
135 static GdkCursor *cursor = NULL;
711db8ff91dd [gaim-migrate @ 6292]
Christian Hammond <chipx86@chipx86.com>
parents: 5227
diff changeset
136
4390
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
137 switch (event->type) {
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
138 case GDK_BUTTON_PRESS:
9843
19fd43d52d18 [gaim-migrate @ 10721]
Luke Schierer <lschiere@pidgin.im>
parents: 8555
diff changeset
139 if (event->button.button != gstroke_get_mouse_button()) {
19fd43d52d18 [gaim-migrate @ 10721]
Luke Schierer <lschiere@pidgin.im>
parents: 8555
diff changeset
140 /* Similar to the bug below catch when any other button is
19fd43d52d18 [gaim-migrate @ 10721]
Luke Schierer <lschiere@pidgin.im>
parents: 8555
diff changeset
141 * clicked after the middle button is clicked (but possibly
19fd43d52d18 [gaim-migrate @ 10721]
Luke Schierer <lschiere@pidgin.im>
parents: 8555
diff changeset
142 * not released)
19fd43d52d18 [gaim-migrate @ 10721]
Luke Schierer <lschiere@pidgin.im>
parents: 8555
diff changeset
143 */
19fd43d52d18 [gaim-migrate @ 10721]
Luke Schierer <lschiere@pidgin.im>
parents: 8555
diff changeset
144 gstroke_cancel(event);
19fd43d52d18 [gaim-migrate @ 10721]
Luke Schierer <lschiere@pidgin.im>
parents: 8555
diff changeset
145 original_widget = NULL;
19fd43d52d18 [gaim-migrate @ 10721]
Luke Schierer <lschiere@pidgin.im>
parents: 8555
diff changeset
146 break;
19fd43d52d18 [gaim-migrate @ 10721]
Luke Schierer <lschiere@pidgin.im>
parents: 8555
diff changeset
147 }
4390
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
148
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
149 original_widget = widget; /* remeber the widget where
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
150 the stroke started */
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
151
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
152 gstroke_invisible_window_init (widget);
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
153
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
154 record_stroke_segment (widget);
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
155
5861
711db8ff91dd [gaim-migrate @ 6292]
Christian Hammond <chipx86@chipx86.com>
parents: 5227
diff changeset
156 if (cursor == NULL)
711db8ff91dd [gaim-migrate @ 6292]
Christian Hammond <chipx86@chipx86.com>
parents: 5227
diff changeset
157 cursor = gdk_cursor_new(GDK_PENCIL);
711db8ff91dd [gaim-migrate @ 6292]
Christian Hammond <chipx86@chipx86.com>
parents: 5227
diff changeset
158
4390
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
159 gdk_pointer_grab (widget->window, FALSE,
5861
711db8ff91dd [gaim-migrate @ 6292]
Christian Hammond <chipx86@chipx86.com>
parents: 5227
diff changeset
160 GDK_BUTTON_RELEASE_MASK, NULL, cursor,
4390
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
161 event->button.time);
8555
e0535ba0d667 [gaim-migrate @ 9298]
Nathan Walp <nwalp@pidgin.im>
parents: 7631
diff changeset
162 timer_id = g_timeout_add (GSTROKE_TIMEOUT_DURATION,
4390
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
163 gstroke_timeout, widget);
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
164 return TRUE;
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
165
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
166 case GDK_BUTTON_RELEASE:
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
167 if ((event->button.button != gstroke_get_mouse_button())
4399
ce8d35b435de [gaim-migrate @ 4668]
Christian Hammond <chipx86@chipx86.com>
parents: 4390
diff changeset
168 || (original_widget == NULL)) {
ce8d35b435de [gaim-migrate @ 4668]
Christian Hammond <chipx86@chipx86.com>
parents: 4390
diff changeset
169
9843
19fd43d52d18 [gaim-migrate @ 10721]
Luke Schierer <lschiere@pidgin.im>
parents: 8555
diff changeset
170 /* Nice bug when you hold down one button and press another. */
19fd43d52d18 [gaim-migrate @ 10721]
Luke Schierer <lschiere@pidgin.im>
parents: 8555
diff changeset
171 /* We'll just cancel the gesture instead. */
19fd43d52d18 [gaim-migrate @ 10721]
Luke Schierer <lschiere@pidgin.im>
parents: 8555
diff changeset
172 gstroke_cancel(event);
19fd43d52d18 [gaim-migrate @ 10721]
Luke Schierer <lschiere@pidgin.im>
parents: 8555
diff changeset
173 original_widget = NULL;
19fd43d52d18 [gaim-migrate @ 10721]
Luke Schierer <lschiere@pidgin.im>
parents: 8555
diff changeset
174 break;
4399
ce8d35b435de [gaim-migrate @ 4668]
Christian Hammond <chipx86@chipx86.com>
parents: 4390
diff changeset
175 }
4390
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
176
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
177 last_mouse_position.invalid = TRUE;
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
178 original_widget = NULL;
8555
e0535ba0d667 [gaim-migrate @ 9298]
Nathan Walp <nwalp@pidgin.im>
parents: 7631
diff changeset
179 g_source_remove (timer_id);
4390
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
180 gdk_pointer_ungrab (event->button.time);
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
181 timer_id = 0;
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
182
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
183 {
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
184 char result[GSTROKE_MAX_SEQUENCE];
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
185 struct gstroke_metrics *metrics;
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
186
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
187 metrics = (struct gstroke_metrics *)g_object_get_data(G_OBJECT (widget),
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
188 GSTROKE_METRICS);
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
189 if (gstroke_draw_strokes()) {
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
190 /* get rid of the invisible stroke window */
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
191 XUnmapWindow (gstroke_disp, gstroke_window);
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
192 XFlush (gstroke_disp);
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
193 }
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
194
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
195 _gstroke_canonical (result, metrics);
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
196 gstroke_execute (widget, result);
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
197 return FALSE;
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
198 }
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
199 return TRUE;
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
200 default:
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
201 break;
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
202 }
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
203
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
204 return FALSE;
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
205 }
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
206
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
207 void
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
208 gstroke_set_draw_strokes(gboolean draw)
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
209 {
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
210 draw_strokes = draw;
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
211 }
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
212
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
213 gboolean
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
214 gstroke_draw_strokes(void)
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
215 {
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
216 return draw_strokes;
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
217 }
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
218
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
219 void
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
220 gstroke_set_mouse_button(gint button)
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
221 {
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
222 mouse_button = button;
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
223 }
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
224
7631
ea2d07ad05a9 [gaim-migrate @ 8255]
Nathan Walp <nwalp@pidgin.im>
parents: 5861
diff changeset
225 guint
4390
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
226 gstroke_get_mouse_button(void)
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
227 {
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
228 return mouse_button;
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
229 }
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
230
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
231 void
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
232 gstroke_enable (GtkWidget *widget)
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
233 {
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
234 struct gstroke_metrics*
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
235 metrics = (struct gstroke_metrics *)g_object_get_data(G_OBJECT(widget),
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
236 GSTROKE_METRICS);
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
237 if (metrics == NULL)
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
238 {
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
239 metrics = (struct gstroke_metrics *)g_malloc (sizeof
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
240 (struct gstroke_metrics));
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
241 metrics->pointList = NULL;
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
242 metrics->min_x = 10000;
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
243 metrics->min_y = 10000;
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
244 metrics->max_x = 0;
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
245 metrics->max_y = 0;
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
246 metrics->point_count = 0;
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
247
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
248 g_object_set_data(G_OBJECT(widget), GSTROKE_METRICS, metrics);
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
249
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
250 g_signal_connect(G_OBJECT(widget), "event",
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
251 G_CALLBACK(process_event), NULL);
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
252 }
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
253 else
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
254 _gstroke_init (metrics);
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
255
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
256 last_mouse_position.invalid = TRUE;
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
257 }
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
258
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
259 guint
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
260 gstroke_signal_connect (GtkWidget *widget,
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
261 const gchar *name,
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
262 void (*func)(GtkWidget *widget, void *data),
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
263 gpointer data)
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
264 {
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
265 struct gstroke_func_and_data *func_and_data;
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
266 GHashTable *hash_table =
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
267 (GHashTable*)g_object_get_data(G_OBJECT(widget), GSTROKE_SIGNALS);
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
268
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
269 if (!hash_table)
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
270 {
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
271 hash_table = g_hash_table_new (g_str_hash, g_str_equal);
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
272 g_object_set_data(G_OBJECT(widget), GSTROKE_SIGNALS,
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
273 (gpointer)hash_table);
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
274 }
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
275 func_and_data = g_new (struct gstroke_func_and_data, 1);
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
276 func_and_data->func = func;
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
277 func_and_data->data = data;
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
278 g_hash_table_insert (hash_table, (gpointer)name, (gpointer)func_and_data);
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
279 return TRUE;
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
280 }
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
281
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
282 static void
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
283 gstroke_execute (GtkWidget *widget, const gchar *name)
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
284 {
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
285
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
286 GHashTable *hash_table =
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
287 (GHashTable*)g_object_get_data(G_OBJECT(widget), GSTROKE_SIGNALS);
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
288
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
289 #if 0
5227
6d1707dc8c3d [gaim-migrate @ 5597]
Christian Hammond <chipx86@chipx86.com>
parents: 4529
diff changeset
290 gaim_debug(GAIM_DEBUG_MISC, "gestures", "gstroke %s\n", name);
4390
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
291 #endif
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
292
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
293 if (hash_table)
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
294 {
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
295 struct gstroke_func_and_data *fd =
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
296 (struct gstroke_func_and_data*)g_hash_table_lookup (hash_table, name);
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
297 if (fd)
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
298 (*fd->func)(widget, fd->data);
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
299 }
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
300 }
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
301
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
302 void
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
303 gstroke_cleanup (GtkWidget *widget)
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
304 {
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
305 struct gstroke_metrics *metrics;
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
306 GHashTable *hash_table =
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
307 (GHashTable*)g_object_get_data(G_OBJECT(widget), GSTROKE_SIGNALS);
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
308 if (hash_table)
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
309 /* FIXME: does this delete the elements too? */
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
310 g_hash_table_destroy (hash_table);
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
311
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
312 g_object_steal_data(G_OBJECT(widget), GSTROKE_SIGNALS);
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
313
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
314 metrics = (struct gstroke_metrics*)g_object_get_data(G_OBJECT(widget),
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
315 GSTROKE_METRICS);
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
316 if (metrics)
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
317 g_free (metrics);
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
318 g_object_steal_data(G_OBJECT(widget), GSTROKE_METRICS);
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
319 }
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
320
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
321
10814
364a2ef907ae [gaim-migrate @ 12468]
Luke Schierer <lschiere@pidgin.im>
parents: 9855
diff changeset
322 /* This function should be written using GTK+ primitives*/
4390
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
323 static void
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
324 gstroke_invisible_window_init (GtkWidget *widget)
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
325 {
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
326 XSetWindowAttributes w_attr;
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
327 XWindowAttributes orig_w_attr;
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
328 unsigned long mask, col_border, col_background;
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
329 unsigned int border_width;
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
330 XSizeHints hints;
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
331 Display *disp = GDK_WINDOW_XDISPLAY(widget->window);
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
332 Window wind = GDK_WINDOW_XWINDOW (widget->window);
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
333 int screen = DefaultScreen (disp);
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
334
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
335 if (!gstroke_draw_strokes())
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
336 return;
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
337
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
338 gstroke_disp = disp;
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
339
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
340 /* X server should save what's underneath */
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
341 XGetWindowAttributes (gstroke_disp, wind, &orig_w_attr);
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
342 hints.x = orig_w_attr.x;
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
343 hints.y = orig_w_attr.y;
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
344 hints.width = orig_w_attr.width;
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
345 hints.height = orig_w_attr.height;
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
346 mask = CWSaveUnder;
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
347 w_attr.save_under = True;
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
348
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
349 /* inhibit all the decorations */
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
350 mask |= CWOverrideRedirect;
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
351 w_attr.override_redirect = True;
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
352
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
353 /* Don't set a background, transparent window */
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
354 mask |= CWBackPixmap;
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
355 w_attr.background_pixmap = None;
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
356
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
357 /* Default input window look */
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
358 col_background = WhitePixel (gstroke_disp, screen);
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
359
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
360 /* no border for the window */
4399
ce8d35b435de [gaim-migrate @ 4668]
Christian Hammond <chipx86@chipx86.com>
parents: 4390
diff changeset
361 #if 0
4390
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
362 border_width = 5;
4399
ce8d35b435de [gaim-migrate @ 4668]
Christian Hammond <chipx86@chipx86.com>
parents: 4390
diff changeset
363 #endif
4390
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
364 border_width = 0;
4399
ce8d35b435de [gaim-migrate @ 4668]
Christian Hammond <chipx86@chipx86.com>
parents: 4390
diff changeset
365
4390
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
366 col_border = BlackPixel (gstroke_disp, screen);
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
367
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
368 gstroke_window = XCreateSimpleWindow (gstroke_disp, wind,
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
369 0, 0,
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
370 hints.width - 2 * border_width,
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
371 hints.height - 2 * border_width,
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
372 border_width,
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
373 col_border, col_background);
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
374
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
375 gstroke_gc = XCreateGC (gstroke_disp, gstroke_window, 0, NULL);
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
376
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
377 XSetFunction (gstroke_disp, gstroke_gc, GXinvert);
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
378
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
379 XChangeWindowAttributes (gstroke_disp, gstroke_window, mask, &w_attr);
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
380
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
381 XSetLineAttributes (gstroke_disp, gstroke_gc, 2, LineSolid,
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
382 CapButt, JoinMiter);
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
383 XMapRaised (gstroke_disp, gstroke_window);
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
384
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
385 #if 0
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
386 /*FIXME: is this call really needed? If yes, does it need the real
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
387 argc and argv? */
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
388 hints.flags = PPosition | PSize;
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
389 XSetStandardProperties (gstroke_disp, gstroke_window, "gstroke_test", NULL,
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
390 (Pixmap)NULL, NULL, 0, &hints);
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
391
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
392
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
393 /* Receive the close window client message */
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
394 {
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
395 /* FIXME: is this really needed? If yes, something should be done
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
396 with wmdelete...*/
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
397 Atom wmdelete = XInternAtom (gstroke_disp, "WM_DELETE_WINDOW",
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
398 False);
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
399 XSetWMProtocols (gstroke_disp, gstroke_window, &wmdelete, True);
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
400 }
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
401 #endif
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
402 }