Mir
server_example_input_event_filter.cpp

Demonstrate a custom input by making Ctrl+Alt+BkSp stop the server

/*
* Copyright © 2014 Canonical Ltd.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Authored By: Alan Griffiths <alan@octopull.co.uk>
*/
#include "mir/server.h"
#include <linux/input.h>
namespace me = mir::examples;
me::QuitFilter::QuitFilter(std::function<void()> const& quit_action)
: quit_action{quit_action}
{
}
bool me::QuitFilter::handle(MirEvent const& event)
{
return false;
MirInputEvent const* input_event = mir_event_get_input_event(&event);
return false;
return false;
return false;
if (mir_keyboard_event_scan_code(kev) == KEY_BACKSPACE)
{
quit_action();
return true;
}
return false;
}
-> std::shared_ptr<mir::input::EventFilter>
{
auto const quit_filter = std::make_shared<me::QuitFilter>([&]{ server.stop(); });
server.add_init_callback([quit_filter, &server]
{ server.the_composite_event_filter()->append(quit_filter); });
return quit_filter;
}

Copyright © 2012-2015 Canonical Ltd.
Generated on Wed Mar 30 00:29:56 UTC 2016