~thomas-moenicke/phablet-extras/maliit-plugins_fix_focus_out

« back to all changes in this revision

Viewing changes to maliit-keyboard/plugin/inputmethod.cpp

branch to get the new maliit-keyboard.

Approved by Bill Filler, PS Jenkins bot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
45
45
#include "logic/style.h"
46
46
#include "logic/languagefeatures.h"
47
47
#include "logic/eventhandler.h"
 
48
#include "logic/keyareaconverter.h"
48
49
 
49
50
#include "view/glass.h"
50
51
#include "view/setup.h"
68
69
#include <QDesktopWidget>
69
70
#include <QtQuick>
70
71
 
 
72
#ifdef QT_OPENGL_ES_2
 
73
#include <ubuntu/ui/ubuntu_ui_session_service.h>
 
74
  #define HAVE_UBUNTU_PLATFORM_API
 
75
#endif
 
76
 
71
77
class MImUpdateEvent;
72
78
 
73
79
namespace MaliitKeyboard {
154
160
    LayoutGroup extended_layout;
155
161
    Model::Layout magnifier_layout;
156
162
    MaliitContext context;
 
163
    QRect keyboardSurfaceRect;
157
164
 
158
165
    explicit InputMethodPrivate(InputMethod * const q,
159
166
                                MAbstractInputMethodHost *host);
160
167
    void setLayoutOrientation(Logic::LayoutHelper::Orientation orientation);
 
168
    void updateKeyboardOrientation();
161
169
    void syncWordEngine(Logic::LayoutHelper::Orientation orientation);
162
170
 
163
171
    void connectToNotifier();
220
228
    setContextProperties(magnifier_engine->rootContext());
221
229
 
222
230
    magnifier_surface->view()->setSource(QUrl::fromLocalFile(g_maliit_magnifier_qml));
 
231
 
 
232
    surface->view()->setProperty("role", 7);
223
233
}
224
234
 
225
235
 
228
238
    syncWordEngine(orientation);
229
239
    layout.updater.setOrientation(orientation);
230
240
    extended_layout.updater.setOrientation(orientation);
231
 
}
232
 
 
 
241
 
 
242
    keyboardSurfaceRect = uiConst->keyboardSurfaceRect(orientation);
 
243
}
 
244
 
 
245
void InputMethodPrivate::updateKeyboardOrientation()
 
246
{
 
247
    Qt::ScreenOrientation o;
 
248
 
 
249
    if ( QGuiApplication::primaryScreen()->orientation() == Qt::PrimaryOrientation )
 
250
        o = QGuiApplication::primaryScreen()->primaryOrientation();
 
251
    else
 
252
        o = QGuiApplication::primaryScreen()->orientation();
 
253
 
 
254
    setLayoutOrientation(o == Qt::LandscapeOrientation
 
255
                            ? Logic::LayoutHelper::Landscape : Logic::LayoutHelper::Portrait);
 
256
}
233
257
 
234
258
void InputMethodPrivate::syncWordEngine(Logic::LayoutHelper::Orientation orientation)
235
259
{
330
354
 
331
355
    // Setting layout orientation depends on word engine and hide word ribbon
332
356
    // settings to be initialized first:
333
 
    const QSize &screen_size(d->surface_factory->screenSize());
334
 
    d->setLayoutOrientation(screen_size.width() >= screen_size.height()
335
 
                            ? Logic::LayoutHelper::Landscape : Logic::LayoutHelper::Portrait);
 
357
 
 
358
    d->updateKeyboardOrientation();
336
359
}
337
360
 
338
361
InputMethod::~InputMethod()
348
371
    d->surface->show();
349
372
    d->extended_surface->show();
350
373
    d->magnifier_surface->show();
 
374
 
 
375
#ifdef HAVE_UBUNTU_PLATFORM_API
 
376
    ubuntu_ui_report_osk_visible(
 
377
                d->keyboardSurfaceRect.x(),
 
378
                d->keyboardSurfaceRect.y(),
 
379
                d->keyboardSurfaceRect.width(),
 
380
                d->keyboardSurfaceRect.height()
 
381
                );
 
382
#endif
351
383
}
352
384
 
353
385
void InputMethod::hide()
358
390
    d->surface->hide();
359
391
    d->extended_surface->hide();
360
392
    d->magnifier_surface->hide();
 
393
 
 
394
#ifdef HAVE_UBUNTU_PLATFORM_API
 
395
    ubuntu_ui_report_osk_invisible();
 
396
#endif
361
397
}
362
398
 
363
399
void InputMethod::setPreedit(const QString &preedit,
415
451
void InputMethod::handleAppOrientationChanged(int angle)
416
452
{
417
453
    Q_D(InputMethod);
418
 
    d->setLayoutOrientation((angle == 0 || angle == 180)
419
 
                            ? Logic::LayoutHelper::Landscape
420
 
                            : Logic::LayoutHelper::Portrait);
 
454
 
 
455
    d->updateKeyboardOrientation();
421
456
}
422
457
 
423
458
bool InputMethod::imExtensionEvent(MImExtensionEvent *event)
586
621
    d->layout.helper.setScreenSize(size);
587
622
    d->extended_layout.helper.setScreenSize(d->layout.helper.screenSize());
588
623
 
589
 
    d->setLayoutOrientation(size.width() >= size.height()
590
 
                            ? Logic::LayoutHelper::Landscape : Logic::LayoutHelper::Portrait);
 
624
    d->updateKeyboardOrientation();
591
625
}
592
626
 
593
627
void InputMethod::onStyleSettingChanged()