SDL  2.0
SDL_fcitx.c File Reference
#include "../../SDL_internal.h"
#include <unistd.h>
#include "SDL_fcitx.h"
#include "SDL_keycode.h"
#include "SDL_keyboard.h"
#include "../../events/SDL_keyboard_c.h"
#include "SDL_dbus.h"
#include "SDL_syswm.h"
#include "SDL_hints.h"
+ Include dependency graph for SDL_fcitx.c:

Go to the source code of this file.

Data Structures

struct  FcitxClient
 

Macros

#define FCITX_DBUS_SERVICE   "org.freedesktop.portal.Fcitx"
 
#define FCITX_IM_DBUS_PATH   "/org/freedesktop/portal/inputmethod"
 
#define FCITX_IM_DBUS_INTERFACE   "org.fcitx.Fcitx.InputMethod1"
 
#define FCITX_IC_DBUS_INTERFACE   "org.fcitx.Fcitx.InputContext1"
 
#define DBUS_TIMEOUT   500
 

Functions

static char * GetAppName ()
 
size_t Fcitx_GetPreeditString (SDL_DBusContext *dbus, DBusMessage *msg, char **ret)
 
static DBusHandlerResult DBus_MessageFilter (DBusConnection *conn, DBusMessage *msg, void *data)
 
static void FcitxClientICCallMethod (FcitxClient *client, const char *method)
 
static void Fcitx_SetCapabilities (void *data, const char *name, const char *old_val, const char *internal_editing)
 
static SDL_bool FcitxCreateInputContext (SDL_DBusContext *dbus, const char *appname, char **ic_path)
 
static SDL_bool FcitxClientCreateIC (FcitxClient *client)
 
static Uint32 Fcitx_ModState (void)
 
SDL_bool SDL_Fcitx_Init ()
 
void SDL_Fcitx_Quit ()
 
void SDL_Fcitx_SetFocus (SDL_bool focused)
 
void SDL_Fcitx_Reset (void)
 
SDL_bool SDL_Fcitx_ProcessKeyEvent (Uint32 keysym, Uint32 keycode)
 
void SDL_Fcitx_UpdateTextRect (SDL_Rect *rect)
 
void SDL_Fcitx_PumpEvents (void)
 

Variables

static FcitxClient fcitx_client
 

Macro Definition Documentation

◆ DBUS_TIMEOUT

#define DBUS_TIMEOUT   500

Definition at line 43 of file SDL_fcitx.c.

◆ FCITX_DBUS_SERVICE

#define FCITX_DBUS_SERVICE   "org.freedesktop.portal.Fcitx"

Definition at line 36 of file SDL_fcitx.c.

◆ FCITX_IC_DBUS_INTERFACE

#define FCITX_IC_DBUS_INTERFACE   "org.fcitx.Fcitx.InputContext1"

Definition at line 41 of file SDL_fcitx.c.

◆ FCITX_IM_DBUS_INTERFACE

#define FCITX_IM_DBUS_INTERFACE   "org.fcitx.Fcitx.InputMethod1"

Definition at line 40 of file SDL_fcitx.c.

◆ FCITX_IM_DBUS_PATH

#define FCITX_IM_DBUS_PATH   "/org/freedesktop/portal/inputmethod"

Definition at line 38 of file SDL_fcitx.c.

Function Documentation

◆ DBus_MessageFilter()

static DBusHandlerResult DBus_MessageFilter ( DBusConnection *  conn,
DBusMessage *  msg,
void data 
)
static

Definition at line 136 of file SDL_fcitx.c.

137 {
138  SDL_DBusContext *dbus = (SDL_DBusContext *)data;
139 
140  if (dbus->message_is_signal(msg, FCITX_IC_DBUS_INTERFACE, "CommitString")) {
141  DBusMessageIter iter;
142  const char *text = NULL;
143 
144  dbus->message_iter_init(msg, &iter);
145  dbus->message_iter_get_basic(&iter, &text);
146 
147  if (text && *text) {
149  size_t text_bytes = SDL_strlen(text), i = 0;
150 
151  while (i < text_bytes) {
152  size_t sz = SDL_utf8strlcpy(buf, text+i, sizeof(buf));
154 
155  i += sz;
156  }
157  }
158 
159  return DBUS_HANDLER_RESULT_HANDLED;
160  }
161 
162  if (dbus->message_is_signal(msg, FCITX_IC_DBUS_INTERFACE, "UpdateFormattedPreedit")) {
163  char *text = NULL;
164  size_t text_bytes = Fcitx_GetPreeditString(dbus, msg, &text);
165  if (text_bytes) {
167  size_t i = 0;
168  size_t cursor = 0;
169 
170  while (i < text_bytes) {
171  const size_t sz = SDL_utf8strlcpy(buf, text + i, sizeof(buf));
172  const size_t chars = SDL_utf8strlen(buf);
173 
174  SDL_SendEditingText(buf, cursor, chars);
175 
176  i += sz;
177  cursor += chars;
178  }
179  SDL_free(text);
180  } else {
181  SDL_SendEditingText("", 0, 0);
182  }
183 
185  return DBUS_HANDLER_RESULT_HANDLED;
186  }
187 
188  return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
189 }
#define SDL_utf8strlcpy
#define SDL_strlen
#define SDL_free
#define SDL_utf8strlen
#define SDL_TEXTEDITINGEVENT_TEXT_SIZE
Definition: SDL_events.h:229
#define SDL_TEXTINPUTEVENT_TEXT_SIZE
Definition: SDL_events.h:244
size_t Fcitx_GetPreeditString(SDL_DBusContext *dbus, DBusMessage *msg, char **ret)
Definition: SDL_fcitx.c:87
void SDL_Fcitx_UpdateTextRect(SDL_Rect *rect)
Definition: SDL_fcitx.c:365
#define FCITX_IC_DBUS_INTERFACE
Definition: SDL_fcitx.c:41
int SDL_SendEditingText(const char *text, int start, int length)
Definition: SDL_keyboard.c:871
int SDL_SendKeyboardText(const char *text)
Definition: SDL_keyboard.c:848
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: SDL_opengl.h:1974
GLenum GLuint GLenum GLsizei const GLchar * buf
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
Definition: SDL_x11sym.h:50
#define NULL
Definition: begin_code.h:163
static char text[MAX_TEXT_LENGTH]
Definition: testime.c:47
SDL_Cursor * cursor
Definition: testwm2.c:40

References cursor, Fcitx_GetPreeditString(), FCITX_IC_DBUS_INTERFACE, i, NULL, SDL_Fcitx_UpdateTextRect(), SDL_free, SDL_SendEditingText(), SDL_SendKeyboardText(), SDL_strlen, SDL_TEXTEDITINGEVENT_TEXT_SIZE, SDL_TEXTINPUTEVENT_TEXT_SIZE, SDL_utf8strlcpy, SDL_utf8strlen, and text.

Referenced by FcitxClientCreateIC().

◆ Fcitx_GetPreeditString()

size_t Fcitx_GetPreeditString ( SDL_DBusContext *  dbus,
DBusMessage *  msg,
char **  ret 
)

Definition at line 87 of file SDL_fcitx.c.

87  {
88  char *text = NULL, *subtext;
89  size_t text_bytes = 0;
90  DBusMessageIter iter, array, sub;
91 
92  dbus->message_iter_init(msg, &iter);
93  /* Message type is a(si)i, we only need string part */
94  if (dbus->message_iter_get_arg_type(&iter) == DBUS_TYPE_ARRAY) {
95  /* First pass: calculate string length */
96  dbus->message_iter_recurse(&iter, &array);
97  while (dbus->message_iter_get_arg_type(&array) == DBUS_TYPE_STRUCT) {
98  dbus->message_iter_recurse(&array, &sub);
99  if (dbus->message_iter_get_arg_type(&sub) == DBUS_TYPE_STRING) {
100  dbus->message_iter_get_basic(&sub, &subtext);
101  if (subtext && *subtext) {
102  text_bytes += SDL_strlen(subtext);
103  }
104  }
105  dbus->message_iter_next(&array);
106  }
107  if (text_bytes) {
108  text = SDL_malloc(text_bytes + 1);
109  }
110 
111  if (text) {
112  char* pivot = text;
113  /* Second pass: join all the sub string */
114  dbus->message_iter_recurse(&iter, &array);
115  while (dbus->message_iter_get_arg_type(&array) == DBUS_TYPE_STRUCT) {
116  dbus->message_iter_recurse(&array, &sub);
117  if (dbus->message_iter_get_arg_type(&sub) == DBUS_TYPE_STRING) {
118  dbus->message_iter_get_basic(&sub, &subtext);
119  if (subtext && *subtext) {
120  size_t length = SDL_strlen(subtext);
121  SDL_strlcpy(pivot, subtext, length + 1);
122  pivot += length;
123  }
124  }
125  dbus->message_iter_next(&array);
126  }
127  } else {
128  text_bytes = 0;
129  }
130  }
131  *ret= text;
132  return text_bytes;
133 }
#define SDL_malloc
#define SDL_strlcpy
GLenum array
GLuint GLsizei GLsizei * length
set set set set set set set set set set set set set set set set set set set set *set set set macro pixldst op &r &cond WK op &r &cond WK op &r &cond WK else op &m &cond &ia op &r &cond WK else op &m &cond &ia elseif elseif else error unsupported base if elseif elseif else error unsupported unaligned pixldst unaligned endm macro pixst base base else pixldst base endif endm macro PF base if bpp PF set rept prefetch_distance PF set OFFSET endr endif endm macro preload_leading_step2 base if bpp ifc DST PF PF else if bpp lsl PF PF lsl PF sub

References NULL, SDL_malloc, SDL_strlcpy, SDL_strlen, sub, and text.

Referenced by DBus_MessageFilter().

◆ Fcitx_ModState()

static Uint32 Fcitx_ModState ( void  )
static

Definition at line 283 of file SDL_fcitx.c.

284 {
285  Uint32 fcitx_mods = 0;
286  SDL_Keymod sdl_mods = SDL_GetModState();
287 
288  if (sdl_mods & KMOD_SHIFT) fcitx_mods |= (1 << 0);
289  if (sdl_mods & KMOD_CAPS) fcitx_mods |= (1 << 1);
290  if (sdl_mods & KMOD_CTRL) fcitx_mods |= (1 << 2);
291  if (sdl_mods & KMOD_ALT) fcitx_mods |= (1 << 3);
292  if (sdl_mods & KMOD_NUM) fcitx_mods |= (1 << 4);
293  if (sdl_mods & KMOD_MODE) fcitx_mods |= (1 << 7);
294  if (sdl_mods & KMOD_LGUI) fcitx_mods |= (1 << 6);
295  if (sdl_mods & KMOD_RGUI) fcitx_mods |= (1 << 28);
296 
297  return fcitx_mods;
298 }
#define SDL_GetModState
SDL_Keymod
Enumeration of valid key mods (possibly OR'd together).
Definition: SDL_keycode.h:328
@ KMOD_MODE
Definition: SDL_keycode.h:340
@ KMOD_SHIFT
Definition: SDL_keycode.h:344
@ KMOD_LGUI
Definition: SDL_keycode.h:336
@ KMOD_CAPS
Definition: SDL_keycode.h:339
@ KMOD_RGUI
Definition: SDL_keycode.h:337
@ KMOD_ALT
Definition: SDL_keycode.h:345
@ KMOD_NUM
Definition: SDL_keycode.h:338
@ KMOD_CTRL
Definition: SDL_keycode.h:343
uint32_t Uint32
Definition: SDL_stdinc.h:209

References KMOD_ALT, KMOD_CAPS, KMOD_CTRL, KMOD_LGUI, KMOD_MODE, KMOD_NUM, KMOD_RGUI, KMOD_SHIFT, and SDL_GetModState.

Referenced by SDL_Fcitx_ProcessKeyEvent().

◆ Fcitx_SetCapabilities()

static void Fcitx_SetCapabilities ( void data,
const char *  name,
const char *  old_val,
const char *  internal_editing 
)
static

Definition at line 201 of file SDL_fcitx.c.

205 {
206  FcitxClient *client = (FcitxClient *)data;
207  Uint32 caps = 0;
208  if (!client->ic_path) {
209  return;
210  }
211 
212  if (!(internal_editing && *internal_editing == '1')) {
213  caps |= (1 << 1); /* Preedit Flag */
214  caps |= (1 << 4); /* Formatted Preedit Flag */
215  }
216 
217  SDL_DBus_CallVoidMethod(FCITX_DBUS_SERVICE, client->ic_path, FCITX_IC_DBUS_INTERFACE, "SetCapability", DBUS_TYPE_UINT64, &caps, DBUS_TYPE_INVALID);
218 }
#define FCITX_DBUS_SERVICE
Definition: SDL_fcitx.c:36
char * ic_path
Definition: SDL_fcitx.c:49

References FCITX_DBUS_SERVICE, FCITX_IC_DBUS_INTERFACE, and FcitxClient::ic_path.

Referenced by FcitxClientCreateIC().

◆ FcitxClientCreateIC()

static SDL_bool FcitxClientCreateIC ( FcitxClient client)
static

Definition at line 250 of file SDL_fcitx.c.

251 {
252  char *appname = GetAppName();
253  char *ic_path = NULL;
254  SDL_DBusContext *dbus = client->dbus;
255 
256  /* SDL_DBus_CallMethod cannot handle a(ss) type, call dbus function directly */
257  if (!FcitxCreateInputContext(dbus, appname, &ic_path)) {
258  ic_path = NULL; /* just in case. */
259  }
260 
261  SDL_free(appname);
262 
263  if (ic_path) {
264  SDL_free(client->ic_path);
265  client->ic_path = SDL_strdup(ic_path);
266 
267  dbus->bus_add_match(dbus->session_conn,
268  "type='signal', interface='org.fcitx.Fcitx.InputContext1'",
269  NULL);
270  dbus->connection_add_filter(dbus->session_conn,
271  &DBus_MessageFilter, dbus,
272  NULL);
273  dbus->connection_flush(dbus->session_conn);
274 
276  return SDL_TRUE;
277  }
278 
279  return SDL_FALSE;
280 }
#define SDL_strdup
#define SDL_AddHintCallback
static void Fcitx_SetCapabilities(void *data, const char *name, const char *old_val, const char *internal_editing)
Definition: SDL_fcitx.c:201
static char * GetAppName()
Definition: SDL_fcitx.c:59
static SDL_bool FcitxCreateInputContext(SDL_DBusContext *dbus, const char *appname, char **ic_path)
Definition: SDL_fcitx.c:221
static DBusHandlerResult DBus_MessageFilter(DBusConnection *conn, DBusMessage *msg, void *data)
Definition: SDL_fcitx.c:136
#define SDL_HINT_IME_INTERNAL_EDITING
A variable to control whether certain IMEs should handle text editing internally instead of sending S...
Definition: SDL_hints.h:1044
@ SDL_TRUE
Definition: SDL_stdinc.h:170
@ SDL_FALSE
Definition: SDL_stdinc.h:169
SDL_DBusContext * dbus
Definition: SDL_fcitx.c:47

References FcitxClient::dbus, DBus_MessageFilter(), Fcitx_SetCapabilities(), FcitxCreateInputContext(), GetAppName(), FcitxClient::ic_path, NULL, SDL_AddHintCallback, SDL_FALSE, SDL_free, SDL_HINT_IME_INTERNAL_EDITING, SDL_strdup, and SDL_TRUE.

Referenced by SDL_Fcitx_Init().

◆ FcitxClientICCallMethod()

static void FcitxClientICCallMethod ( FcitxClient client,
const char *  method 
)
static

Definition at line 192 of file SDL_fcitx.c.

193 {
194  if (!client->ic_path) {
195  return;
196  }
197  SDL_DBus_CallVoidMethod(FCITX_DBUS_SERVICE, client->ic_path, FCITX_IC_DBUS_INTERFACE, method, DBUS_TYPE_INVALID);
198 }

References FCITX_DBUS_SERVICE, FCITX_IC_DBUS_INTERFACE, and FcitxClient::ic_path.

Referenced by SDL_Fcitx_Quit(), SDL_Fcitx_Reset(), and SDL_Fcitx_SetFocus().

◆ FcitxCreateInputContext()

static SDL_bool FcitxCreateInputContext ( SDL_DBusContext *  dbus,
const char *  appname,
char **  ic_path 
)
static

Definition at line 221 of file SDL_fcitx.c.

221  {
222  const char *program = "program";
224  if (dbus->session_conn) {
225  DBusMessage *msg = dbus->message_new_method_call(FCITX_DBUS_SERVICE, FCITX_IM_DBUS_PATH, FCITX_IM_DBUS_INTERFACE, "CreateInputContext");
226  if (msg) {
227  DBusMessage *reply = NULL;
228  DBusMessageIter args, array, sub;
229  dbus->message_iter_init_append(msg, &args);
230  dbus->message_iter_open_container(&args, DBUS_TYPE_ARRAY, "(ss)", &array);
231  dbus->message_iter_open_container(&array, DBUS_TYPE_STRUCT, 0, &sub);
232  dbus->message_iter_append_basic(&sub, DBUS_TYPE_STRING, &program);
233  dbus->message_iter_append_basic(&sub, DBUS_TYPE_STRING, &appname);
234  dbus->message_iter_close_container(&array, &sub);
235  dbus->message_iter_close_container(&args, &array);
236  reply = dbus->connection_send_with_reply_and_block(dbus->session_conn, msg, 300, NULL);
237  if (reply) {
238  if (dbus->message_get_args(reply, NULL, DBUS_TYPE_OBJECT_PATH, ic_path, DBUS_TYPE_INVALID)) {
239  retval = SDL_TRUE;
240  }
241  dbus->message_unref(reply);
242  }
243  dbus->message_unref(msg);
244  }
245  }
246  return retval;
247 }
#define FCITX_IM_DBUS_INTERFACE
Definition: SDL_fcitx.c:40
#define FCITX_IM_DBUS_PATH
Definition: SDL_fcitx.c:38
GLbitfield GLuint program
SDL_bool
Definition: SDL_stdinc.h:168
SDL_bool retval

References FCITX_DBUS_SERVICE, FCITX_IM_DBUS_INTERFACE, FCITX_IM_DBUS_PATH, NULL, retval, SDL_FALSE, SDL_TRUE, and sub.

Referenced by FcitxClientCreateIC().

◆ GetAppName()

static char* GetAppName ( )
static

Definition at line 59 of file SDL_fcitx.c.

60 {
61 #if defined(__LINUX__) || defined(__FREEBSD__)
62  char *spot;
63  char procfile[1024];
64  char linkfile[1024];
65  int linksize;
66 
67 #if defined(__LINUX__)
68  SDL_snprintf(procfile, sizeof(procfile), "/proc/%d/exe", getpid());
69 #elif defined(__FREEBSD__)
70  SDL_snprintf(procfile, sizeof(procfile), "/proc/%d/file", getpid());
71 #endif
72  linksize = readlink(procfile, linkfile, sizeof(linkfile) - 1);
73  if (linksize > 0) {
74  linkfile[linksize] = '\0';
75  spot = SDL_strrchr(linkfile, '/');
76  if (spot) {
77  return SDL_strdup(spot + 1);
78  } else {
79  return SDL_strdup(linkfile);
80  }
81  }
82 #endif /* __LINUX__ || __FREEBSD__ */
83 
84  return SDL_strdup("SDL_App");
85 }
#define SDL_strrchr
#define SDL_snprintf

References SDL_snprintf, SDL_strdup, and SDL_strrchr.

Referenced by FcitxClientCreateIC().

◆ SDL_Fcitx_Init()

SDL_bool SDL_Fcitx_Init ( void  )

Definition at line 301 of file SDL_fcitx.c.

302 {
303  fcitx_client.dbus = SDL_DBus_GetContext();
304 
309 
311 }
static SDL_bool FcitxClientCreateIC(FcitxClient *client)
Definition: SDL_fcitx.c:250
static FcitxClient fcitx_client
Definition: SDL_fcitx.c:56
SDL_Rect cursor_rect
Definition: SDL_fcitx.c:53
int h
Definition: SDL_rect.h:80
int w
Definition: SDL_rect.h:80
int y
Definition: SDL_rect.h:79
int x
Definition: SDL_rect.h:79

References FcitxClient::cursor_rect, FcitxClient::dbus, fcitx_client, FcitxClientCreateIC(), SDL_Rect::h, SDL_Rect::w, SDL_Rect::x, and SDL_Rect::y.

Referenced by InitIME().

◆ SDL_Fcitx_ProcessKeyEvent()

SDL_bool SDL_Fcitx_ProcessKeyEvent ( Uint32  keysym,
Uint32  keycode 
)

Definition at line 341 of file SDL_fcitx.c.

342 {
344  Uint32 handled = SDL_FALSE;
345  Uint32 is_release = SDL_FALSE;
346  Uint32 event_time = 0;
347 
348  if (!fcitx_client.ic_path) {
349  return SDL_FALSE;
350  }
351 
352  if (SDL_DBus_CallMethod(FCITX_DBUS_SERVICE, fcitx_client.ic_path, FCITX_IC_DBUS_INTERFACE, "ProcessKeyEvent",
353  DBUS_TYPE_UINT32, &keysym, DBUS_TYPE_UINT32, &keycode, DBUS_TYPE_UINT32, &state, DBUS_TYPE_BOOLEAN, &is_release, DBUS_TYPE_UINT32, &event_time, DBUS_TYPE_INVALID,
354  DBUS_TYPE_BOOLEAN, &handled, DBUS_TYPE_INVALID)) {
355  if (handled) {
357  return SDL_TRUE;
358  }
359  }
360 
361  return SDL_FALSE;
362 }
static Uint32 Fcitx_ModState(void)
Definition: SDL_fcitx.c:283
struct xkb_state * state

References fcitx_client, FCITX_DBUS_SERVICE, FCITX_IC_DBUS_INTERFACE, Fcitx_ModState(), FcitxClient::ic_path, NULL, SDL_FALSE, SDL_Fcitx_UpdateTextRect(), SDL_TRUE, and state.

Referenced by InitIME().

◆ SDL_Fcitx_PumpEvents()

void SDL_Fcitx_PumpEvents ( void  )

Definition at line 416 of file SDL_fcitx.c.

417 {
418  SDL_DBusContext *dbus = fcitx_client.dbus;
419  DBusConnection *conn = dbus->session_conn;
420 
421  dbus->connection_read_write(conn, 0);
422 
423  while (dbus->connection_dispatch(conn) == DBUS_DISPATCH_DATA_REMAINS) {
424  /* Do nothing, actual work happens in DBus_MessageFilter */
425  usleep(10);
426  }
427 }

References FcitxClient::dbus, and fcitx_client.

Referenced by InitIME().

◆ SDL_Fcitx_Quit()

void SDL_Fcitx_Quit ( void  )

Definition at line 314 of file SDL_fcitx.c.

315 {
316  FcitxClientICCallMethod(&fcitx_client, "DestroyIC");
317  if (fcitx_client.ic_path) {
320  }
321 }
static void FcitxClientICCallMethod(FcitxClient *client, const char *method)
Definition: SDL_fcitx.c:192

References fcitx_client, FcitxClientICCallMethod(), FcitxClient::ic_path, NULL, and SDL_free.

Referenced by InitIME().

◆ SDL_Fcitx_Reset()

void SDL_Fcitx_Reset ( void  )

Definition at line 334 of file SDL_fcitx.c.

335 {
338 }

References fcitx_client, and FcitxClientICCallMethod().

Referenced by InitIME().

◆ SDL_Fcitx_SetFocus()

void SDL_Fcitx_SetFocus ( SDL_bool  focused)

Definition at line 324 of file SDL_fcitx.c.

325 {
326  if (focused) {
328  } else {
330  }
331 }

References fcitx_client, and FcitxClientICCallMethod().

Referenced by InitIME().

◆ SDL_Fcitx_UpdateTextRect()

void SDL_Fcitx_UpdateTextRect ( SDL_Rect rect)

Definition at line 365 of file SDL_fcitx.c.

366 {
367  SDL_Window *focused_win = NULL;
368  SDL_SysWMinfo info;
369  int x = 0, y = 0;
371 
372  if (rect) {
373  SDL_memcpy(cursor, rect, sizeof(SDL_Rect));
374  }
375 
376  focused_win = SDL_GetKeyboardFocus();
377  if (!focused_win) {
378  return ;
379  }
380 
381  SDL_VERSION(&info.version);
382  if (!SDL_GetWindowWMInfo(focused_win, &info)) {
383  return;
384  }
385 
386  SDL_GetWindowPosition(focused_win, &x, &y);
387 
388 #if SDL_VIDEO_DRIVER_X11
389  if (info.subsystem == SDL_SYSWM_X11) {
390  SDL_DisplayData *displaydata = (SDL_DisplayData *) SDL_GetDisplayForWindow(focused_win)->driverdata;
391 
392  Display *x_disp = info.info.x11.display;
393  Window x_win = info.info.x11.window;
394  int x_screen = displaydata->screen;
395  Window unused;
396  X11_XTranslateCoordinates(x_disp, x_win, RootWindow(x_disp, x_screen), 0, 0, &x, &y, &unused);
397  }
398 #endif
399 
400  if (cursor->x == -1 && cursor->y == -1 && cursor->w == 0 && cursor->h == 0) {
401  /* move to bottom left */
402  int w = 0, h = 0;
403  SDL_GetWindowSize(focused_win, &w, &h);
404  cursor->x = 0;
405  cursor->y = h;
406  }
407 
408  x += cursor->x;
409  y += cursor->y;
410 
411  SDL_DBus_CallVoidMethod(FCITX_DBUS_SERVICE, fcitx_client.ic_path, FCITX_IC_DBUS_INTERFACE, "SetCursorRect",
412  DBUS_TYPE_INT32, &x, DBUS_TYPE_INT32, &y, DBUS_TYPE_INT32, &cursor->w, DBUS_TYPE_INT32, &cursor->h, DBUS_TYPE_INVALID);
413 }
#define SDL_GetWindowSize
#define SDL_GetKeyboardFocus
#define SDL_GetWindowPosition
#define SDL_memcpy
#define SDL_GetWindowWMInfo
GLint GLint GLint GLint GLint GLint y
Definition: SDL_opengl.h:1574
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
GLfloat GLfloat GLfloat GLfloat h
GLubyte GLubyte GLubyte GLubyte w
SDL_VideoDisplay * SDL_GetDisplayForWindow(SDL_Window *window)
Definition: SDL_video.c:1130
@ SDL_SYSWM_X11
Definition: SDL_syswm.h:131
#define SDL_VERSION(x)
Macro to determine SDL version program was compiled against.
Definition: SDL_version.h:79
set set set set set set set set set set set set set set set set set set set set *set set set macro pixldst op &r &cond WK op &r &cond WK op &r &cond WK else op &m &cond &ia op &r &cond WK else op &m &cond &ia elseif elseif else error unsupported base if elseif elseif else error unsupported unaligned pixldst unaligned endm macro pixst base base else pixldst base endif endm macro PF base if bpp PF set rept prefetch_distance PF set OFFSET endr endif endm macro preload_leading_step2 base if bpp ifc DST PF PF else if bpp lsl PF PF lsl PF PF lsl PF PF PF else PF lsl PF lsl PF lsl PF endif SIZE macro preload_middle scratch_holds_offset if bpp if else PF PF endif endif endif endm macro preload_trailing base if bpp if bpp *pix_per_block PF PF lsl PF PF PF PF PF else PF lsl PF lsl PF PF PF PF PF base if bpp if narrow_case &&bpp<=dst_w_bpp) PF bic, WK0, base, #31 PF pld,[WK0] PF add, WK1, base, X, LSL #bpp_shift PF sub, WK1, WK1, #1 PF bic, WK1, WK1, #31 PF cmp, WK1, WK0 PF beq, 90f PF pld,[WK1]90:.else PF bic, WK0, base, #31 PF pld,[WK0] PF add, WK1, base, X, lsl #bpp_shift PF sub, WK1, WK1, #1 PF bic, WK1, WK1, #31 PF cmp, WK1, WK0 PF beq, 92f91:PF add, WK0, WK0, #32 PF cmp, WK0, WK1 PF pld,[WK0] PF bne, 91b92:.endif .endif.endm.macro conditional_process1_helper cond, process_head, process_tail, numbytes, firstreg, unaligned_src, unaligned_mask, decrementx process_head cond, numbytes, firstreg, unaligned_src, unaligned_mask, 0 .if decrementx sub &cond X, X, #8 *numbytes/dst_w_bpp .endif process_tail cond, numbytes, firstreg .if !((flags) &FLAG_PROCESS_DOES_STORE) pixst cond, numbytes, firstreg, DST .endif.endm.macro conditional_process1 cond, process_head, process_tail, numbytes, firstreg, unaligned_src, unaligned_mask, decrementx .if(flags) &FLAG_BRANCH_OVER .ifc cond, mi bpl 100f .endif .ifc cond, cs bcc 100f .endif .ifc cond, ne beq 100f .endif conditional_process1_helper, process_head, process_tail, numbytes, firstreg, unaligned_src, unaligned_mask, decrementx100:.else conditional_process1_helper cond, process_head, process_tail, numbytes, firstreg, unaligned_src, unaligned_mask, decrementx .endif.endm.macro conditional_process2 test, cond1, cond2, process_head, process_tail, numbytes1, numbytes2, firstreg1, firstreg2, unaligned_src, unaligned_mask, decrementx .if(flags) &(FLAG_DST_READWRITE|FLAG_BRANCH_OVER|FLAG_PROCESS_CORRUPTS_PSR|FLAG_PROCESS_DOES_STORE) test conditional_process1 cond1, process_head, process_tail, numbytes1, firstreg1, unaligned_src, unaligned_mask, decrementx .if(flags) &FLAG_PROCESS_CORRUPTS_PSR test .endif conditional_process1 cond2, process_head, process_tail, numbytes2, firstreg2, unaligned_src, unaligned_mask, decrementx .else test process_head cond1, numbytes1, firstreg1, unaligned_src, unaligned_mask, 0 process_head cond2, numbytes2, firstreg2, unaligned_src, unaligned_mask, 0 .if decrementx sub &cond1 X, X, #8 *numbytes1/dst_w_bpp sub &cond2 X, X, #8 *numbytes2/dst_w_bpp .endif process_tail cond1, numbytes1, firstreg1 process_tail cond2, numbytes2, firstreg2 pixst cond1, numbytes1, firstreg1, DST pixst cond2, numbytes2, firstreg2, DST .endif.endm.macro test_bits_1_0_ptr .if(flags) &FLAG_PROCESS_CORRUPTS_WK0 movs SCRATCH, X, lsl #32-1 .else movs SCRATCH, WK0, lsl #32-1 .endif.endm.macro test_bits_3_2_ptr .if(flags) &FLAG_PROCESS_CORRUPTS_WK0 movs SCRATCH, X, lsl #32-3 .else movs SCRATCH, WK0, lsl #32-3 .endif.endm.macro leading_15bytes process_head, process_tail .set DECREMENT_X, 1 .if(flags) &FLAG_PROCESS_CORRUPTS_WK0 .set DECREMENT_X, 0 sub X, X, WK0, lsr #dst_bpp_shift str X,[sp, #LINE_SAVED_REG_COUNT *4] mov X, WK0 .endif .if dst_w_bpp==8 conditional_process2 test_bits_1_0_ptr, mi, cs, process_head, process_tail, 1, 2, 1, 2, 1, 1, DECREMENT_X .elseif dst_w_bpp==16 test_bits_1_0_ptr conditional_process1 cs, process_head, process_tail, 2, 2, 1, 1, DECREMENT_X .endif conditional_process2 test_bits_3_2_ptr, mi, cs, process_head, process_tail, 4, 8, 1, 2, 1, 1, DECREMENT_X .if(flags) &FLAG_PROCESS_CORRUPTS_WK0 ldr X,[sp, #LINE_SAVED_REG_COUNT *4] .endif.endm.macro test_bits_3_2_pix movs SCRATCH, X, lsl #dst_bpp_shift+32-3.endm.macro test_bits_1_0_pix .if dst_w_bpp==8 movs SCRATCH, X, lsl #dst_bpp_shift+32-1 .else movs SCRATCH, X, lsr #1 .endif.endm.macro trailing_15bytes process_head, process_tail, unaligned_src, unaligned_mask conditional_process2 test_bits_3_2_pix, cs, mi, process_head, process_tail, 8, 4, 0, 2, unaligned_src, unaligned_mask, 0 .if dst_w_bpp==16 test_bits_1_0_pix conditional_process1 cs, process_head, process_tail, 2, 0, unaligned_src, unaligned_mask, 0 .elseif dst_w_bpp==8 conditional_process2 test_bits_1_0_pix, cs, mi, process_head, process_tail, 2, 1, 0, 1, unaligned_src, unaligned_mask, 0 .endif.endm.macro wide_case_inner_loop process_head, process_tail, unaligned_src, unaligned_mask, dst_alignment110:.set SUBBLOCK, 0 .rept pix_per_block *dst_w_bpp/128 process_head, 16, 0, unaligned_src, unaligned_mask, 1 .if(src_bpp > 0) &&(mask_bpp==0) &&((flags) &FLAG_PROCESS_PRESERVES_SCRATCH) preload_middle src_bpp, SRC, 1 .elseif(src_bpp==0) &&(mask_bpp > 0) &&((flags) &FLAG_PROCESS_PRESERVES_SCRATCH) preload_middle mask_bpp, MASK, 1 .else preload_middle src_bpp, SRC, 0 preload_middle mask_bpp, MASK, 0 .endif .if(dst_r_bpp > 0) &&((SUBBLOCK % 2)==0) &&(((flags) &FLAG_NO_PRELOAD_DST)==0) PF pld,[DST, #32 *prefetch_distance - dst_alignment] .endif process_tail, 16, 0 .if !((flags) &FLAG_PROCESS_DOES_STORE) pixst, 16, 0, DST .endif .set SUBBLOCK, SUBBLOCK+1 .endr subs X, X, #pix_per_block bhs 110b.endm.macro wide_case_inner_loop_and_trailing_pixels process_head, process_tail, process_inner_loop, exit_label, unaligned_src, unaligned_mask .if dst_r_bpp > tst bne process_inner_loop DST_PRELOAD_BIAS endif preload_trailing SRC preload_trailing MASK DST endif add medium_case_inner_loop_and_trailing_pixels unaligned_mask endm macro medium_case_inner_loop_and_trailing_pixels unused
A rectangle, with the origin at the upper left (integer).
Definition: SDL_rect.h:78
union SDL_SysWMinfo::@10 info
struct SDL_SysWMinfo::@10::@11 x11
SDL_SYSWM_TYPE subsystem
Definition: SDL_syswm.h:219
SDL_version version
Definition: SDL_syswm.h:218
The type used to identify a window.
Definition: SDL_sysvideo.h:75
SDL_Rect rect
Definition: testrelative.c:27

References cursor, FcitxClient::cursor_rect, SDL_VideoDisplay::driverdata, fcitx_client, FCITX_DBUS_SERVICE, FCITX_IC_DBUS_INTERFACE, FcitxClient::ic_path, SDL_SysWMinfo::info, NULL, rect, SDL_DisplayData::screen, SDL_GetDisplayForWindow(), SDL_GetKeyboardFocus, SDL_GetWindowPosition, SDL_GetWindowSize, SDL_GetWindowWMInfo, SDL_memcpy, SDL_SYSWM_X11, SDL_VERSION, SDL_SysWMinfo::subsystem, unused, SDL_SysWMinfo::version, and SDL_SysWMinfo::x11.

Referenced by DBus_MessageFilter(), InitIME(), and SDL_Fcitx_ProcessKeyEvent().

Variable Documentation

◆ fcitx_client