~gerboland/miral/release-patched

« back to all changes in this revision

Viewing changes to miral/window_management_trace.cpp

  • Committer: Bileto Bot
  • Date: 2017-01-27 03:02:13 UTC
  • mfrom: (330.2.167 miral0)
  • Revision ID: ci-train-bot@canonical.com-20170127030213-q62prxw1xh7kasbu
* New upstream release 1.1.0 (https://launchpad.net/miral/+milestone/1.1)
  - ABI summary:
    . miral ABI unchanged at 2
  - Enhancements:
    . Compatibility with Mir 0.26 and update API to use the new Mir types and
      enums.
    . Logging of exceptions added to --window-management-trace
    . Rename WindowManagementPolicy::place_new_surface => place_new_window"
  - Bugs fixed:
    . top-level window is not raised along with its child (LP: #1658085)
    . miral-shell depends on default cursor theme being installed
      (LP: #1658159)

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
 
30
30
#define MIR_LOG_COMPONENT "miral::Window Management"
31
31
#include <mir/log.h>
 
32
#include <mir/report_exception.h>
32
33
 
33
34
using mir::operator<<;
34
35
 
 
36
#define MIRAL_TRACE_EXCEPTION \
 
37
catch (std::exception const& x)\
 
38
{\
 
39
    std::stringstream out;\
 
40
    mir::report_exception(out);\
 
41
    mir::log_warning("%s throws %s", __func__, out.str().c_str());\
 
42
    throw;\
 
43
}
 
44
 
 
45
 
35
46
namespace
36
47
{
37
48
std::string const null_ptr{"(null)"};
273
284
    return out.str();
274
285
}
275
286
 
276
 
auto dump_of(MirSurfaceState state) -> std::string
 
287
auto dump_of(MirWindowState state) -> std::string
277
288
{
278
289
    std::stringstream out;
279
290
    out << state;
304
315
}
305
316
 
306
317
auto miral::WindowManagementTrace::count_applications() const -> unsigned int
307
 
{
 
318
try {
308
319
    log_input();
309
320
    auto const result = wrapped.count_applications();
310
321
    mir::log_info("%s -> %d", __func__, result);
311
322
    trace_count++;
312
323
    return result;
313
324
}
 
325
MIRAL_TRACE_EXCEPTION
314
326
 
315
327
void miral::WindowManagementTrace::for_each_application(std::function<void(miral::ApplicationInfo&)> const& functor)
316
 
{
 
328
try {
317
329
    log_input();
318
330
    mir::log_info("%s", __func__);
319
331
    trace_count++;
320
332
    wrapped.for_each_application(functor);
321
333
}
 
334
MIRAL_TRACE_EXCEPTION
322
335
 
323
336
auto miral::WindowManagementTrace::find_application(std::function<bool(ApplicationInfo const& info)> const& predicate)
324
337
-> Application
325
 
{
 
338
try {
326
339
    log_input();
327
340
    auto result = wrapped.find_application(predicate);
328
341
    mir::log_info("%s -> %s", __func__, dump_of(result).c_str());
329
342
    trace_count++;
330
343
    return result;
331
344
}
 
345
MIRAL_TRACE_EXCEPTION
332
346
 
333
347
auto miral::WindowManagementTrace::info_for(std::weak_ptr<mir::scene::Session> const& session) const -> ApplicationInfo&
334
 
{
 
348
try {
335
349
    log_input();
336
350
    auto& result = wrapped.info_for(session);
337
351
    mir::log_info("%s -> %s", __func__, result.application()->name().c_str());
338
352
    trace_count++;
339
353
    return result;
340
354
}
 
355
MIRAL_TRACE_EXCEPTION
341
356
 
342
357
auto miral::WindowManagementTrace::info_for(std::weak_ptr<mir::scene::Surface> const& surface) const -> WindowInfo&
343
 
{
 
358
try {
344
359
    log_input();
345
360
    auto& result = wrapped.info_for(surface);
346
361
    mir::log_info("%s -> %s", __func__, result.name().c_str());
347
362
    trace_count++;
348
363
    return result;
349
364
}
 
365
MIRAL_TRACE_EXCEPTION
350
366
 
351
367
auto miral::WindowManagementTrace::info_for(Window const& window) const -> WindowInfo&
352
 
{
 
368
try {
353
369
    log_input();
354
370
    auto& result = wrapped.info_for(window);
355
371
    mir::log_info("%s -> %s", __func__, result.name().c_str());
356
372
    trace_count++;
357
373
    return result;
358
374
}
 
375
MIRAL_TRACE_EXCEPTION
359
376
 
360
377
void miral::WindowManagementTrace::ask_client_to_close(miral::Window const& window)
361
 
{
 
378
try {
362
379
    log_input();
363
380
    mir::log_info("%s -> %s", __func__, dump_of(window).c_str());
364
381
    trace_count++;
365
382
    wrapped.ask_client_to_close(window);
366
383
}
 
384
MIRAL_TRACE_EXCEPTION
367
385
 
368
386
void miral::WindowManagementTrace::force_close(miral::Window const& window)
369
 
{
 
387
try {
370
388
    log_input();
371
389
    mir::log_info("%s -> %s", __func__, dump_of(window).c_str());
372
390
    trace_count++;
373
391
    wrapped.force_close(window);
374
392
}
 
393
MIRAL_TRACE_EXCEPTION
375
394
 
376
395
auto miral::WindowManagementTrace::active_window() const -> Window
377
 
{
 
396
try {
378
397
    log_input();
379
398
    auto result = wrapped.active_window();
380
399
    mir::log_info("%s -> %s", __func__, dump_of(result).c_str());
381
400
    trace_count++;
382
401
    return result;
383
402
}
 
403
MIRAL_TRACE_EXCEPTION
384
404
 
385
405
auto miral::WindowManagementTrace::select_active_window(Window const& hint) -> Window
386
 
{
 
406
try {
387
407
    log_input();
388
408
    auto result = wrapped.select_active_window(hint);
389
409
    mir::log_info("%s hint=%s -> %s", __func__, dump_of(hint).c_str(), dump_of(result).c_str());
390
410
    trace_count++;
391
411
    return result;
392
412
}
 
413
MIRAL_TRACE_EXCEPTION
393
414
 
394
415
auto miral::WindowManagementTrace::window_at(mir::geometry::Point cursor) const -> Window
395
 
{
 
416
try {
396
417
    log_input();
397
418
    auto result = wrapped.window_at(cursor);
398
419
    std::stringstream out;
401
422
    trace_count++;
402
423
    return result;
403
424
}
 
425
MIRAL_TRACE_EXCEPTION
404
426
 
405
427
auto miral::WindowManagementTrace::active_display() -> mir::geometry::Rectangle const
406
 
{
 
428
try {
407
429
    log_input();
408
430
    auto result = wrapped.active_display();
409
431
    std::stringstream out;
412
434
    trace_count++;
413
435
    return result;
414
436
}
 
437
MIRAL_TRACE_EXCEPTION
415
438
 
416
439
auto miral::WindowManagementTrace::info_for_window_id(std::string const& id) const -> WindowInfo&
417
 
{
 
440
try {
418
441
    log_input();
419
442
    auto& result = wrapped.info_for_window_id(id);
420
443
    mir::log_info("%s id=%s -> %s", __func__, id.c_str(), dump_of(result).c_str());
421
444
    trace_count++;
422
445
    return result;
423
446
}
 
447
MIRAL_TRACE_EXCEPTION
424
448
 
425
449
auto miral::WindowManagementTrace::id_for_window(Window const& window) const -> std::string
426
 
{
 
450
try {
427
451
    log_input();
428
452
    auto result = wrapped.id_for_window(window);
429
453
    mir::log_info("%s window=%s -> %s", __func__, dump_of(window).c_str(), result.c_str());
430
454
    trace_count++;
431
455
    return result;
432
456
}
 
457
MIRAL_TRACE_EXCEPTION
433
458
 
434
459
void miral::WindowManagementTrace::place_and_size_for_state(
435
460
    WindowSpecification& modifications, WindowInfo const& window_info) const
436
 
{
 
461
try {
437
462
    log_input();
438
463
    mir::log_info("%s modifications=%s window_info=%s", __func__, dump_of(modifications).c_str(), dump_of(window_info).c_str());
439
464
    wrapped.place_and_size_for_state(modifications, window_info);
440
465
}
 
466
MIRAL_TRACE_EXCEPTION
441
467
 
442
468
void miral::WindowManagementTrace::drag_active_window(mir::geometry::Displacement movement)
443
 
{
 
469
try {
444
470
    log_input();
445
471
    std::stringstream out;
446
472
    out << movement;
448
474
    trace_count++;
449
475
    wrapped.drag_active_window(movement);
450
476
}
 
477
MIRAL_TRACE_EXCEPTION
451
478
 
452
479
void miral::WindowManagementTrace::focus_next_application()
453
 
{
 
480
try {
454
481
    log_input();
455
482
    mir::log_info("%s", __func__);
456
483
    trace_count++;
457
484
    wrapped.focus_next_application();
458
485
}
 
486
MIRAL_TRACE_EXCEPTION
459
487
 
460
488
void miral::WindowManagementTrace::focus_next_within_application()
461
 
{
 
489
try {
462
490
    log_input();
463
491
    mir::log_info("%s", __func__);
464
492
    trace_count++;
465
493
    wrapped.focus_next_within_application();
466
494
}
 
495
MIRAL_TRACE_EXCEPTION
467
496
 
468
497
void miral::WindowManagementTrace::raise_tree(miral::Window const& root)
469
 
{
 
498
try {
470
499
    log_input();
471
500
    mir::log_info("%s root=%s", __func__, dump_of(root).c_str());
472
501
    trace_count++;
473
502
    wrapped.raise_tree(root);
474
503
}
 
504
MIRAL_TRACE_EXCEPTION
475
505
 
476
506
void miral::WindowManagementTrace::modify_window(
477
507
    miral::WindowInfo& window_info, miral::WindowSpecification const& modifications)
478
 
{
 
508
try {
479
509
    log_input();
480
510
    mir::log_info("%s window_info=%s, modifications=%s",
481
511
                  __func__, dump_of(window_info).c_str(), dump_of(modifications).c_str());
482
512
    trace_count++;
483
513
    wrapped.modify_window(window_info, modifications);
484
514
}
 
515
MIRAL_TRACE_EXCEPTION
485
516
 
486
517
void miral::WindowManagementTrace::invoke_under_lock(std::function<void()> const& callback)
487
 
{
 
518
try {
488
519
    mir::log_info("%s", __func__);
489
520
    wrapped.invoke_under_lock(callback);
490
521
}
 
522
MIRAL_TRACE_EXCEPTION
491
523
 
492
 
auto miral::WindowManagementTrace::place_new_surface(
 
524
auto miral::WindowManagementTrace::place_new_window(
493
525
    ApplicationInfo const& app_info,
494
526
    WindowSpecification const& requested_specification) -> WindowSpecification
495
 
{
496
 
    auto const result = policy->place_new_surface(app_info, requested_specification);
 
527
try {
 
528
    auto const result = policy->place_new_window(app_info, requested_specification);
497
529
    mir::log_info("%s app_info=%s, requested_specification=%s -> %s",
498
530
              __func__, dump_of(app_info).c_str(), dump_of(requested_specification).c_str(), dump_of(result).c_str());
499
531
    return result;
500
532
}
 
533
MIRAL_TRACE_EXCEPTION
501
534
 
502
535
void miral::WindowManagementTrace::handle_window_ready(miral::WindowInfo& window_info)
503
 
{
 
536
try {
504
537
    mir::log_info("%s window_info=%s", __func__, dump_of(window_info).c_str());
505
538
    policy->handle_window_ready(window_info);
506
539
}
 
540
MIRAL_TRACE_EXCEPTION
507
541
 
508
542
void miral::WindowManagementTrace::handle_modify_window(
509
543
    miral::WindowInfo& window_info, miral::WindowSpecification const& modifications)
510
 
{
 
544
try {
511
545
    mir::log_info("%s window_info=%s, modifications=%s",
512
546
                  __func__, dump_of(window_info).c_str(), dump_of(modifications).c_str());
513
547
    policy->handle_modify_window(window_info, modifications);
514
548
}
 
549
MIRAL_TRACE_EXCEPTION
515
550
 
516
551
void miral::WindowManagementTrace::handle_raise_window(miral::WindowInfo& window_info)
517
 
{
 
552
try {
518
553
    mir::log_info("%s window_info=%s", __func__, dump_of(window_info).c_str());
519
554
    policy->handle_raise_window(window_info);
520
555
}
 
556
MIRAL_TRACE_EXCEPTION
521
557
 
522
558
bool miral::WindowManagementTrace::handle_keyboard_event(MirKeyboardEvent const* event)
523
 
{
 
559
try {
524
560
    log_input = [event, this]
525
561
        {
526
562
            mir::log_info("handle_keyboard_event event=%s", dump_of(event).c_str());
529
565
 
530
566
    return policy->handle_keyboard_event(event);
531
567
}
 
568
MIRAL_TRACE_EXCEPTION
532
569
 
533
570
bool miral::WindowManagementTrace::handle_touch_event(MirTouchEvent const* event)
534
 
{
 
571
try {
535
572
    log_input = [event, this]
536
573
        {
537
574
            mir::log_info("handle_touch_event event=%s", dump_of(event).c_str());
540
577
 
541
578
    return policy->handle_touch_event(event);
542
579
}
 
580
MIRAL_TRACE_EXCEPTION
543
581
 
544
582
bool miral::WindowManagementTrace::handle_pointer_event(MirPointerEvent const* event)
545
 
{
 
583
try {
546
584
    log_input = [event, this]
547
585
        {
548
586
            mir::log_info("handle_pointer_event event=%s", dump_of(event).c_str());
551
589
 
552
590
    return policy->handle_pointer_event(event);
553
591
}
 
592
MIRAL_TRACE_EXCEPTION
554
593
 
555
594
auto miral::WindowManagementTrace::confirm_inherited_move(WindowInfo const& window_info, Displacement movement)
556
595
-> Rectangle
557
 
{
 
596
try {
558
597
    std::stringstream out;
559
598
    out << movement;
560
599
    mir::log_info("%s window_info=%s, movement=%s", __func__, dump_of(window_info).c_str(), out.str().c_str());
561
600
 
562
601
    return policy->confirm_inherited_move(window_info, movement);
563
602
}
 
603
MIRAL_TRACE_EXCEPTION
564
604
 
565
605
void miral::WindowManagementTrace::advise_begin()
566
 
{
 
606
try {
567
607
    log_input = []{};
568
608
    trace_count.store(0);
569
609
    policy->advise_begin();
570
610
}
 
611
MIRAL_TRACE_EXCEPTION
571
612
 
572
613
void miral::WindowManagementTrace::advise_end()
573
 
{
 
614
try {
574
615
    if (trace_count.load() > 0)
575
616
        mir::log_info("====");
576
617
    policy->advise_end();
577
618
}
 
619
MIRAL_TRACE_EXCEPTION
578
620
 
579
621
void miral::WindowManagementTrace::advise_new_app(miral::ApplicationInfo& application)
580
 
{
 
622
try {
581
623
    mir::log_info("%s application=%s", __func__, dump_of(application).c_str());
582
624
    policy->advise_new_app(application);
583
625
}
 
626
MIRAL_TRACE_EXCEPTION
584
627
 
585
628
void miral::WindowManagementTrace::advise_delete_app(miral::ApplicationInfo const& application)
586
 
{
 
629
try {
587
630
    mir::log_info("%s application=%s", __func__, dump_of(application).c_str());
588
631
    policy->advise_delete_app(application);
589
632
}
 
633
MIRAL_TRACE_EXCEPTION
590
634
 
591
635
void miral::WindowManagementTrace::advise_new_window(miral::WindowInfo const& window_info)
592
 
{
 
636
try {
593
637
    mir::log_info("%s window_info=%s", __func__, dump_of(window_info).c_str());
594
638
    policy->advise_new_window(window_info);
595
639
}
 
640
MIRAL_TRACE_EXCEPTION
596
641
 
597
642
void miral::WindowManagementTrace::advise_focus_lost(miral::WindowInfo const& window_info)
598
 
{
 
643
try {
599
644
    mir::log_info("%s window_info=%s", __func__, dump_of(window_info).c_str());
600
645
    policy->advise_focus_lost(window_info);
601
646
}
 
647
MIRAL_TRACE_EXCEPTION
602
648
 
603
649
void miral::WindowManagementTrace::advise_focus_gained(miral::WindowInfo const& window_info)
604
 
{
 
650
try {
605
651
    mir::log_info("%s window_info=%s", __func__, dump_of(window_info).c_str());
606
652
    policy->advise_focus_gained(window_info);
607
653
}
 
654
MIRAL_TRACE_EXCEPTION
608
655
 
609
 
void miral::WindowManagementTrace::advise_state_change(miral::WindowInfo const& window_info, MirSurfaceState state)
610
 
{
 
656
void miral::WindowManagementTrace::advise_state_change(miral::WindowInfo const& window_info, MirWindowState state)
 
657
try {
611
658
    mir::log_info("%s window_info=%s, state=%s", __func__, dump_of(window_info).c_str(), dump_of(state).c_str());
612
659
    policy->advise_state_change(window_info, state);
613
660
}
 
661
MIRAL_TRACE_EXCEPTION
614
662
 
615
663
void miral::WindowManagementTrace::advise_move_to(miral::WindowInfo const& window_info, mir::geometry::Point top_left)
616
 
{
 
664
try {
617
665
    mir::log_info("%s window_info=%s, top_left=%s", __func__, dump_of(window_info).c_str(), dump_of(top_left).c_str());
618
666
    policy->advise_move_to(window_info, top_left);
619
667
}
 
668
MIRAL_TRACE_EXCEPTION
620
669
 
621
670
void miral::WindowManagementTrace::advise_resize(miral::WindowInfo const& window_info, mir::geometry::Size const& new_size)
622
 
{
 
671
try {
623
672
    mir::log_info("%s window_info=%s, new_size=%s", __func__, dump_of(window_info).c_str(), dump_of(new_size).c_str());
624
673
    policy->advise_resize(window_info, new_size);
625
674
}
 
675
MIRAL_TRACE_EXCEPTION
626
676
 
627
677
void miral::WindowManagementTrace::advise_delete_window(miral::WindowInfo const& window_info)
628
 
{
 
678
try {
629
679
    mir::log_info("%s window_info=%s", __func__, dump_of(window_info).c_str());
630
680
    policy->advise_delete_window(window_info);
631
681
}
 
682
MIRAL_TRACE_EXCEPTION
632
683
 
633
684
void miral::WindowManagementTrace::advise_raise(std::vector<miral::Window> const& windows)
634
 
{
 
685
try {
635
686
    mir::log_info("%s window_info=%s", __func__, dump_of(windows).c_str());
636
687
    policy->advise_raise(windows);
637
688
}
 
689
MIRAL_TRACE_EXCEPTION