Skip to content
This repository has been archived by the owner on Aug 31, 2021. It is now read-only.

[[ Bug 22840 ]] Activate IME in redraw #7401

Open
wants to merge 1 commit into
base: develop-9.6
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/notes/bugfix-22840.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Improved IME activation

The IME (soft keyboard on mobile) is now activated and deactivated if required
only on redraw. The change allows `lock screen` to delay changes to the IME.
4 changes: 3 additions & 1 deletion engine/src/card.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ along with LiveCode. If not see <http://www.gnu.org/licenses/>. */

#include "stackfileformat.h"

#include "mode.h"

MCRectangle MCCard::selrect;
int2 MCCard::startx;
int2 MCCard::starty;
Expand Down Expand Up @@ -804,7 +806,7 @@ Boolean MCCard::mdown(uint2 which)
#ifdef _MOBILE
// Make sure the IME has gone away on mobile if due to an explicit card
// click.
MCscreen -> closeIME();
MCModeActivateIme(getstack(), false);
#endif
message_with_valueref_args(MCM_mouse_down, MCSTR("1"));
if (!(MCbuttonstate & (0x1L << (which - 1))))
Expand Down
8 changes: 0 additions & 8 deletions engine/src/desktop-dc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -926,10 +926,6 @@ void MCScreenDC::clearIME(Window w)
MCPlatformResetTextInputInWindow(MCactivefield -> getstack() -> getwindow());
}

void MCScreenDC::openIME()
{
}

void MCScreenDC::activateIME(Boolean activate)
{
if (!MCactivefield)
Expand All @@ -938,10 +934,6 @@ void MCScreenDC::activateIME(Boolean activate)
MCPlatformConfigureTextInputInWindow(MCactivefield -> getstack() -> getwindow(), activate);
}

void MCScreenDC::closeIME()
{
}

////////////////////////////////////////////////////////////////////////////////

void MCScreenDC::getsystemappearance(MCSystemAppearance &r_appearance)
Expand Down
2 changes: 0 additions & 2 deletions engine/src/desktop-dc.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,7 @@ class MCScreenDC: public MCUIDC
virtual void flushevents(uint2 e);

virtual void clearIME(Window w);
virtual void openIME();
virtual void activateIME(Boolean activate);
virtual void closeIME();

virtual void seticon(uint4 p_icon);
virtual void seticonmenu(MCStringRef p_menu);
Expand Down
2 changes: 1 addition & 1 deletion engine/src/exec-interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1294,7 +1294,7 @@ void MCInterfaceExecFocusOnNothing(MCExecContext &ctxt)
MCfocusedstackptr -> getcard() -> kunfocus();
#ifdef _MOBILE
// Make sure the IME is forced closed if explicitly asked to be.
MCscreen -> closeIME();
MCModeActivateIme(ctxt.GetObject() -> getstack(), false);
#endif
}

Expand Down
3 changes: 1 addition & 2 deletions engine/src/lnxdc.h
Original file line number Diff line number Diff line change
Expand Up @@ -352,8 +352,7 @@ class MCScreenDC : public MCUIDC
virtual void clearIME(Window w);
virtual void configureIME(int32_t x, int32_t y);
virtual void activateIME(Boolean activate);
//virtual void closeIME();


virtual bool loadfont(MCStringRef p_path, bool p_globally, void*& r_loaded_font_handle);
virtual bool unloadfont(MCStringRef p_path, bool p_globally, void *r_loaded_font_handle);

Expand Down
8 changes: 0 additions & 8 deletions engine/src/mblandroiddc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -639,10 +639,6 @@ void MCScreenDC::pingwait(void)

////////////////////////////////////////////////////////////////////////////////

void MCScreenDC::openIME()
{
}

extern int32_t MCInterfaceAndroidKeyboardEnumFromMCExecEnum(MCInterfaceKeyboardType p_type);
extern int32_t MCInterfaceAndroidReturnKeyTypeEnumFromMCExecEnum(MCInterfaceReturnKeyType p_type);
void MCScreenDC::activateIME(Boolean activate)
Expand Down Expand Up @@ -672,10 +668,6 @@ void MCScreenDC::activateIME(Boolean activate)
MCAndroidEngineRemoteCall("setTextInputVisible", "vbii", nil, activate, t_keyboard_type, t_return_key_type);
}

void MCScreenDC::closeIME()
{
}

////////////////////////////////////////////////////////////////////////////////

void MCScreenDC::do_take_focus(void)
Expand Down
4 changes: 1 addition & 3 deletions engine/src/mbldc.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,8 @@ class MCScreenDC: public MCUIDC
// char *charsettofontname(uint1 charset, const char *oldfontname);

void clearIME(Window w);
void openIME();
void activateIME(Boolean activate);
void closeIME();


void enactraisewindows(void);

//
Expand Down
12 changes: 0 additions & 12 deletions engine/src/mbliphonedc.mm
Original file line number Diff line number Diff line change
Expand Up @@ -784,10 +784,6 @@ static void MCScreenDCDoSnapshot(void *p_env)
MCIPhoneBreakWait();
}

void MCScreenDC::openIME()
{
}

void MCScreenDC::activateIME(Boolean activate)
{
// MW-2012-08-06: [[ Fibers ]] Execute the system code on the main fiber.
Expand All @@ -799,14 +795,6 @@ static void MCScreenDCDoSnapshot(void *p_env)
});
}

void MCScreenDC::closeIME()
{
// MW-2012-08-06: [[ Fibers ]] Execute the system code on the main fiber.
MCIPhoneRunBlockOnMainFiber(^(void) {
MCIPhoneDeactivateKeyboard();
});
}

void MCScreenDC::do_take_focus(void)
{
// MW-2012-08-06: [[ Fibers ]] Execute the system code on the main fiber.
Expand Down
2 changes: 1 addition & 1 deletion engine/src/mode_development.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,7 @@ bool MCModeMakeLocalWindows(void)

void MCModeActivateIme(MCStack *p_stack, bool p_activate)
{
MCscreen -> activateIME(p_activate);
MCscreen -> pendingIME(p_activate);
}

void MCModeConfigureIme(MCStack *p_stack, bool p_enabled, int32_t x, int32_t y)
Expand Down
2 changes: 1 addition & 1 deletion engine/src/mode_installer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1659,7 +1659,7 @@ bool MCModeMakeLocalWindows(void)

void MCModeActivateIme(MCStack *p_stack, bool p_activate)
{
MCscreen -> activateIME(p_activate);
MCscreen -> pendingIME(p_activate);
}

void MCModeConfigureIme(MCStack *p_stack, bool p_enabled, int32_t x, int32_t y)
Expand Down
2 changes: 1 addition & 1 deletion engine/src/mode_standalone.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1278,7 +1278,7 @@ bool MCModeMakeLocalWindows(void)

void MCModeActivateIme(MCStack *p_stack, bool p_activate)
{
MCscreen -> activateIME(p_activate);
MCscreen -> pendingIME(p_activate);
}

void MCModeConfigureIme(MCStack *p_stack, bool p_enabled, int32_t x, int32_t y)
Expand Down
2 changes: 2 additions & 0 deletions engine/src/redraw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1441,6 +1441,8 @@ void MCRedrawDoUpdateScreen(void)
{
if (MClockscreen != 0)
return;

MCscreen->updateIME();

if (!s_screen_is_dirty)
return;
Expand Down
22 changes: 18 additions & 4 deletions engine/src/uidc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,9 @@ MCUIDC::MCUIDC()
m_runloop_actions = nil;

m_modal_loops = NULL;

m_ime_activate = false;
m_pending_ime_activate = false;
}

MCUIDC::~MCUIDC()
Expand Down Expand Up @@ -1114,17 +1117,28 @@ uint1 MCUIDC::fontnametocharset(MCStringRef p_fontname)
return 0;
}

void MCUIDC::openIME()
{}
void MCUIDC::activateIME(Boolean activate)
{}
void MCUIDC::clearIME(Window w)
{}
void MCUIDC::closeIME()
{}
void MCUIDC::configureIME(int32_t x, int32_t y)
{}

void MCUIDC::updateIME()
{
if (m_pending_ime_activate)
{
m_pending_ime_activate = false;
activateIME(m_ime_activate);
}
}

void MCUIDC::pendingIME(bool p_activate)
{
m_pending_ime_activate = true;
m_ime_activate = p_activate;
}

void MCUIDC::updatemenubar(Boolean force)
{
if (!MCdefaultmenubar)
Expand Down
6 changes: 4 additions & 2 deletions engine/src/uidc.h
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,8 @@ class MCUIDC
// IM-2014-03-06: [[ revBrowserCEF ]] List of actions to run during the runloop
MCRunloopAction *m_runloop_actions;

bool m_ime_activate;
bool m_pending_ime_activate;
public:
MCColor white_pixel;
MCColor black_pixel;
Expand Down Expand Up @@ -594,9 +596,9 @@ class MCUIDC

virtual void clearIME(Window w);
virtual void configureIME(int32_t x, int32_t y);
virtual void openIME();
virtual void activateIME(Boolean activate);
virtual void closeIME();
void pendingIME(bool activate);
void updateIME();

virtual void seticon(uint4 p_icon);
virtual void seticonmenu(MCStringRef p_menu);
Expand Down
4 changes: 1 addition & 3 deletions engine/src/w32dc.h
Original file line number Diff line number Diff line change
Expand Up @@ -283,10 +283,8 @@ class MCScreenDC : public MCUIDC
// virtual char *charsettofontname(uint1 chharset, const char *oldfontname);
virtual uint1 fontnametocharset(MCStringRef p_fontname);
virtual void clearIME(Window w);
virtual void openIME();
virtual void activateIME(Boolean activate);
virtual void closeIME();


virtual void enablebackdrop(bool p_hard);
virtual void disablebackdrop(bool p_hard);

Expand Down
5 changes: 0 additions & 5 deletions engine/src/w32dce.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -714,9 +714,6 @@ char *MCScreenDC::charsettofontname(uint1 charset, const char *oldfontname)
}
*/

void MCScreenDC::openIME()
{}

void MCScreenDC::activateIME(Boolean activate)
{}

Expand All @@ -727,5 +724,3 @@ void MCScreenDC::clearIME(Window w)
ImmReleaseContext((HWND)w->handle.window,hIMC);
}

void MCScreenDC::closeIME()
{}