~brandontschaefer/mir/improve-capnproto-cmake-find

« back to all changes in this revision

Viewing changes to src/server/frontend/wayland/wayland_connector.cpp

  • Committer: Tarmac
  • Author(s): Alan Griffiths
  • Date: 2017-09-22 22:45:15 UTC
  • mfrom: (4252.2.8 mir2)
  • Revision ID: tarmac-20170922224515-qnk0p8868zgut0ei
Handle focus events in the Wayland frontend (so that keyboard input works). Fixes: https://bugs.launchpad.net/bugs/1718632.

Approved by mir-ci-bot, Gerry Boland.

Show diffs side-by-side

added added

removed removed

Lines of Context:
786
786
            });
787
787
    }
788
788
 
 
789
    void handle_event(MirWindowEvent const* event, wl_resource* target)
 
790
    {
 
791
        if (mir_window_event_get_attribute(event) == mir_window_attrib_focus)
 
792
        {
 
793
            executor->spawn(
 
794
               [resource = resource, serial = wl_display_next_serial(wl_client_get_display(client)),
 
795
                target = target, focussed = mir_window_event_get_attribute_value(event)]()
 
796
                {
 
797
                    if (focussed)
 
798
                    {
 
799
                        wl_array key_state;
 
800
                        wl_array_init(&key_state);
 
801
                        wl_keyboard_send_enter(resource, serial, target, &key_state);
 
802
                        wl_array_release(&key_state);
 
803
                    }
 
804
                    else
 
805
                    {
 
806
                        wl_keyboard_send_leave(resource, serial, target);
 
807
                    }
 
808
                });
 
809
        }
 
810
    }
 
811
 
789
812
private:
790
813
    std::shared_ptr<mir::Executor> const executor;
791
814
 
998
1021
        }
999
1022
    }
1000
1023
 
 
1024
    void handle_event(MirWindowEvent const* event, wl_resource* target) const
 
1025
    {
 
1026
        for (auto& listener : listeners)
 
1027
        {
 
1028
            listener->handle_event(event, target);
 
1029
        }
 
1030
    }
 
1031
 
1001
1032
private:
1002
1033
    std::vector<std::shared_ptr<InputInterface>> listeners;
1003
1034
};
1214
1245
        default:
1215
1246
            break;
1216
1247
        }
 
1248
        break;
 
1249
    }
 
1250
    case mir_event_type_window:
 
1251
    {
 
1252
        auto const wev = mir_event_get_window_event(&event);
 
1253
 
 
1254
        seat->acquire_keyboard_reference(client).handle_event(wev, target);
1217
1255
    }
1218
1256
    default:
1219
1257
        break;