Merge lp:~robertcarr/unity-mir/default-input-focus into lp:unity-mir

Proposed by Robert Carr
Status: Superseded
Proposed branch: lp:~robertcarr/unity-mir/default-input-focus
Merge into: lp:unity-mir
Diff against target: 233 lines (+140/-2)
6 files modified
src/modules/Unity/Application/mirsurfacemanager.cpp (+4/-0)
src/unity-mir/focussetter.cpp (+56/-0)
src/unity-mir/focussetter.h (+56/-0)
src/unity-mir/shellserverconfiguration.cpp (+16/-0)
src/unity-mir/shellserverconfiguration.h (+4/-0)
src/unity-mir/unity-mir.pro (+4/-2)
To merge this branch: bzr merge lp:~robertcarr/unity-mir/default-input-focus
Reviewer Review Type Date Requested Status
Gerry Boland (community) code review Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+189733@code.launchpad.net

This proposal has been superseded by a proposal from 2013-10-08.

Commit message

Focus the shell when no sessions are focused.

It's difficult with the current architecture for the shell to receive keyboard focus, as it does not have an associated application session. Work around this by implementing a defaulting FocusSetter, which assigns keyboard focus to the shell surface when focus would otherwise be cleared.

Description of the change

It's difficult with the current architecture for the shell to receive keyboard focus, as it does not have an associated application session. Work around this by implementing a defaulting FocusSetter, which assigns keyboard focus to the shell surface when focus would otherwise be cleared.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Gerry Boland (gerboland) wrote :

Please adjust commit message to prepend a short description of the change - the discursive bit afterwards is fine.

+std::shared_ptr<mir::shell::FocusSetter> the_shell_focus_setter() override;
please fix the indent.

Code looks clean. Otherwise.

review: Approve (code review)

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/modules/Unity/Application/mirsurfacemanager.cpp'
--- src/modules/Unity/Application/mirsurfacemanager.cpp 2013-09-06 05:34:01 +0000
+++ src/modules/Unity/Application/mirsurfacemanager.cpp 2013-10-07 23:19:43 +0000
@@ -28,6 +28,7 @@
28#include "sessionlistener.h"28#include "sessionlistener.h"
29#include "surfaceconfigurator.h"29#include "surfaceconfigurator.h"
30#include "surfacesource.h"30#include "surfacesource.h"
31#include "focussetter.h"
31#include "logging.h"32#include "logging.h"
3233
33namespace msh = mir::shell;34namespace msh = mir::shell;
@@ -125,6 +126,9 @@
125{126{
126 DLOG("MirSurfaceManager::shellSurfaceCreated (this=%p)", this);127 DLOG("MirSurfaceManager::shellSurfaceCreated (this=%p)", this);
127 m_shellSurface = new MirSurface(surface, nullptr);128 m_shellSurface = new MirSurface(surface, nullptr);
129
130 m_mirServer->focusSetter()->set_default_keyboard_target(surface);
131
128 Q_EMIT shellSurfaceChanged(m_shellSurface);132 Q_EMIT shellSurfaceChanged(m_shellSurface);
129}133}
130134
131135
=== added file 'src/unity-mir/focussetter.cpp'
--- src/unity-mir/focussetter.cpp 1970-01-01 00:00:00 +0000
+++ src/unity-mir/focussetter.cpp 2013-10-07 23:19:43 +0000
@@ -0,0 +1,56 @@
1/*
2 * Copyright (C) 2013 Canonical, Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it under
5 * the terms of the GNU Lesser General Public License version 3, as published by
6 * the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
10 * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#include <mir/shell/surface.h>
18
19#include "focussetter.h"
20#include "logging.h"
21
22namespace msh = mir::shell;
23
24FocusSetter::FocusSetter(std::shared_ptr<msh::FocusSetter> const& underlying_setter, std::shared_ptr<mir::shell::InputTargeter> const& keyboard_input_targeter, QObject *parent)
25 : QObject(parent),
26 underlying_setter(underlying_setter),
27 keyboard_input_targeter(keyboard_input_targeter)
28{
29}
30
31FocusSetter::~FocusSetter()
32{
33}
34
35void FocusSetter::set_focus_to(std::shared_ptr<msh::Session> const& session)
36{
37 // Ensure we always call the underlying setter to dispatch focus/unfocus notifications.
38 underlying_setter->set_focus_to(session);
39 if (session == nullptr)
40 {
41 auto default_target = default_keyboard_target.lock();
42 if (!default_target)
43 return;
44 default_target->take_input_focus(keyboard_input_targeter);
45 }
46}
47
48void FocusSetter::set_default_keyboard_target(std::weak_ptr<msh::Surface> const& default_target)
49{
50 auto t = default_target.lock();
51 assert(t);
52
53 default_keyboard_target = default_target;
54
55 t->take_input_focus(keyboard_input_targeter);
56}
057
=== added file 'src/unity-mir/focussetter.h'
--- src/unity-mir/focussetter.h 1970-01-01 00:00:00 +0000
+++ src/unity-mir/focussetter.h 2013-10-07 23:19:43 +0000
@@ -0,0 +1,56 @@
1/*
2 * Copyright (C) 2013 Canonical, Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it under
5 * the terms of the GNU Lesser General Public License version 3, as published by
6 * the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
10 * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#ifndef FOCUSSETTER_H
18#define FOCUSSETTER_H
19
20// mir
21#include <mir/shell/focus_setter.h>
22
23// Qt
24#include <QObject>
25
26namespace mir
27{
28namespace shell
29{
30class InputTargeter;
31class Surface;
32}
33}
34
35class FocusSetter : public QObject, public mir::shell::FocusSetter
36{
37 Q_OBJECT
38
39public:
40 FocusSetter(std::shared_ptr<mir::shell::FocusSetter> const& underlying_setter, std::shared_ptr<mir::shell::InputTargeter> const& keyboard_input_targeter,
41 QObject *parent = 0);
42 ~FocusSetter();
43
44 void set_focus_to(std::shared_ptr<mir::shell::Session> const& session) override;
45
46 // We support a surface to be given key input when focus is otherwise to be cleared.
47 void set_default_keyboard_target(std::weak_ptr<mir::shell::Surface> const& default_keyboard_target);
48
49private:
50 std::shared_ptr<mir::shell::FocusSetter> const underlying_setter;
51 std::shared_ptr<mir::shell::InputTargeter> const keyboard_input_targeter;
52
53 std::weak_ptr<mir::shell::Surface> default_keyboard_target;
54};
55
56#endif // FOCUSSETTER_H
057
=== modified file 'src/unity-mir/shellserverconfiguration.cpp'
--- src/unity-mir/shellserverconfiguration.cpp 2013-08-21 23:10:11 +0000
+++ src/unity-mir/shellserverconfiguration.cpp 2013-10-07 23:19:43 +0000
@@ -22,6 +22,7 @@
22#include "surfacesource.h"22#include "surfacesource.h"
23#include "sessionauthorizer.h"23#include "sessionauthorizer.h"
24#include "surfacecontroller.h"24#include "surfacecontroller.h"
25#include "focussetter.h"
25#include "logging.h"26#include "logging.h"
2627
27// mir28// mir
@@ -107,6 +108,16 @@
107 });108 });
108}109}
109110
111std::shared_ptr<msh::FocusSetter>
112ShellServerConfiguration::the_shell_focus_setter()
113{
114 return shell_focus_setter(
115 [this]
116 {
117 return std::make_shared<FocusSetter>(DefaultServerConfiguration::the_shell_focus_setter(), the_input_targeter());
118 });
119}
120
110/************************************ Shell side ************************************/121/************************************ Shell side ************************************/
111SessionAuthorizer *ShellServerConfiguration::sessionAuthorizer()122SessionAuthorizer *ShellServerConfiguration::sessionAuthorizer()
112{123{
@@ -130,3 +141,8 @@
130{141{
131 return m_surfaceSource.get();142 return m_surfaceSource.get();
132}143}
144
145FocusSetter *ShellServerConfiguration::focusSetter()
146{
147 return static_cast<FocusSetter*>(the_shell_focus_setter().get());
148}
133149
=== modified file 'src/unity-mir/shellserverconfiguration.h'
--- src/unity-mir/shellserverconfiguration.h 2013-08-21 23:10:11 +0000
+++ src/unity-mir/shellserverconfiguration.h 2013-10-07 23:19:43 +0000
@@ -20,6 +20,8 @@
20#include <QObject>20#include <QObject>
21#include <mir/default_server_configuration.h>21#include <mir/default_server_configuration.h>
2222
23
24class FocusSetter;
23class SessionListener;25class SessionListener;
24class SessionAuthorizer;26class SessionAuthorizer;
25class SurfaceSource;27class SurfaceSource;
@@ -43,6 +45,7 @@
43 std::shared_ptr<mir::shell::SessionListener> the_shell_session_listener() override;45 std::shared_ptr<mir::shell::SessionListener> the_shell_session_listener() override;
44 std::shared_ptr<mir::shell::SurfaceConfigurator> the_shell_surface_configurator() override;46 std::shared_ptr<mir::shell::SurfaceConfigurator> the_shell_surface_configurator() override;
45 std::shared_ptr<mir::shell::SurfaceFactory> the_shell_surface_factory() override;47 std::shared_ptr<mir::shell::SurfaceFactory> the_shell_surface_factory() override;
48std::shared_ptr<mir::shell::FocusSetter> the_shell_focus_setter() override;
46 std::shared_ptr<mir::frontend::SessionAuthorizer> the_session_authorizer() override;49 std::shared_ptr<mir::frontend::SessionAuthorizer> the_session_authorizer() override;
47 std::shared_ptr<mir::surfaces::SurfaceController> the_surface_controller() override;50 std::shared_ptr<mir::surfaces::SurfaceController> the_surface_controller() override;
4851
@@ -52,6 +55,7 @@
52 SessionListener *sessionListener();55 SessionListener *sessionListener();
53 SurfaceConfigurator *surfaceConfigurator();56 SurfaceConfigurator *surfaceConfigurator();
54 SurfaceSource *surfaceSource();57 SurfaceSource *surfaceSource();
58 FocusSetter *focusSetter();
5559
56protected:60protected:
57 std::shared_ptr<SurfaceSource> m_surfaceSource;61 std::shared_ptr<SurfaceSource> m_surfaceSource;
5862
=== modified file 'src/unity-mir/unity-mir.pro'
--- src/unity-mir/unity-mir.pro 2013-09-26 09:51:23 +0000
+++ src/unity-mir/unity-mir.pro 2013-10-07 23:19:43 +0000
@@ -23,7 +23,8 @@
23 shellserverconfiguration.cpp \23 shellserverconfiguration.cpp \
24 surfacecontroller.cpp \24 surfacecontroller.cpp \
25 surfacesource.cpp \25 surfacesource.cpp \
26 surfaceconfigurator.cpp26 surfaceconfigurator.cpp \
27 focussetter.cpp
2728
28HEADERS += \29HEADERS += \
29 dbusscreen.h \30 dbusscreen.h \
@@ -36,7 +37,8 @@
36 surfacecontroller.h \37 surfacecontroller.h \
37 surfacesource.h \38 surfacesource.h \
38 surfaceconfigurator.h \39 surfaceconfigurator.h \
39 logging.h40 logging.h \
41 focussetter.h
4042
41target.path = $$[QT_INSTALL_LIBS]43target.path = $$[QT_INSTALL_LIBS]
4244

Subscribers

People subscribed via source and target branches