• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Aucun tag

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Révisionf9fc4878bc05dd4e9375e09829b4e7fa2c8a02f5 (tree)
l'heure2023-03-19 14:33:27
Auteurphabrics <phabrics@phab...>
Commiterphabrics

Message de Log

Finalized structure of display for GTK4 migration.

Change Summary

Modification

--- a/host/display/display-keyboard.c
+++ b/host/display/display-keyboard.c
@@ -227,10 +227,9 @@ _tme_keyboard_keyval_name(tme_keyboard_keyval_t keyval)
227227
228228 /* this is a generic callback for a key press or release event: */
229229 int
230-_tme_keyboard_key_event(int down, tme_keyboard_keyval_t key, void *disp)
230+_tme_keyboard_key_event(int down, tme_keyboard_keyval_t key, struct tme_display *display)
231231 {
232232 struct tme_keyboard_event tme_event;
233- struct tme_display *display = (_tme_display_get) ? (_tme_display_get(disp)) : (disp);
234233 int was_empty;
235234 int new_callouts;
236235 int rc;
--- a/host/display/display-mouse.c
+++ b/host/display/display-mouse.c
@@ -53,31 +53,23 @@ _tme_mouse_debug(const struct tme_mouse_event *event)
5353 #endif
5454
5555 /* this is a generic callback for a mouse event: */
56-int
57-_tme_mouse_button_press(int button, int x, int y, struct tme_display *display)
56+void
57+_tme_mouse_event(int button, int x, int y, struct tme_display *display)
5858 {
59- int state;
60-
59+ struct tme_mouse_event tme_event;
60+ int was_empty;
61+ int new_callouts, rc;
62+
6163 /* make the buttons mask: */
62- state = display->tme_screen_mouse_buttons_last;
64+ int buttons = display->tme_screen_mouse_buttons_last;
6365
6466 if(button>0)
65- state |= TME_BIT(button-1);
67+ buttons |= TME_BIT(button-1);
6668 else if(button) {
6769 button = -button;
68- state &= ~TME_BIT(button-1);
70+ buttons &= ~TME_BIT(button-1);
6971 }
7072
71- return _tme_mouse_buttons_event(state, x, y, display);
72-}
73-
74-int _tme_mouse_buttons_event(int buttons, int x, int y, void *disp)
75-{
76- struct tme_mouse_event tme_event;
77- int was_empty;
78- int new_callouts, rc;
79- struct tme_display *display = (_tme_display_get) ? (_tme_display_get(disp)) : (disp);
80-
8173 /* start the tme event: */
8274 tme_event.tme_mouse_event_delta_units
8375 = TME_MOUSE_UNITS_UNKNOWN;
@@ -100,7 +92,7 @@ int _tme_mouse_buttons_event(int buttons, int x, int y, void *disp)
10092 tme_mutex_unlock(&display->tme_display_mutex);
10193
10294 /* stop propagating this event: */
103- return (TRUE);
95+ return;
10496 }
10597
10698 tme_event.tme_mouse_event_buttons =
@@ -145,9 +137,6 @@ int _tme_mouse_buttons_event(int buttons, int x, int y, void *disp)
145137
146138 /* unlock the mutex: */
147139 tme_mutex_unlock(&display->tme_display_mutex);
148-
149- /* don't process this event any further: */
150- return (TRUE);
151140 }
152141
153142 /* this is called when the mouse controls change: */
--- a/host/display/display.c
+++ b/host/display/display.c
@@ -36,8 +36,6 @@
3636 /* includes: */
3737 #include "display.h"
3838
39-struct tme_display *(*_tme_display_get) _TME_P((void *));
40-
4139 static int
4240 _tme_screen_update(struct tme_screen *screen) {
4341 struct tme_fb_connection *conn_fb;
@@ -689,9 +687,6 @@ int tme_display_init(struct tme_element *element,
689687 /* start our data structure: */
690688 display->tme_display_element = element;
691689
692- /* default display: */
693- _tme_display_get = 0;
694-
695690 /* create the keyboard: */
696691 _tme_keyboard_new(display);
697692
--- a/host/display/display.h
+++ b/host/display/display.h
@@ -186,7 +186,6 @@ _tme_scanline_pad(int bpl)
186186 return (8);
187187 }
188188
189-extern struct tme_display *(*_tme_display_get) _TME_P((void *));
190189 struct tme_screen *_tme_screen_add _TME_P((struct tme_display *,
191190 size_t,
192191 struct tme_connection *));
@@ -197,12 +196,12 @@ void _tme_screen_xlat_set _TME_P((struct tme_screen *screen));
197196 void _tme_keyboard_new _TME_P((struct tme_display *));
198197 int _tme_keyboard_connections_new _TME_P((struct tme_display *,
199198 struct tme_connection **));
200-int _tme_keyboard_key_event _TME_P((int down, tme_keyboard_keyval_t key, void *disp));
199+int _tme_keyboard_key_event _TME_P((int down, tme_keyboard_keyval_t key, struct tme_display *disp));
201200 void _tme_mouse_new _TME_P((struct tme_display *));
202201 void _tme_mouse_mode_off _TME_P((struct tme_screen *, tme_uint32_t));
203202 int _tme_mouse_connections_new _TME_P((struct tme_display *,
204203 struct tme_connection **));
205-int _tme_mouse_buttons_event _TME_P((int buttons, int x, int y, void *disp));
204+void _tme_mouse_event _TME_P((int button, int x, int y, struct tme_display *disp));
206205
207206 #endif /* _HOST_DISPLAY_H */
208207
--- a/host/display/gtk/gtk-display.h
+++ b/host/display/gtk/gtk-display.h
@@ -98,8 +98,8 @@ typedef struct tme_gtk_screen {
9898 guint tme_gtk_screen_mouse_statusbar_cid;
9999
100100 cairo_format_t tme_gtk_screen_format;
101- GtkEventControllerKey *key;
102- GtkEventControllerMotion *motion;
101+ GtkEventController *key, *mouse, *motion, *event;
102+ GtkGesture *press;
103103
104104 /* when mouse mode is on, this is the previous events mask
105105 for the framebuffer event box: */
--- a/host/display/gtk/gtk-keyboard.c
+++ b/host/display/gtk/gtk-keyboard.c
@@ -50,9 +50,25 @@ _tme_gtk_keyboard_key_down(
5050 guint keyval,
5151 guint keycode,
5252 GdkModifierType* state,
53- struct tme_display *display)
53+ struct tme_gtk_screen *screen)
5454 {
55- return _tme_keyboard_key_event(TRUE, keyval, display);
55+ if(screen->tme_gtk_screen_mouse_keyval
56+ != keyval)
57+ return _tme_keyboard_key_event(TRUE, keyval, screen->screen.tme_screen_display);
58+
59+ /* pop our message off of the statusbar: */
60+ gtk_statusbar_pop(GTK_STATUSBAR(screen->tme_gtk_screen_mouse_statusbar),
61+ screen->tme_gtk_screen_mouse_statusbar_cid);
62+
63+ /* restore the text on the mouse label: */
64+ gtk_frame_set_label(GTK_FRAME(screen->tme_gtk_screen_mouse_label),
65+ _("Mouse is off"));
66+
67+ /* the mouse is now off: */
68+ screen->tme_gtk_screen_mouse_keyval = GDK_KEY_VoidSymbol;
69+
70+ return (TRUE);
71+
5672 }
5773
5874 static gboolean
@@ -61,46 +77,100 @@ _tme_gtk_keyboard_key_up(
6177 guint keyval,
6278 guint keycode,
6379 GdkModifierType* state,
64- struct tme_display *display)
80+ struct tme_gtk_screen *screen)
81+{
82+ return _tme_keyboard_key_event(FALSE, keyval, screen->screen.tme_screen_display);
83+}
84+
85+/* this sets the mouse mode, e.g., on/off. it is called with the mutex locked: */
86+static gboolean
87+_tme_gtk_mouse_key_down(
88+ GtkEventControllerKey* self,
89+ guint keyval,
90+ guint keycode,
91+ GdkModifierType* state,
92+ struct tme_gtk_screen *screen)
6593 {
66- return _tme_keyboard_key_event(FALSE, keyval, display);
94+ struct tme_gtk_display *display;
95+ int rc;
96+ char *status;
97+
98+ /* recover our data structure: */
99+ display = screen->screen.tme_screen_display;
100+
101+ if(screen->tme_gtk_screen_mouse_keyval
102+ != GDK_KEY_VoidSymbol) return (FALSE);
103+
104+ /* lock the mutex: */
105+ tme_mutex_lock(&display->display.tme_display_mutex);
106+
107+ /* this keyval must not be GDK_KEY_VoidSymbol: */
108+ assert (keyval
109+ != GDK_KEY_VoidSymbol);
110+
111+ /* set the text on the mouse label: */
112+ gtk_frame_set_label(GTK_FRAME(screen->tme_gtk_screen_mouse_label),
113+ _("Mouse is on"));
114+
115+ /* push the mouse status onto the statusbar: */
116+ status = NULL;
117+ tme_output_append(&status,
118+ _("Press the %s key to turn the mouse off"),
119+ gdk_keyval_name(keyval));
120+ gtk_statusbar_push(GTK_STATUSBAR(screen->tme_gtk_screen_mouse_statusbar),
121+ screen->tme_gtk_screen_mouse_statusbar_cid,
122+ status);
123+ tme_free(status);
124+
125+ gdk_device_get_position(gdk_seat_get_pointer(display->tme_gdk_display_seat),
126+ NULL,
127+ &display->display.tme_screen_mouse_warp_x,
128+ &display->display.tme_screen_mouse_warp_y);
129+
130+ /* we are now in mouse mode: */
131+ screen->tme_gtk_screen_mouse_keyval
132+ = keyval;
133+
134+ /* unlock the mutex: */
135+ tme_mutex_unlock(&display->display.tme_display_mutex);
136+
137+ return (TRUE);
67138 }
68139
69140 /* this attaches the GTK keyboard to a new screen: */
70141 void
71142 _tme_gtk_keyboard_attach(struct tme_gtk_screen *screen)
72143 {
73- GtkEventControllerKey *key;
74- GtkEventControllerMotion *motion;
144+ GtkEventController *key, *mouse;
75145
76146 #if GTK_MAJOR_VERSION == 4
77- motion=gtk_event_controller_motion_new();
78147 key=gtk_event_controller_key_new();
79- gtk_widget_add_controller(screen->tme_gtk_screen_draw, GTK_EVENT_CONTROLLER(key));
80- gtk_widget_add_controller(screen->tme_gtk_screen_draw, GTK_EVENT_CONTROLLER(motion));
148+ gtk_widget_add_controller(screen->tme_gtk_screen_draw, key);
149+ gtk_widget_set_focussable(screen->tme_gtk_screen_draw, TRUE);
150+ mouse=gtk_event_controller_key_new();
151+ gtk_widget_add_controller(screen->tme_gtk_screen_mouse_label, mouse);
152+ gtk_widget_set_focussable(screen->tme_gtk_screen_mouse_label, TRUE);
81153 #elif GTK_MAJOR_VERSION == 3
82- motion=screen->motion=gtk_event_controller_motion_new(screen->tme_gtk_screen_draw);
83154 key=screen->key=gtk_event_controller_key_new(screen->tme_gtk_screen_draw);
155+ gtk_widget_set_can_focus(screen->tme_gtk_screen_draw, TRUE);
156+ mouse=screen->mouse=gtk_event_controller_key_new(screen->tme_gtk_screen_mouse_label);
157+ gtk_widget_set_can_focus(screen->tme_gtk_screen_mouse_label, TRUE);
84158 #endif
85159
86- /* on entering window, grab keyboard focus: */
87- g_signal_connect_swapped(motion,
88- "enter",
89- G_CALLBACK(gtk_widget_grab_focus),
90- screen->tme_gtk_screen_draw);
91-
92160 g_signal_connect_after(key,
93161 "key-pressed",
94162 G_CALLBACK(_tme_gtk_keyboard_key_down),
95- screen->screen.tme_screen_display);
163+ screen);
164+
96165 g_signal_connect_after(key,
97166 "key-released",
98167 G_CALLBACK(_tme_gtk_keyboard_key_up),
99- screen->screen.tme_screen_display);
100-
101- /* the event box can focus, and have it grab the focus now: */
102- gtk_widget_set_can_focus(screen->tme_gtk_screen_draw, TRUE);
103- gtk_widget_grab_focus(screen->tme_gtk_screen_draw);
168+ screen);
169+
170+ g_signal_connect_after(mouse,
171+ "key-pressed",
172+ G_CALLBACK(_tme_gtk_mouse_key_down),
173+ screen);
104174
105175 }
106176
--- a/host/display/gtk/gtk-mouse.c
+++ b/host/display/gtk/gtk-mouse.c
@@ -56,231 +56,88 @@ _tme_gtk_mouse_warp_pointer(struct tme_gtk_screen *screen)
5656 screen->screen.tme_screen_mouse_warp_y);
5757 }
5858 #endif
59-/* this is a GTK callback for a mouse event in the framebuffer event box: */
60-static int
61-_tme_gtk_mouse_mouse_event(GtkWidget *widget,
62- GdkEvent *gdk_event_raw,
63- struct tme_gtk_screen *display)
64-{
65- gint x;
66- gint y;
67- int button=0;
68-
69-#if GTK_MAJOR_VERSION == 4
70- gdk_event_get_position(gdk_event_raw, &x, &y);
71- button = gdk_button_event_get_button(gdk_event_raw);
72-
73-#elif GTK_MAJOR_VERSION == 3
74- /* if this is motion: */
75- if (gdk_event_raw->type == GDK_MOTION_NOTIFY) {
76-
77- /* if the pointer position hasn't changed either, return now.
78- every time we warp the pointer we will get a motion event, and
79- this should ignore those events: */
80- x = gdk_event_raw->motion.x;
81- y = gdk_event_raw->motion.y;
82-
83- }
84-
85- /* otherwise, this must be a button press or a release: */
86- else {
8759
88- /* get the pointer position: */
89- x = gdk_event_raw->button.x;
90- y = gdk_event_raw->button.y;
91-
92- /* make the buttons mask: */
93- button = gdk_event_raw->button.button;
94- if(gdk_event_raw->type == GDK_BUTTON_RELEASE)
95- button = -button;
96- }
97-
98- /* otherwise, if this is a double- or triple-click: */
99- if (gdk_event_raw->type != GDK_2BUTTON_PRESS
100- && gdk_event_raw->type != GDK_3BUTTON_PRESS)
101-#endif
102- {
103- /* we ignore double- and triple-click events, since normal button
104- press and release events are always generated also: */
105- // assert (gdk_event_raw->type == GDK_BUTTON_PRESS || gdk_event_raw->type == GDK_BUTTON_RELEASE);
106-
107- _tme_mouse_button_press(button, x, y, display);
108-
109- }
60+/* this is a GTK callback for a mouse event in the framebuffer event box: */
61+static void
62+_tme_gtk_mouse_motion_event(GtkEventControllerMotion* self,
63+ gdouble x,
64+ gdouble y,
65+ struct tme_gtk_screen *screen)
11066
111- /* stop propagating this event: */
112- return (TRUE);
67+{
68+ if(screen->tme_gtk_screen_mouse_keyval
69+ != GDK_KEY_VoidSymbol)
70+ _tme_mouse_event(0, x, y, screen->screen.tme_screen_display);
11371 }
11472
115-/* this is a GTK callback for an event in the event box containing the
116- mouse label: */
117-static int
118-_tme_gtk_mouse_ebox_event(GtkWidget *widget,
119- GdkEvent *gdk_event_raw,
120- struct tme_gtk_screen *screen)
73+/* this is a GTK callback for a mouse event in the framebuffer event box: */
74+static void
75+_tme_gtk_mouse_button_down(GtkGesture* self,
76+ int n_press,
77+ gdouble x,
78+ gdouble y,
79+ struct tme_gtk_screen *screen)
12180 {
122- struct tme_gtk_display *display;
123- int rc;
124- char *status;
125- GdkWindow *window;
126-
127- /* if this is an enter notify event, grab the focus and continue
128- propagating the event: */
129- if (gdk_event_get_event_type(gdk_event_raw) == GDK_ENTER_NOTIFY) {
130- gtk_widget_grab_focus(widget);
131- return (FALSE);
132- }
133-
134- /* if this is not a key press event, continue propagating it now: */
135- if (gdk_event_get_event_type(gdk_event_raw) != GDK_KEY_PRESS) {
136- return (FALSE);
137- }
138-
139- /* recover our data structure: */
140- display = screen->screen.tme_screen_display;
141-
142- /* lock the mutex: */
143- tme_mutex_lock(&display->display.tme_display_mutex);
144-
145- /* the mouse must not be on already: */
146- assert (screen->tme_gtk_screen_mouse_keyval
147- == GDK_KEY_VoidSymbol);
148-
149- /* this keyval must not be GDK_KEY_VoidSymbol: */
150- assert (gdk_event_raw->key.keyval
151- != GDK_KEY_VoidSymbol);
152-
153- /* set the text on the mouse label: */
154- gtk_label_set_text(GTK_LABEL(screen->tme_gtk_screen_mouse_label),
155- _("Mouse is on"));
156-
157- /* push the mouse status onto the statusbar: */
158- status = NULL;
159- tme_output_append(&status,
160- _("Press the %s key to turn the mouse off"),
161- gdk_keyval_name(gdk_event_raw->key.keyval));
162- gtk_statusbar_push(GTK_STATUSBAR(screen->tme_gtk_screen_mouse_statusbar),
163- screen->tme_gtk_screen_mouse_statusbar_cid,
164- status);
165- tme_free(status);
166-
167- window = gtk_widget_get_window(screen->tme_gtk_screen_draw);
168-
169- /* if the original events mask on the framebuffer event box have
170- never been saved, save them now, and add the mouse events: */
171- /* if (screen->tme_gtk_screen_mouse_events_old == 0) {
172- screen->tme_gtk_screen_mouse_events_old
173- = gtk_widget_get_events(screen->tme_gtk_screen_draw);
174- gtk_widget_add_events(screen->tme_gtk_screen_draw,
175- GDK_POINTER_MOTION_MASK
176- | GDK_BUTTON_PRESS_MASK
177- | GDK_BUTTON_RELEASE_MASK);
178- }
179- */
180- /* grab the pointer: */
181- gtk_grab_add(screen->tme_gtk_screen_draw);
182- /*gtk_device_grab_add(screen->tme_gtk_screen_draw,
183- gdk_seat_get_pointer(display->tme_gdk_display_seat),
184- FALSE);*/
185-
186- rc
187- = gdk_seat_grab(display->tme_gdk_display_seat,
188- window,
189- GDK_SEAT_CAPABILITY_ALL_POINTING,
190- TRUE,
191- display->tme_gdk_display_cursor,
192- gdk_event_raw,
193- NULL,
194- NULL);
195- assert (rc == 0);
196-
197- gdk_device_get_position(gdk_seat_get_pointer(display->tme_gdk_display_seat),
198- NULL,
199- &display->display.tme_screen_mouse_warp_x,
200- &display->display.tme_screen_mouse_warp_y);
201-
202- /* we are now in mouse mode: */
203- screen->tme_gtk_screen_mouse_keyval
204- = gdk_event_raw->key.keyval;
205-
206- /* unlock the mutex: */
207- tme_mutex_unlock(&display->display.tme_display_mutex);
208-
209- /* stop propagating this event: */
210- return (TRUE);
81+ if(screen->tme_gtk_screen_mouse_keyval
82+ != GDK_KEY_VoidSymbol)
83+ _tme_mouse_event(gtk_gesture_single_get_current_button(self),
84+ x, y, screen->screen.tme_screen_display);
21185 }
21286
213-/* this turns mouse mode off. it is called with the mutex locked: */
214-void
215-_tme_gtk_mouse_mode_off(struct tme_gtk_screen *screen,
216- guint32 time)
87+/* this is a GTK callback for a mouse event in the framebuffer event box: */
88+static void
89+_tme_gtk_mouse_button_up(GtkGesture* self,
90+ int n_press,
91+ gdouble x,
92+ gdouble y,
93+ struct tme_gtk_screen *screen)
21794 {
218- struct tme_gtk_display *display;
219-
220- /* get the display: */
221- display = screen->screen.tme_screen_display;
222-
223- /* the mouse must be on: */
224- assert (screen->tme_gtk_screen_mouse_keyval
225- != GDK_KEY_VoidSymbol);
226-
227- /* ungrab the pointer: */
228- gdk_seat_ungrab(display->tme_gdk_display_seat);
229- gtk_grab_remove(screen->tme_gtk_screen_draw);
230- //gtk_device_grab_remove(screen->tme_gtk_screen_draw, gdk_seat_get_pointer(display->tme_gdk_display_seat));
231-
232- /* restore the old events mask on the event box: */
233- // gtk_widget_set_events(screen->tme_gtk_screen_draw, screen->tme_gtk_screen_mouse_events_old);
234-
235- /* pop our message off of the statusbar: */
236- gtk_statusbar_pop(GTK_STATUSBAR(screen->tme_gtk_screen_mouse_statusbar),
237- screen->tme_gtk_screen_mouse_statusbar_cid);
238-
239- /* restore the text on the mouse label: */
240- gtk_label_set_text(GTK_LABEL(screen->tme_gtk_screen_mouse_label),
241- _("Mouse is off"));
242-
243- /* the mouse is now off: */
244- screen->tme_gtk_screen_mouse_keyval = GDK_KEY_VoidSymbol;
95+ if(screen->tme_gtk_screen_mouse_keyval
96+ != GDK_KEY_VoidSymbol)
97+ _tme_mouse_event(-gtk_gesture_single_get_current_button(self),
98+ x, y, screen->screen.tme_screen_display);
24599 }
246100
247101 /* this attaches the GTK mouse to a new screen: */
248102 void
249103 _tme_gtk_mouse_attach(struct tme_gtk_screen *screen)
250104 {
251- GtkWidget *ebox;
105+ GtkEventController *motion, *event;
106+ GtkGesture *press;
252107
253108 /* create the event box for the mouse on label: */
254- ebox = gtk_event_box_new();
109+ /* create the mouse on label: */
110+ screen->tme_gtk_screen_mouse_label
111+ = gtk_frame_new(_("Mouse is off"));
255112
256113 /* pack the event box into the horizontal packing box: */
257- gtk_header_bar_pack_start(GTK_HEADER_BAR(screen->tme_gtk_screen_header), ebox);
114+ gtk_header_bar_pack_start(GTK_HEADER_BAR(screen->tme_gtk_screen_header),
115+ screen->tme_gtk_screen_mouse_label);
258116
117+#if GTK_MAJOR_VERSION == 4
118+ motion=gtk_event_controller_motion_new();
119+ gtk_widget_add_controller(screen->tme_gtk_screen_draw, motion);
120+ event=gtk_event_controller_motion_new();
121+ gtk_widget_add_controller(screen->tme_gtk_screen_mouse_label, event);
122+ press = gtk_gesture_click_new();
123+ gtk_widget_add_controller(screen->tme_gtk_screen_draw, GTK_EVENT_CONTROLLER (press));
124+#elif GTK_MAJOR_VERSION == 3
125+ motion=screen->motion=gtk_event_controller_motion_new(screen->tme_gtk_screen_draw);
126+ event=screen->event=gtk_event_controller_motion_new(screen->tme_gtk_screen_mouse_label);
127+ press=screen->press=gtk_gesture_multi_press_new(screen->tme_gtk_screen_draw);
128+#endif
129+
130+ gtk_gesture_single_set_button(GTK_GESTURE_SINGLE (press), 0);
259131 /* set the tip on the event box, which will eventually contain the mouse on label: */
260- gtk_widget_set_tooltip_text(ebox,
132+ gtk_widget_set_tooltip_text(screen->tme_gtk_screen_mouse_label,
261133 "Press a key here to turn the mouse on. The same key " \
262134 "will turn the mouse off.");
263135
264- /* make sure the event box gets key_press events: */
265- gtk_widget_add_events(ebox,
266- GDK_KEY_PRESS_MASK);
267-
268136 /* set a signal handler for the event box events: */
269- g_signal_connect(ebox,
137+ /* g_signal_connect(ebox,
270138 "event",
271139 G_CALLBACK(_tme_gtk_mouse_ebox_event),
272- screen);
273-
274- /* the event box can focus: */
275- gtk_widget_set_can_focus(ebox, TRUE);
276-
277- /* create the mouse on label: */
278- screen->tme_gtk_screen_mouse_label
279- = gtk_label_new(_("Mouse is off"));
280-
281- /* add the mouse on label to the event box: */
282- gtk_container_add(GTK_CONTAINER(ebox),
283- screen->tme_gtk_screen_mouse_label);
140+ screen); */
284141
285142 /* create the mouse statusbar: */
286143 screen->tme_gtk_screen_mouse_statusbar
@@ -298,20 +155,30 @@ _tme_gtk_mouse_attach(struct tme_gtk_screen *screen)
298155 screen->tme_gtk_screen_mouse_statusbar_cid,
299156 _("The Machine Emulator"));
300157
158+ /* on entering window, grab keyboard focus: */
159+ g_signal_connect_swapped(motion,
160+ "enter",
161+ G_CALLBACK(gtk_widget_grab_focus),
162+ screen->tme_gtk_screen_draw);
163+
301164 /* although the event mask doesn't include these events yet,
302165 set a signal handler for the mouse events: */
303- g_signal_connect(screen->tme_gtk_screen_draw,
304- "motion_notify_event",
305- G_CALLBACK(_tme_gtk_mouse_mouse_event),
306- screen->screen.tme_screen_display);
307- g_signal_connect(screen->tme_gtk_screen_draw,
308- "button_press_event",
309- G_CALLBACK(_tme_gtk_mouse_mouse_event),
310- screen->screen.tme_screen_display);
311- g_signal_connect(screen->tme_gtk_screen_draw,
312- "button_release_event",
313- G_CALLBACK(_tme_gtk_mouse_mouse_event),
314- screen->screen.tme_screen_display);
166+ g_signal_connect(motion,
167+ "motion",
168+ G_CALLBACK(_tme_gtk_mouse_motion_event),
169+ screen);
170+
171+ g_signal_connect(press, "released", G_CALLBACK(_tme_gtk_mouse_button_up),
172+ screen);
173+
174+ g_signal_connect(press, "pressed", G_CALLBACK(_tme_gtk_mouse_button_down),
175+ screen);
176+
177+ /* on entering window, grab keyboard focus: */
178+ g_signal_connect_swapped(event,
179+ "enter",
180+ G_CALLBACK(gtk_widget_grab_focus),
181+ screen->tme_gtk_screen_mouse_label);
315182
316183 /* mouse mode is off: */
317184 screen->tme_gtk_screen_mouse_keyval = GDK_KEY_VoidSymbol;
--- a/host/display/rfb/rfb-display.c
+++ b/host/display/rfb/rfb-display.c
@@ -136,7 +136,17 @@ static enum rfbNewClientAction _tme_rfb_newclient(rfbClientPtr cl)
136136 return RFB_CLIENT_ACCEPT;
137137 }
138138
139-static struct tme_display *tme_rfb_display(rfbClientPtr cl) { return cl->clientData; }
139+static void _tme_mouse_ev(int buttons, int x, int y, rfbClientPtr cl) {
140+ struct tme_display *display = cl->clientData;
141+
142+ /* make the buttons mask: */
143+ display->tme_screen_mouse_buttons_last = buttons;
144+ _tme_mouse_event(0,x,y,display);
145+}
146+
147+static void _tme_keyboard_key_ev(int down, tme_keyboard_keyval_t key, rfbClientPtr cl) {
148+ _tme_keyboard_key_event(down, key, cl->clientData);
149+}
140150
141151 /* the new RFB display function: */
142152 TME_ELEMENT_SUB_NEW_DECL(tme_host_rfb,display) {
@@ -148,8 +158,6 @@ TME_ELEMENT_SUB_NEW_DECL(tme_host_rfb,display) {
148158 /* start our data structure: */
149159 tme_display_init(element, 0);
150160
151- _tme_display_get = tme_rfb_display;
152-
153161 /* recover our data structure: */
154162 display = element->tme_element_private;
155163
@@ -165,8 +173,8 @@ TME_ELEMENT_SUB_NEW_DECL(tme_host_rfb,display) {
165173 display->tme_screen_height *
166174 bpp);
167175 server->alwaysShared = TRUE;
168- server->ptrAddEvent = _tme_mouse_buttons_event;
169- server->kbdAddEvent = _tme_keyboard_key_event;
176+ server->ptrAddEvent = _tme_mouse_ev;
177+ server->kbdAddEvent = _tme_keyboard_key_ev;
170178 server->newClientHook = _tme_rfb_newclient;
171179 // server->httpDir = "../webclients";
172180 // server->httpEnableProxyConnect = TRUE;