Nux

Merge lp:~brandontschaefer/nux/destroy-XIC-on-input-window-hide into lp:nux

Proposed by Brandon Schaefer
Status: Merged
Approved by: Stephen M. Webb
Approved revision: 741
Merged at revision: 741
Proposed branch: lp:~brandontschaefer/nux/destroy-XIC-on-input-window-hide
Merge into: lp:nux
Diff against target: 112 lines (+22/-2)
6 files modified
NuxGraphics/GraphicsDisplayX11.cpp (+5/-0)
NuxGraphics/GraphicsDisplayX11.h (+1/-0)
NuxGraphics/XICClient.cpp (+4/-0)
NuxGraphics/XIMController.cpp (+9/-2)
NuxGraphics/XIMController.h (+1/-0)
NuxGraphics/XInputWindow.cpp (+2/-0)
To merge this branch: bzr merge lp:~brandontschaefer/nux/destroy-XIC-on-input-window-hide
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Pending
Unity Team Pending
Review via email: mp+140277@code.launchpad.net

Commit message

Destroy the XIC when hiding a window, or creating a new XIC.

Description of the change

Last branch was corrupt, thinking it should be merging another branch...

When hiding a XInputWindow we need to destroy the XIC otherwise preedit window can be left behind. Also need to make sure it gets destroyed when creating a new one, otherwise we are leaking memory.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'NuxGraphics/GraphicsDisplayX11.cpp'
2--- NuxGraphics/GraphicsDisplayX11.cpp 2012-12-08 01:03:38 +0000
3+++ NuxGraphics/GraphicsDisplayX11.cpp 2012-12-17 19:08:22 +0000
4@@ -735,6 +735,11 @@
5 m_xim_controller->SetFocusedWindow(window);
6 }
7
8+ void GraphicsDisplay::RemoveFocusedWindowForXIMController()
9+ {
10+ m_xim_controller->RemoveFocusedWindow();
11+ }
12+
13 int GraphicsDisplay::GetGlXMajor() const
14 {
15 return _glx_major;
16
17=== modified file 'NuxGraphics/GraphicsDisplayX11.h'
18--- NuxGraphics/GraphicsDisplayX11.h 2012-11-24 00:20:10 +0000
19+++ NuxGraphics/GraphicsDisplayX11.h 2012-12-17 19:08:22 +0000
20@@ -287,6 +287,7 @@
21 GpuDevice* GetGpuDevice() const;
22
23 void SetFocusedWindowForXIMController(Window window);
24+ void RemoveFocusedWindowForXIMController();
25
26 // Dialog
27 /*bool StartOpenFileDialog(FileDialogOption& fdo);
28
29=== modified file 'NuxGraphics/XICClient.cpp'
30--- NuxGraphics/XICClient.cpp 2012-11-27 19:30:57 +0000
31+++ NuxGraphics/XICClient.cpp 2012-12-17 19:08:22 +0000
32@@ -35,11 +35,15 @@
33 {
34 if (!xim_style_)
35 SetupXIMStyle(xim);
36+
37 SetupXIC(xim, window);
38 }
39
40 void XICClient::SetupXIC(XIM xim, Window window)
41 {
42+ if (xic_)
43+ DestroyXIC();
44+
45 xic_ = XCreateIC(xim, XNInputStyle, xim_style_, XNClientWindow, window, XNFocusWindow, window, NULL);
46 }
47
48
49=== modified file 'NuxGraphics/XIMController.cpp'
50--- NuxGraphics/XIMController.cpp 2012-11-27 19:30:57 +0000
51+++ NuxGraphics/XIMController.cpp 2012-12-17 19:08:22 +0000
52@@ -40,8 +40,7 @@
53 XIMController::~XIMController()
54 {
55 // The XIC must be destroyed before the XIM
56- if (xic_client_.HasXIC())
57- xic_client_.DestroyXIC();
58+ xic_client_.DestroyXIC();
59
60 if (xim_)
61 XCloseIM(xim_);
62@@ -50,10 +49,17 @@
63 void XIMController::SetFocusedWindow(Window window)
64 {
65 window_ = window;
66+
67 if (xim_)
68 xic_client_.ResetXIC(xim_, window);
69 }
70
71+void XIMController::RemoveFocusedWindow()
72+{
73+ window_ = 0;
74+ xic_client_.DestroyXIC();
75+}
76+
77 bool XIMController::IsXICValid() const
78 {
79 return xic_client_.HasXIC();
80@@ -95,6 +101,7 @@
81 {
82 LOG_WARN(logger) << "XSetLocalModifiers Failed.";
83 }
84+
85 XRegisterIMInstantiateCallback(display_, NULL, NULL, NULL,
86 XIMController::SetupXIMClientCallback,
87 (XPointer)this);
88
89=== modified file 'NuxGraphics/XIMController.h'
90--- NuxGraphics/XIMController.h 2012-11-27 19:30:57 +0000
91+++ NuxGraphics/XIMController.h 2012-12-17 19:08:22 +0000
92@@ -37,6 +37,7 @@
93 ~XIMController();
94
95 void SetFocusedWindow(Window window);
96+ void RemoveFocusedWindow();
97
98 bool IsXICValid() const;
99 XIC GetXIC() const;
100
101=== modified file 'NuxGraphics/XInputWindow.cpp'
102--- NuxGraphics/XInputWindow.cpp 2012-11-23 23:55:02 +0000
103+++ NuxGraphics/XInputWindow.cpp 2012-12-17 19:08:22 +0000
104@@ -368,6 +368,8 @@
105
106 void XInputWindow::Hide()
107 {
108+ GetGraphicsDisplay()->RemoveFocusedWindowForXIMController();
109+
110 XMoveResizeWindow(display_, window_,
111 -100 - geometry_.width,
112 -100 - geometry_.height,

Subscribers

People subscribed via source and target branches