summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Hollerbach <mail@marcel-hollerbach.de>2020-12-09 10:40:59 +0100
committerMarcel Hollerbach <mail@marcel-hollerbach.de>2020-12-09 10:40:59 +0100
commite800a57821698cb0f839854a6b795f0eb532a092 (patch)
tree4b363c7f950e6f2a41109e4ba78a5fa56a7f72ef
parentaa7b50ae4b4230d5f908b2c88d8559e63a4a5ff9 (diff)
controls: always focus new buttondevs/bu5hm4n/fix-for-billiob
if the terminal is unfocused, the layout is not allowed to get focus anymore. This way we ensure that cases where we have multiple ui elements overlapping cause problems.
-rw-r--r--src/bin/controls.c223
-rw-r--r--src/bin/win.c6
2 files changed, 118 insertions, 111 deletions
diff --git a/src/bin/controls.c b/src/bin/controls.c
index c3bf996..85d5dd2 100644
--- a/src/bin/controls.c
+++ b/src/bin/controls.c
@@ -19,6 +19,7 @@ typedef struct _Controls_Ctx {
19 Evas_Object *base; 19 Evas_Object *base;
20 Evas_Object *bg; 20 Evas_Object *bg;
21 Evas_Object *term; 21 Evas_Object *term;
22 Evas_Object *new_btn;
22 void (*donecb) (void *data); 23 void (*donecb) (void *data);
23 void *donedata; 24 void *donedata;
24} Controls_Ctx; 25} Controls_Ctx;
@@ -351,140 +352,142 @@ controls_show(Evas_Object *win, Evas_Object *base, Evas_Object *bg,
351 Evas_Object *ct_boxh, *ct_boxv, *ct_box, *ct_box2; 352 Evas_Object *ct_boxh, *ct_boxv, *ct_box, *ct_box2;
352 Controls_Ctx *ctx; 353 Controls_Ctx *ctx;
353 354
354 if (eina_hash_find(controls, &win) || 355 ctx = eina_hash_find(controls, &win);
355 elm_layout_content_get(base, "terminology.controls")) 356 if (ctx)
356 { 357 {
357 donecb(donedata); 358 donecb(donedata);
358 return;
359 } 359 }
360 else
361 {
362 ctx = malloc(sizeof(*ctx));
363 assert(ctx);
364 ctx->win = win;
365 ctx->wn = win_evas_object_to_win(win);
366 ctx->base = base;
367 ctx->bg = bg;
368 ctx->term = term;
369 ctx->donecb = donecb;
370 ctx->donedata = donedata;
371
372 eina_hash_add(controls, &win, ctx);
373
374 ctx->frame = o = elm_frame_add(win);
375 evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
376 evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL);
377 elm_object_text_set(o, _("Controls"));
378
379 ct_boxv = o = elm_box_add(win);
380 elm_box_horizontal_set(o, EINA_FALSE);
381 elm_object_content_set(ctx->frame, o);
382 evas_object_show(o);
360 383
361 ctx = malloc(sizeof(*ctx)); 384 ct_boxh = o = elm_box_add(win);
362 assert(ctx); 385 elm_box_pack_end(ct_boxv, o);
363 ctx->win = win; 386 elm_box_horizontal_set(o, EINA_TRUE);
364 ctx->wn = win_evas_object_to_win(win); 387 evas_object_show(o);
365 ctx->base = base;
366 ctx->bg = bg;
367 ctx->term = term;
368 ctx->donecb = donecb;
369 ctx->donedata = donedata;
370
371 eina_hash_add(controls, &win, ctx);
372
373 ctx->frame = o = elm_frame_add(win);
374 evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
375 evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL);
376 elm_object_text_set(o, _("Controls"));
377
378 ct_boxv = o = elm_box_add(win);
379 elm_box_horizontal_set(o, EINA_FALSE);
380 elm_object_content_set(ctx->frame, o);
381 evas_object_show(o);
382
383 ct_boxh = o = elm_box_add(win);
384 elm_box_pack_end(ct_boxv, o);
385 elm_box_horizontal_set(o, EINA_TRUE);
386 evas_object_show(o);
387 388
388 ct_box = o = elm_box_add(win); 389 ct_box = o = elm_box_add(win);
389 elm_box_pack_end(ct_boxh, o); 390 elm_box_pack_end(ct_boxh, o);
390 evas_object_show(o); 391 evas_object_show(o);
391 392
392 o = _button_add(win, _("New"), "window-new", 393 o = _button_add(win, _("New"), "window-new",
393 _cb_ct_new, ctx); 394 _cb_ct_new, ctx);
394 elm_box_pack_end(ct_box, o); 395 elm_box_pack_end(ct_box, o);
396 ctx->new_btn=o;
395 397
396 o = _sep_add_h(win); 398 o = _sep_add_h(win);
397 elm_box_pack_end(ct_box, o); 399 elm_box_pack_end(ct_box, o);
398 400
399 o = _button_add(win, _("Split V"), "split-v", 401 o = _button_add(win, _("Split V"), "split-v",
400 _cb_ct_split_v, ctx); 402 _cb_ct_split_v, ctx);
401 elm_box_pack_end(ct_box, o); 403 elm_box_pack_end(ct_box, o);
402 404
403 o = _button_add(win, _("Split H"), "split-h", 405 o = _button_add(win, _("Split H"), "split-h",
404 _cb_ct_split_h, ctx); 406 _cb_ct_split_h, ctx);
405 elm_box_pack_end(ct_box, o); 407 elm_box_pack_end(ct_box, o);
406 408
407 o = _sep_add_h(win); 409 o = _sep_add_h(win);
408 elm_box_pack_end(ct_box, o); 410 elm_box_pack_end(ct_box, o);
409 411
410 o = _button_add(win, _("Miniview"), "view-restore", 412 o = _button_add(win, _("Miniview"), "view-restore",
411 _cb_ct_miniview, ctx); 413 _cb_ct_miniview, ctx);
412 elm_box_pack_end(ct_box, o); 414 elm_box_pack_end(ct_box, o);
413 415
414 o = _sep_add_h(win); 416 o = _sep_add_h(win);
415 elm_box_pack_end(ct_box, o); 417 elm_box_pack_end(ct_box, o);
416 418
417 o = _button_add(win, _("Set title"), "format-text-underline", 419 o = _button_add(win, _("Set title"), "format-text-underline",
418 _cb_ct_set_title, ctx); 420 _cb_ct_set_title, ctx);
419 elm_box_pack_end(ct_box, o); 421 elm_box_pack_end(ct_box, o);
420 422
421 o = _sep_add_v(win); 423 o = _sep_add_v(win);
422 elm_box_pack_end(ct_boxh, o); 424 elm_box_pack_end(ct_boxh, o);
423 425
424 ct_box2 = o = elm_box_add(win); 426 ct_box2 = o = elm_box_add(win);
425 elm_box_pack_end(ct_boxh, o); 427 elm_box_pack_end(ct_boxh, o);
426 evas_object_show(o); 428 evas_object_show(o);
427 429
428 o = _button_add(win, _("Copy"), "edit-copy", _cb_ct_copy, ctx); 430 o = _button_add(win, _("Copy"), "edit-copy", _cb_ct_copy, ctx);
429 evas_object_data_set(ctx->frame, "bt_copy", o); 431 evas_object_data_set(ctx->frame, "bt_copy", o);
430 if (!termio_selection_exists(term)) 432 if (!termio_selection_exists(term))
431 elm_object_disabled_set(o, EINA_TRUE); 433 elm_object_disabled_set(o, EINA_TRUE);
432 elm_box_pack_end(ct_box2, o); 434 elm_box_pack_end(ct_box2, o);
433 435
434 o = _button_add(win, _("Paste"), "edit-paste", _cb_ct_paste, ctx); 436 o = _button_add(win, _("Paste"), "edit-paste", _cb_ct_paste, ctx);
435 elm_box_pack_end(ct_box2, o); 437 elm_box_pack_end(ct_box2, o);
436 438
437 o = _sep_add_h(win); 439 o = _sep_add_h(win);
438 elm_box_pack_end(ct_box2, o); 440 elm_box_pack_end(ct_box2, o);
439 441
440 o = _button_add(win, _("Settings"), "preferences-desktop", _cb_ct_options, ctx); 442 o = _button_add(win, _("Settings"), "preferences-desktop", _cb_ct_options, ctx);
441 elm_box_pack_end(ct_box2, o); 443 elm_box_pack_end(ct_box2, o);
442 444
443 o = _sep_add_h(win); 445 o = _sep_add_h(win);
444 elm_box_pack_end(ct_box2, o); 446 elm_box_pack_end(ct_box2, o);
445 447
446 o = _button_add(win, _("About"), "help-about", _cb_ct_about, ctx); 448 o = _button_add(win, _("About"), "help-about", _cb_ct_about, ctx);
447 elm_box_pack_end(ct_box2, o); 449 elm_box_pack_end(ct_box2, o);
448 450
449 o = _sep_add_h(win); 451 o = _sep_add_h(win);
450 elm_box_pack_end(ct_boxv, o); 452 elm_box_pack_end(ct_boxv, o);
451 453
452 o = elm_check_add(win); 454 o = elm_check_add(win);
453 evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, 0.0); 455 evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, 0.0);
454 evas_object_size_hint_align_set(o, EVAS_HINT_FILL, 0.5); 456 evas_object_size_hint_align_set(o, EVAS_HINT_FILL, 0.5);
455 elm_object_text_set(o, _("Grouped input")); 457 elm_object_text_set(o, _("Grouped input"));
456 elm_object_disabled_set(o, win_has_single_child(ctx->wn)); 458 elm_object_disabled_set(o, win_has_single_child(ctx->wn));
457 elm_check_state_set(o, win_is_group_input(ctx->wn)); 459 elm_check_state_set(o, win_is_group_input(ctx->wn));
458 elm_box_pack_end(ct_boxv, o); 460 elm_box_pack_end(ct_boxv, o);
459 evas_object_show(o); 461 evas_object_show(o);
460 ctx->group_input_cx = o; 462 ctx->group_input_cx = o;
461 evas_object_smart_callback_add(o, "changed", 463 evas_object_smart_callback_add(o, "changed",
462 _cb_group_input_changed, ctx); 464 _cb_group_input_changed, ctx);
463 465
464 o = _sep_add_h(win); 466 o = _sep_add_h(win);
465 elm_box_pack_end(ct_boxv, o); 467 elm_box_pack_end(ct_boxv, o);
466 468
467 o = _button_add(win, _("Close Terminal"), "window-close", _cb_ct_close, ctx); 469 o = _button_add(win, _("Close Terminal"), "window-close", _cb_ct_close, ctx);
468 elm_box_pack_end(ct_boxv, o); 470 elm_box_pack_end(ct_boxv, o);
469 471
470 evas_object_smart_callback_add(win, "selection,on", _cb_sel_on, 472 evas_object_smart_callback_add(win, "selection,on", _cb_sel_on,
471 ctx); 473 ctx);
472 evas_object_smart_callback_add(win, "selection,off", _cb_sel_off, 474 evas_object_smart_callback_add(win, "selection,off", _cb_sel_off,
473 ctx); 475 ctx);
474 476
475 elm_layout_content_set(base, "terminology.controls", ctx->frame); 477 elm_layout_content_set(base, "terminology.controls", ctx->frame);
476 evas_object_show(ctx->frame); 478 evas_object_show(ctx->frame);
477 ctx->over = o = evas_object_rectangle_add(evas_object_evas_get(win)); 479 ctx->over = o = evas_object_rectangle_add(evas_object_evas_get(win));
478 evas_object_color_set(o, 0, 0, 0, 0); 480 evas_object_color_set(o, 0, 0, 0, 0);
479 elm_layout_content_set(base, "terminology.dismiss", o); 481 elm_layout_content_set(base, "terminology.dismiss", o);
480 evas_object_show(o); 482 evas_object_show(o);
481 evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_DOWN, 483 evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_DOWN,
482 _cb_mouse_down, ctx); 484 _cb_mouse_down, ctx);
483 485
484 elm_layout_signal_emit(base, "controls,show", "terminology"); 486 elm_layout_signal_emit(base, "controls,show", "terminology");
485 elm_object_focus_set(ctx->frame, EINA_TRUE); 487 evas_object_event_callback_add(ctx->win, EVAS_CALLBACK_DEL, _cb_saved_del, ctx);
486 evas_object_event_callback_add(ctx->win, EVAS_CALLBACK_DEL, _cb_saved_del, ctx); 488 evas_object_event_callback_add(ctx->term, EVAS_CALLBACK_DEL, _cb_saved_del, ctx);
487 evas_object_event_callback_add(ctx->term, EVAS_CALLBACK_DEL, _cb_saved_del, ctx); 489 }
490 elm_object_focus_set(ctx->new_btn, EINA_TRUE);
488} 491}
489 492
490void 493void
diff --git a/src/bin/win.c b/src/bin/win.c
index 42c60d2..f8f82b0 100644
--- a/src/bin/win.c
+++ b/src/bin/win.c
@@ -1379,6 +1379,7 @@ _win_focus(Term_Container *tc, Term_Container *relative)
1379 assert (tc->type == TERM_CONTAINER_TYPE_WIN); 1379 assert (tc->type == TERM_CONTAINER_TYPE_WIN);
1380 1380
1381 wn = (Win*) tc; 1381 wn = (Win*) tc;
1382 elm_object_focus_allow_set(wn->base, EINA_TRUE);
1382 DBG("tc:%p tc->is_focused:%d from_child:%d", 1383 DBG("tc:%p tc->is_focused:%d from_child:%d",
1383 tc, tc->is_focused, wn->child == relative); 1384 tc, tc->is_focused, wn->child == relative);
1384 1385
@@ -1414,6 +1415,8 @@ _win_unfocus(Term_Container *tc, Term_Container *relative)
1414 1415
1415 wn = (Win*) tc; 1416 wn = (Win*) tc;
1416 1417
1418 elm_object_focus_allow_set(wn->base, EINA_FALSE);
1419
1417 DBG("tc:%p tc->is_focused:%d from_child:%d", 1420 DBG("tc:%p tc->is_focused:%d from_child:%d",
1418 tc, tc->is_focused, wn->child == relative); 1421 tc, tc->is_focused, wn->child == relative);
1419 elm_win_keyboard_mode_set(wn->win, ELM_WIN_KEYBOARD_OFF); 1422 elm_win_keyboard_mode_set(wn->win, ELM_WIN_KEYBOARD_OFF);
@@ -7304,10 +7307,11 @@ _cb_options(void *data,
7304 term->wn->on_popover++; 7307 term->wn->on_popover++;
7305 7308
7306 term_ref(term); 7309 term_ref(term);
7307 tc->unfocus(tc, NULL);
7308 7310
7309 controls_show(term->wn->win, term->wn->base, term->bg_edj, term->termio, 7311 controls_show(term->wn->win, term->wn->base, term->bg_edj, term->termio,
7310 _cb_options_done, term); 7312 _cb_options_done, term);
7313
7314 tc->unfocus(tc, NULL);
7311} 7315}
7312 7316
7313void 7317void