Qt 4.8
Macros | Enumerations | Functions | Variables
qbbinputcontext_imf.cpp File Reference
#include <qbbeventthread.h>
#include <qbbinputcontext.h>
#include <qbbabstractvirtualkeyboard.h>
#include <QAction>
#include <QCoreApplication>
#include <QDebug>
#include <QInputMethodEvent>
#include <QMutex>
#include <QTextCharFormat>
#include <QVariant>
#include <QVariantHash>
#include <QWaitCondition>
#include <dlfcn.h>
#include "imf/imf_client.h"
#include "imf/input_control.h"
#include <process.h>
#include <sys/keycodes.h>

Go to the source code of this file.

Macros

#define getarg(type, name)   type name = imfEvent->mArgs[qs(#name)].value<type>()
 
#define getparg(type, name)   type name = (type)(imfEvent->mArgs[qs(#name)].value<void*>())
 
#define iarg(name)   event->mArgs[qs(#name)] = QVariant::fromValue(name)
 
#define parg(name)   event->mArgs[qs(#name)] = QVariant::fromValue((void*)name)
 
#define qs(x)   QString::fromLatin1(x)
 
#define STR(x)   STRX(x)
 
#define STRX(x)   #x
 
#define TAG   __FILE__ "(" STR(__LINE__) ")" << __func__ << ":"
 

Enumerations

enum  ImfEventType
 

Functions

static bool imfAvailable ()
 

Variables

static void(* p_ictrl_close_session )(input_session_t *)=0
 
static int32_t(* p_ictrl_dispatch_event )(event_t *)=0
 
static int32_t(* p_ictrl_get_num_active_sessions )()=0
 
static const input_session_t *(* p_ictrl_open_session )(connection_interface_t *)=0
 
static void(* p_imf_client_disconnect )()=0
 
static int32_t(* p_imf_client_init )()=0
 
static int32_t(* p_vkb_init_selection_service )()=0
 
static bool s_imfInitFailed = false
 

Macro Definition Documentation

◆ getarg

#define getarg (   type,
  name 
)    type name = imfEvent->mArgs[qs(#name)].value<type>()

Definition at line 719 of file qbbinputcontext_imf.cpp.

Referenced by QBBInputContext::eventFilter().

◆ getparg

#define getparg (   type,
  name 
)    type name = (type)(imfEvent->mArgs[qs(#name)].value<void*>())

Definition at line 720 of file qbbinputcontext_imf.cpp.

Referenced by QBBInputContext::eventFilter().

◆ iarg

#define iarg (   name)    event->mArgs[qs(#name)] = QVariant::fromValue(name)

Definition at line 76 of file qbbinputcontext_imf.cpp.

◆ parg

#define parg (   name)    event->mArgs[qs(#name)] = QVariant::fromValue((void*)name)

Definition at line 77 of file qbbinputcontext_imf.cpp.

◆ qs

#define qs (   x)    QString::fromLatin1(x)

Definition at line 75 of file qbbinputcontext_imf.cpp.

◆ STR

#define STR (   x)    STRX(x)

Definition at line 49 of file qbbinputcontext_imf.cpp.

◆ STRX

#define STRX (   x)    #x

Definition at line 48 of file qbbinputcontext_imf.cpp.

◆ TAG

#define TAG   __FILE__ "(" STR(__LINE__) ")" << __func__ << ":"

Enumeration Type Documentation

◆ ImfEventType

Definition at line 88 of file qbbinputcontext_imf.cpp.

89 {
90  ImfBeginBatchEdit,
91  ImfClearMetaKeyStates,
92  ImfCommitText,
93  ImfDeleteSurroundingText,
94  ImfEndBatchEdit,
95  ImfFinishComposingText,
96  ImfGetCursorCapsMode,
97  ImfGetCursorPosition,
98  ImfGetExtractedText,
99  ImfGetSelectedText,
100  ImfGetTextAfterCursor,
101  ImfGetTextBeforeCursor,
102  ImfPerformEditorAction,
103  ImfReportFullscreenMode,
104  ImfSendEvent,
105  ImfSendAsyncEvent,
106  ImfSetComposingRegion,
107  ImfSetComposingText,
108  ImfSetSelection
109 };

Function Documentation

◆ imfAvailable()

static bool imfAvailable ( )
static

Definition at line 637 of file qbbinputcontext_imf.cpp.

Referenced by QBBInputContext::closeSession(), QBBInputContext::dispatchFocusEvent(), QBBInputContext::dispatchRequestSoftwareInputPanel(), QBBInputContext::endComposition(), QBBInputContext::handleKeyboardEvent(), QBBInputContext::openSession(), QBBInputContext::QBBInputContext(), and QBBInputContext::~QBBInputContext().

638 {
639  static bool s_imfDisabled = getenv("DISABLE_IMF") != NULL;
640  static bool s_imfReady = false;
641 
642  if ( s_imfInitFailed || s_imfDisabled) {
643  return false;
644  }
645  else if ( s_imfReady ) {
646  return true;
647  }
648 
649  if ( p_imf_client_init == NULL ) {
650  void *handle = dlopen("libinput_client.so.1", 0);
651  if ( handle ) {
652  p_imf_client_init = (int32_t (*)()) dlsym(handle, "imf_client_init");
653  p_imf_client_disconnect = (void (*)()) dlsym(handle, "imf_client_disconnect");
654  p_ictrl_open_session = (const input_session_t* (*)(connection_interface_t*))dlsym(handle, "ictrl_open_session");
655  p_ictrl_close_session = (void (*)(input_session_t*))dlsym(handle, "ictrl_close_session");
656  p_ictrl_dispatch_event = (int32_t (*)(event_t*))dlsym(handle, "ictrl_dispatch_event");
657  p_vkb_init_selection_service = (int32_t (*)())dlsym(handle, "vkb_init_selection_service");
658  p_ictrl_get_num_active_sessions = (int32_t (*)())dlsym(handle, "ictrl_get_num_active_sessions");
659  }
660  else
661  {
662  qCritical() << TAG << "libinput_client.so.1 is not present - IMF services are disabled.";
663  s_imfDisabled = true;
664  return false;
665  }
667  s_imfReady = true;
668  }
669  else {
670  p_ictrl_open_session = NULL;
671  p_ictrl_dispatch_event = NULL;
672  s_imfDisabled = true;
673  qCritical() << TAG << "libinput_client.so.1 did not contain the correct symbols, library mismatch? IMF services are disabled.";
674  return false;
675  }
676  }
677 
678  return s_imfReady;
679 }
static const input_session_t *(* p_ictrl_open_session)(connection_interface_t *)=0
static void(* p_imf_client_disconnect)()=0
#define TAG
static int32_t(* p_ictrl_get_num_active_sessions)()=0
static bool s_imfInitFailed
static int32_t(* p_vkb_init_selection_service)()=0
static int32_t(* p_ictrl_dispatch_event)(event_t *)=0
static void(* p_ictrl_close_session)(input_session_t *)=0
static int32_t(* p_imf_client_init)()=0
Q_CORE_EXPORT void qCritical(const char *,...)

Variable Documentation

◆ p_ictrl_close_session

void(* p_ictrl_close_session) (input_session_t *)=0
static

Definition at line 629 of file qbbinputcontext_imf.cpp.

Referenced by QBBInputContext::closeSession().

◆ p_ictrl_dispatch_event

int32_t(* p_ictrl_dispatch_event) (event_t *)=0
static

◆ p_ictrl_get_num_active_sessions

int32_t(* p_ictrl_get_num_active_sessions) ()=0
static

Definition at line 634 of file qbbinputcontext_imf.cpp.

◆ p_ictrl_open_session

const input_session_t*(* p_ictrl_open_session) (connection_interface_t *)=0
static

Definition at line 628 of file qbbinputcontext_imf.cpp.

Referenced by QBBInputContext::openSession().

◆ p_imf_client_disconnect

void(* p_imf_client_disconnect) ()=0
static

Definition at line 632 of file qbbinputcontext_imf.cpp.

Referenced by imfAvailable(), and QBBInputContext::~QBBInputContext().

◆ p_imf_client_init

int32_t(* p_imf_client_init) ()=0
static

Definition at line 631 of file qbbinputcontext_imf.cpp.

Referenced by imfAvailable(), and QBBInputContext::QBBInputContext().

◆ p_vkb_init_selection_service

int32_t(* p_vkb_init_selection_service) ()=0
static

Definition at line 633 of file qbbinputcontext_imf.cpp.

◆ s_imfInitFailed

bool s_imfInitFailed = false
static

Definition at line 635 of file qbbinputcontext_imf.cpp.

Referenced by imfAvailable(), and QBBInputContext::QBBInputContext().