summaryrefslogtreecommitdiff
path: root/platform/x11/os_x11.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'platform/x11/os_x11.cpp')
-rw-r--r--platform/x11/os_x11.cpp34
1 files changed, 31 insertions, 3 deletions
diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp
index eec371865e..d7f042b4fe 100644
--- a/platform/x11/os_x11.cpp
+++ b/platform/x11/os_x11.cpp
@@ -391,6 +391,9 @@ Error OS_X11::initialize(const VideoMode &p_desired, int p_video_driver, int p_a
wm_delete = XInternAtom(x11_display, "WM_DELETE_WINDOW", true);
XSetWMProtocols(x11_display, x11_window, &wm_delete, 1);
+ im_active = false;
+ im_position = Vector2();
+
if (xim && xim_style) {
xic = XCreateIC(xim, XNInputStyle, xim_style, XNClientWindow, x11_window, XNFocusWindow, x11_window, (char *)NULL);
@@ -400,7 +403,7 @@ Error OS_X11::initialize(const VideoMode &p_desired, int p_video_driver, int p_a
xic = NULL;
}
if (xic) {
- XSetICFocus(xic);
+ XUnsetICFocus(xic);
} else {
WARN_PRINT("XCreateIC couldn't create xic");
}
@@ -541,8 +544,25 @@ void OS_X11::xim_destroy_callback(::XIM im, ::XPointer client_data,
os->xic = NULL;
}
+void OS_X11::set_ime_active(const bool p_active) {
+
+ im_active = p_active;
+
+ if (!xic)
+ return;
+
+ if (p_active) {
+ XSetICFocus(xic);
+ set_ime_position(im_position);
+ } else {
+ XUnsetICFocus(xic);
+ }
+}
+
void OS_X11::set_ime_position(const Point2 &p_pos) {
+ im_position = p_pos;
+
if (!xic)
return;
@@ -1292,6 +1312,9 @@ void OS_X11::set_borderless_window(bool p_borderless) {
hints.decorations = current_videomode.borderless_window ? 0 : 1;
property = XInternAtom(x11_display, "_MOTIF_WM_HINTS", True);
XChangeProperty(x11_display, x11_window, property, property, 32, PropModeReplace, (unsigned char *)&hints, 5);
+
+ // Preserve window size
+ set_window_size(Size2(current_videomode.width, current_videomode.height));
}
bool OS_X11::get_borderless_window() {
@@ -2407,7 +2430,7 @@ void OS_X11::set_cursor_shape(CursorShape p_shape) {
if (p_shape == current_cursor)
return;
- if (mouse_mode == MOUSE_MODE_VISIBLE) {
+ if (mouse_mode == MOUSE_MODE_VISIBLE && mouse_mode != MOUSE_MODE_CONFINED) {
if (cursors[p_shape] != None)
XDefineCursor(x11_display, x11_window, cursors[p_shape]);
else if (cursors[CURSOR_ARROW] != None)
@@ -2449,6 +2472,8 @@ void OS_X11::set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shape, c
image = texture->get_data();
+ ERR_FAIL_COND(!image.is_valid());
+
// Create the cursor structure
XcursorImage *cursor_image = XcursorImageCreate(texture_size.width, texture_size.height);
XcursorUInt image_size = texture_size.width * texture_size.height;
@@ -2460,7 +2485,7 @@ void OS_X11::set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shape, c
cursor_image->yhot = p_hotspot.y;
// allocate memory to contain the whole file
- cursor_image->pixels = (XcursorPixel *)malloc(size);
+ cursor_image->pixels = (XcursorPixel *)memalloc(size);
image->lock();
@@ -2486,6 +2511,9 @@ void OS_X11::set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shape, c
if (p_shape == CURSOR_ARROW) {
XDefineCursor(x11_display, x11_window, cursors[p_shape]);
}
+
+ memfree(cursor_image->pixels);
+ XcursorImageDestroy(cursor_image);
} else {
// Reset to default system cursor
if (img[p_shape]) {