|
192 | 192 | EmbeddedProcessBase() { |
193 | 193 | layer_host = memnew(LayerHost(this)); |
194 | 194 | add_child(layer_host); |
| 195 | + set_focus_mode(FOCUS_NONE); |
195 | 196 | layer_host->set_focus_mode(FOCUS_ALL); |
196 | 197 | layer_host->set_anchors_and_offsets_preset(PRESET_FULL_RECT); |
197 | 198 | layer_host->set_custom_minimum_size(Size2(100, 100)); |
|
219 | 220 | if (script_debugger) { |
220 | 221 | script_debugger->send_message("embed:win_event", { DisplayServer::WINDOW_EVENT_MOUSE_ENTER }); |
221 | 222 | } |
| 223 | + if (get_window()->has_focus()) { |
| 224 | + grab_focus(); |
| 225 | + } |
222 | 226 | } break; |
223 | 227 | case NOTIFICATION_FOCUS_ENTER: { |
224 | 228 | // Restore mouse capture, if necessary. |
|
228 | 232 | ds->mouse_set_mode(process->get_mouse_mode()); |
229 | 233 | } |
230 | 234 | if (!window_focused && script_debugger) { |
| 235 | + script_debugger->send_message("embed:notification", { NOTIFICATION_APPLICATION_FOCUS_IN }); |
231 | 236 | script_debugger->send_message("embed:win_event", { DisplayServer::WINDOW_EVENT_FOCUS_IN }); |
232 | 237 | window_focused = true; |
233 | 238 | } |
| 239 | + process->queue_redraw(); |
234 | 240 | } break; |
235 | 241 | case NOTIFICATION_MOUSE_EXIT: { |
236 | 242 | DisplayServer *ds = DisplayServer::get_singleton(); |
|
249 | 255 | } |
250 | 256 | if (window_focused && script_debugger) { |
251 | 257 | script_debugger->send_message("embed:win_event", { DisplayServer::WINDOW_EVENT_FOCUS_OUT }); |
| 258 | + script_debugger->send_message("embed:notification", { NOTIFICATION_APPLICATION_FOCUS_OUT }); |
252 | 259 | window_focused = false; |
253 | 260 | } |
| 261 | + process->queue_redraw(); |
254 | 262 | } break; |
255 | 263 | case MainLoop::NOTIFICATION_OS_IME_UPDATE: { |
256 | 264 | if (script_debugger && has_focus()) { |
|
268 | 276 | } |
269 | 277 | } |
270 | 278 | } break; |
| 279 | + case NOTIFICATION_APPLICATION_FOCUS_IN: |
271 | 280 | case NOTIFICATION_WM_WINDOW_FOCUS_IN: { |
272 | | - if (!window_focused && script_debugger) { |
| 281 | + if (has_focus() && !window_focused && script_debugger) { |
| 282 | + script_debugger->send_message("embed:notification", { NOTIFICATION_APPLICATION_FOCUS_IN }); |
273 | 283 | script_debugger->send_message("embed:win_event", { DisplayServer::WINDOW_EVENT_FOCUS_IN }); |
274 | 284 | window_focused = true; |
275 | 285 | } |
276 | 286 | } break; |
| 287 | + case NOTIFICATION_APPLICATION_FOCUS_OUT: |
277 | 288 | case NOTIFICATION_WM_WINDOW_FOCUS_OUT: { |
278 | | - if (window_focused && script_debugger) { |
| 289 | + if (has_focus() && window_focused && script_debugger) { |
279 | 290 | script_debugger->send_message("embed:win_event", { DisplayServer::WINDOW_EVENT_FOCUS_OUT }); |
280 | | - window_focused = false; |
281 | | - } |
282 | | - } break; |
283 | | - case NOTIFICATION_APPLICATION_FOCUS_IN: { |
284 | | - if (script_debugger) { |
285 | | - script_debugger->send_message("embed:notification", { NOTIFICATION_APPLICATION_FOCUS_IN }); |
286 | | - } |
287 | | - } break; |
288 | | - case NOTIFICATION_APPLICATION_FOCUS_OUT: { |
289 | | - if (script_debugger) { |
290 | 291 | script_debugger->send_message("embed:notification", { NOTIFICATION_APPLICATION_FOCUS_OUT }); |
| 292 | + window_focused = false; |
291 | 293 | } |
292 | 294 | } break; |
293 | 295 | } |
|
0 commit comments