Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/intern
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2011-10-24 08:18:28 +0400
committerCampbell Barton <ideasman42@gmail.com>2011-10-24 08:18:28 +0400
commit0503a4f7a6fa2aba573ff4f8d4c6d7f387894952 (patch)
tree26fa3836cd19536e6445ef4aad8fcecece1614f3 /intern
parent618d4d1a6e4a3df8399549fa80846cdeacb7299c (diff)
parent2bd9519e39f7c383005fd531f4c7dd92cce246ad (diff)
svn merge ^/trunk/blender -r41100:41150
Diffstat (limited to 'intern')
-rw-r--r--intern/audaspace/intern/AUD_ChannelMapperReader.cpp2
-rw-r--r--intern/ghost/GHOST_Types.h1
-rw-r--r--intern/ghost/intern/GHOST_EventKey.h5
-rw-r--r--intern/ghost/intern/GHOST_SystemCarbon.cpp2
-rw-r--r--intern/ghost/intern/GHOST_SystemCocoa.mm37
-rwxr-xr-xintern/ghost/intern/GHOST_SystemSDL.cpp2
-rw-r--r--intern/ghost/intern/GHOST_SystemWin32.cpp3
-rw-r--r--intern/ghost/intern/GHOST_SystemX11.cpp55
-rw-r--r--intern/ghost/intern/GHOST_SystemX11.h17
-rw-r--r--intern/ghost/intern/GHOST_WindowX11.cpp14
-rw-r--r--intern/ghost/intern/GHOST_WindowX11.h8
11 files changed, 134 insertions, 12 deletions
diff --git a/intern/audaspace/intern/AUD_ChannelMapperReader.cpp b/intern/audaspace/intern/AUD_ChannelMapperReader.cpp
index 27d10ce6dc8..7764164a9b0 100644
--- a/intern/audaspace/intern/AUD_ChannelMapperReader.cpp
+++ b/intern/audaspace/intern/AUD_ChannelMapperReader.cpp
@@ -352,7 +352,7 @@ const float AUD_ChannelMapperReader::SURROUND71_ANGLES[] =
0.0f * M_PI / 180.0f,
0.0f * M_PI / 180.0f,
-110.0f * M_PI / 180.0f,
- 110.0f * M_PI / 180.0f
+ 110.0f * M_PI / 180.0f,
-150.0f * M_PI / 180.0f,
150.0f * M_PI / 180.0f
};
diff --git a/intern/ghost/GHOST_Types.h b/intern/ghost/GHOST_Types.h
index dd399a7aa95..78fc3f69c7a 100644
--- a/intern/ghost/GHOST_Types.h
+++ b/intern/ghost/GHOST_Types.h
@@ -468,6 +468,7 @@ typedef struct {
GHOST_TKey key;
/** The ascii code for the key event ('\0' if none). */
char ascii;
+ char utf8_buf[6];
} GHOST_TEventKeyData;
typedef struct {
diff --git a/intern/ghost/intern/GHOST_EventKey.h b/intern/ghost/intern/GHOST_EventKey.h
index 3581cd86b20..a8fca1e8f2d 100644
--- a/intern/ghost/intern/GHOST_EventKey.h
+++ b/intern/ghost/intern/GHOST_EventKey.h
@@ -55,6 +55,7 @@ public:
{
m_keyEventData.key = key;
m_keyEventData.ascii = '\0';
+ m_keyEventData.utf8_buf[0]= '\0';
m_data = &m_keyEventData;
}
@@ -65,11 +66,13 @@ public:
* @param key The key code of the key.
* @param ascii The ascii code for the key event.
*/
- GHOST_EventKey(GHOST_TUns64 msec, GHOST_TEventType type, GHOST_IWindow* window, GHOST_TKey key, char ascii)
+ GHOST_EventKey(GHOST_TUns64 msec, GHOST_TEventType type, GHOST_IWindow* window, GHOST_TKey key, char ascii, const char utf8_buf[6])
: GHOST_Event(msec, type, window)
{
m_keyEventData.key = key;
m_keyEventData.ascii = ascii;
+ if (utf8_buf) memcpy(m_keyEventData.utf8_buf, utf8_buf, sizeof(m_keyEventData.utf8_buf));
+ else m_keyEventData.utf8_buf[0]= '\0';
m_data = &m_keyEventData;
}
diff --git a/intern/ghost/intern/GHOST_SystemCarbon.cpp b/intern/ghost/intern/GHOST_SystemCarbon.cpp
index 02ff5c0f559..762966c9b9e 100644
--- a/intern/ghost/intern/GHOST_SystemCarbon.cpp
+++ b/intern/ghost/intern/GHOST_SystemCarbon.cpp
@@ -931,7 +931,7 @@ OSStatus GHOST_SystemCarbon::handleKeyEvent(EventRef event)
} else {
type = GHOST_kEventKeyUp;
}
- pushEvent( new GHOST_EventKey( getMilliSeconds(), type, window, key, ascii) );
+ pushEvent( new GHOST_EventKey( getMilliSeconds(), type, window, key, ascii, NULL) );
// }
break;
diff --git a/intern/ghost/intern/GHOST_SystemCocoa.mm b/intern/ghost/intern/GHOST_SystemCocoa.mm
index 303c2b24497..1dfb8e36422 100644
--- a/intern/ghost/intern/GHOST_SystemCocoa.mm
+++ b/intern/ghost/intern/GHOST_SystemCocoa.mm
@@ -1654,8 +1654,19 @@ GHOST_TSuccess GHOST_SystemCocoa::handleKeyEvent(void *eventPtr)
//printf("\nW failure for event 0x%x",[event type]);
return GHOST_kFailure;
}
+
+ /* unicode input - not entirely supported yet
+ * but we are getting the right byte, Blender is not drawing it though
+ * also some languages may need special treatment:
+ - Japanese: romanji is used as input, and every 2 letters OSX converts the text
+ to Hiragana/Katakana.
+ - Korean: one add one letter at a time, and then the OSX join them in the equivalent
+ combined letter.
+ */
+ char utf8_buf[6]= {'\0'};
switch ([event type]) {
+
case NSKeyDown:
case NSKeyUp:
charsIgnoringModifiers = [event charactersIgnoringModifiers];
@@ -1667,7 +1678,7 @@ GHOST_TSuccess GHOST_SystemCocoa::handleKeyEvent(void *eventPtr)
keyCode = convertKey([event keyCode],0,
[event type] == NSKeyDown?kUCKeyActionDown:kUCKeyActionUp);
-
+ /* ascii */
characters = [event characters];
if ([characters length]>0) { //Check for dead keys
//Convert characters to iso latin 1 encoding
@@ -1679,16 +1690,32 @@ GHOST_TSuccess GHOST_SystemCocoa::handleKeyEvent(void *eventPtr)
}
else
ascii= 0;
+
+ /* unicode */
+ if ([characters length]>0) {
+ convertedCharacters = [characters dataUsingEncoding:NSUTF8StringEncoding];
+ if ([convertedCharacters length]>0) {
+ utf8_buf[0] = ((char*)[convertedCharacters bytes])[0];
+ utf8_buf[1] = ((char*)[convertedCharacters bytes])[1];
+ utf8_buf[2] = ((char*)[convertedCharacters bytes])[2];
+ utf8_buf[3] = ((char*)[convertedCharacters bytes])[3];
+ utf8_buf[4] = ((char*)[convertedCharacters bytes])[4];
+ utf8_buf[5] = ((char*)[convertedCharacters bytes])[5];
+ }
+ else {
+ utf8_buf[0] = '\0';
+ }
+ }
if ((keyCode == GHOST_kKeyQ) && (m_modifierMask & NSCommandKeyMask))
break; //Cmd-Q is directly handled by Cocoa
if ([event type] == NSKeyDown) {
- pushEvent( new GHOST_EventKey([event timestamp]*1000, GHOST_kEventKeyDown, window, keyCode, ascii) );
- //printf("\nKey down rawCode=0x%x charsIgnoringModifiers=%c keyCode=%u ascii=%i %c",[event keyCode],[charsIgnoringModifiers length]>0?[charsIgnoringModifiers characterAtIndex:0]:' ',keyCode,ascii,ascii);
+ pushEvent( new GHOST_EventKey([event timestamp]*1000, GHOST_kEventKeyDown, window, keyCode, ascii, utf8_buf) );
+ //printf("Key down rawCode=0x%x charsIgnoringModifiers=%c keyCode=%u ascii=%i %c utf8=%s\n",[event keyCode],[charsIgnoringModifiers length]>0?[charsIgnoringModifiers characterAtIndex:0]:' ',keyCode,ascii,ascii, utf8_buf);
} else {
- pushEvent( new GHOST_EventKey([event timestamp]*1000, GHOST_kEventKeyUp, window, keyCode, ascii) );
- //printf("\nKey up rawCode=0x%x charsIgnoringModifiers=%c keyCode=%u ascii=%i %c",[event keyCode],[charsIgnoringModifiers length]>0?[charsIgnoringModifiers characterAtIndex:0]:' ',keyCode,ascii,ascii);
+ pushEvent( new GHOST_EventKey([event timestamp]*1000, GHOST_kEventKeyUp, window, keyCode, ascii, utf8_buf) );
+ //printf("Key down rawCode=0x%x charsIgnoringModifiers=%c keyCode=%u ascii=%i %c utf8=%s\n",[event keyCode],[charsIgnoringModifiers length]>0?[charsIgnoringModifiers characterAtIndex:0]:' ',keyCode,ascii,ascii, utf8_buf);
}
break;
diff --git a/intern/ghost/intern/GHOST_SystemSDL.cpp b/intern/ghost/intern/GHOST_SystemSDL.cpp
index 12669ed1a19..2d53915b564 100755
--- a/intern/ghost/intern/GHOST_SystemSDL.cpp
+++ b/intern/ghost/intern/GHOST_SystemSDL.cpp
@@ -441,7 +441,7 @@ GHOST_SystemSDL::processEvent(SDL_Event *sdl_event)
}
}
- g_event= new GHOST_EventKey(getMilliSeconds(), type, window, gkey, sym);
+ g_event= new GHOST_EventKey(getMilliSeconds(), type, window, gkey, sym, NULL);
}
break;
}
diff --git a/intern/ghost/intern/GHOST_SystemWin32.cpp b/intern/ghost/intern/GHOST_SystemWin32.cpp
index 38f3985b139..24b6474732e 100644
--- a/intern/ghost/intern/GHOST_SystemWin32.cpp
+++ b/intern/ghost/intern/GHOST_SystemWin32.cpp
@@ -725,7 +725,8 @@ GHOST_EventKey* GHOST_SystemWin32::processKeyEvent(GHOST_IWindow *window, RAWINP
(LPSTR) &ascii, 1,
NULL,NULL);
- event = new GHOST_EventKey(system->getMilliSeconds(), keyDown ? GHOST_kEventKeyDown: GHOST_kEventKeyUp, window, key, ascii);
+ /* TODO, last arg is utf8, need to pass utf8 arg */
+ event = new GHOST_EventKey(system->getMilliSeconds(), keyDown ? GHOST_kEventKeyDown: GHOST_kEventKeyUp, window, key, ascii, NULL);
#ifdef GHOST_DEBUG
std::cout << ascii << std::endl;
diff --git a/intern/ghost/intern/GHOST_SystemX11.cpp b/intern/ghost/intern/GHOST_SystemX11.cpp
index 27a61cf57fc..209ffe501f4 100644
--- a/intern/ghost/intern/GHOST_SystemX11.cpp
+++ b/intern/ghost/intern/GHOST_SystemX11.cpp
@@ -89,6 +89,11 @@ GHOST_SystemX11(
abort(); //was return before, but this would just mean it will crash later
}
+ /* Open a connection to the X input manager */
+#if defined(WITH_X11_XINPUT) && defined(X_HAVE_UTF8_STRING)
+ m_xim = XOpenIM(m_display, NULL, (char *)GHOST_X11_RES_NAME, (char *)GHOST_X11_RES_CLASS);
+#endif
+
m_delete_window_atom
= XInternAtom(m_display, "WM_DELETE_WINDOW", True);
@@ -141,6 +146,10 @@ GHOST_SystemX11(
GHOST_SystemX11::
~GHOST_SystemX11()
{
+#if defined(WITH_X11_XINPUT) && defined(X_HAVE_UTF8_STRING)
+ XCloseIM(m_xim);
+#endif
+
XCloseDisplay(m_display);
}
@@ -500,9 +509,9 @@ GHOST_SystemX11::processEvent(XEvent *xe)
case KeyRelease:
{
XKeyEvent *xke = &(xe->xkey);
-
KeySym key_sym = XLookupKeysym(xke,0);
char ascii;
+ char utf8_buf[6]; /* 6 is enough for a utf8 char */
GHOST_TKey gkey = convertXKey(key_sym);
GHOST_TEventType type = (xke->type == KeyPress) ?
@@ -512,13 +521,55 @@ GHOST_SystemX11::processEvent(XEvent *xe)
ascii = '\0';
}
+#if defined(WITH_X11_XINPUT) && defined(X_HAVE_UTF8_STRING)
+ /* getting unicode on key-up events gives XLookupNone status */
+ if (xke->type == KeyPress) {
+ Status status;
+ int len;
+
+ /* use utf8 because its not locale depentant, from xorg docs */
+ if (!(len= Xutf8LookupString(window->getX11_XIC(), xke, utf8_buf, sizeof(utf8_buf), &key_sym, &status))) {
+ utf8_buf[0]= '\0';
+ }
+
+ if ((status == XLookupChars || status == XLookupBoth)) {
+ if ((unsigned char)utf8_buf[0] >= 32) { /* not an ascii control character */
+ /* do nothing for now, this is valid utf8 */
+ }
+ else {
+ utf8_buf[0]= '\0';
+ }
+ }
+ else if (status == XLookupKeySym) {
+ /* this key doesn't have a text representation, it is a command
+ key of some sort */;
+ }
+ else {
+ printf("Bad keycode lookup. Keysym 0x%x Status: %s\n",
+ (unsigned int) key_sym,
+ (status == XBufferOverflow ? "BufferOverflow" :
+ status == XLookupNone ? "XLookupNone" :
+ status == XLookupKeySym ? "XLookupKeySym" :
+ "Unknown status"));
+
+ printf("'%.*s' %p %p\n", len, utf8_buf, window->getX11_XIC(), m_xim);
+ }
+ }
+ else {
+ utf8_buf[0]= '\0';
+ }
+#else
+ utf8_buf[0]= '\0';
+#endif
+
g_event = new
GHOST_EventKey(
getMilliSeconds(),
type,
window,
gkey,
- ascii
+ ascii,
+ utf8_buf
);
break;
diff --git a/intern/ghost/intern/GHOST_SystemX11.h b/intern/ghost/intern/GHOST_SystemX11.h
index b43d955d156..af45d68450f 100644
--- a/intern/ghost/intern/GHOST_SystemX11.h
+++ b/intern/ghost/intern/GHOST_SystemX11.h
@@ -40,6 +40,12 @@
#include "GHOST_System.h"
#include "../GHOST_Types.h"
+#if defined(WITH_X11_XINPUT) && defined(X_HAVE_UTF8_STRING)
+# define GHOST_X11_RES_NAME "Blender" /* res_name */
+# define GHOST_X11_RES_CLASS "Blender" /* res_class */
+#endif
+
+
class GHOST_WindowX11;
/**
@@ -203,6 +209,14 @@ public:
return m_display;
}
+#if defined(WITH_X11_XINPUT) && defined(X_HAVE_UTF8_STRING)
+ XIM
+ getX11_XIM(
+ ) {
+ return m_xim;
+ }
+#endif
+
/* Helped function for get data from the clipboard. */
void getClipboard_xcout(XEvent evt, Atom sel, Atom target,
unsigned char **txt, unsigned long *len,
@@ -258,6 +272,9 @@ public:
private :
Display * m_display;
+#if defined(WITH_X11_XINPUT) && defined(X_HAVE_UTF8_STRING)
+ XIM m_xim;
+#endif
/// The vector of windows that need to be updated.
std::vector<GHOST_WindowX11 *> m_dirty_windows;
diff --git a/intern/ghost/intern/GHOST_WindowX11.cpp b/intern/ghost/intern/GHOST_WindowX11.cpp
index 160980b6331..d26224d956a 100644
--- a/intern/ghost/intern/GHOST_WindowX11.cpp
+++ b/intern/ghost/intern/GHOST_WindowX11.cpp
@@ -392,6 +392,13 @@ GHOST_WindowX11(
}
}
+#if defined(WITH_X11_XINPUT) && defined(X_HAVE_UTF8_STRING)
+ m_xic = XCreateIC(m_system->getX11_XIM(), XNClientWindow, m_window, XNFocusWindow, m_window,
+ XNInputStyle, XIMPreeditNothing | XIMStatusNothing,
+ XNResourceName, GHOST_X11_RES_NAME, XNResourceClass,
+ GHOST_X11_RES_CLASS, NULL);
+#endif
+
// Set the window icon
XWMHints *xwmhints = XAllocWMHints();
XImage *x_image, *mask_image;
@@ -1304,6 +1311,13 @@ GHOST_WindowX11::
XSetSelectionOwner(m_display, Clipboard_atom, None, CurrentTime);
}
+#if defined(WITH_X11_XINPUT) && defined(X_HAVE_UTF8_STRING)
+ if (m_xic) {
+ XDestroyIC(m_xic);
+ }
+#endif
+
+
XDestroyWindow(m_display, m_window);
XFree(m_visual);
}
diff --git a/intern/ghost/intern/GHOST_WindowX11.h b/intern/ghost/intern/GHOST_WindowX11.h
index 2cb269ea919..ee662945eaa 100644
--- a/intern/ghost/intern/GHOST_WindowX11.h
+++ b/intern/ghost/intern/GHOST_WindowX11.h
@@ -221,6 +221,10 @@ public:
{ return NULL; }
#endif // WITH_X11_XINPUT
+#if defined(WITH_X11_XINPUT) && defined(X_HAVE_UTF8_STRING)
+ XIC getX11_XIC() { return m_xic; }
+#endif
+
/*
* Need this in case that we want start the window
* in FullScree or Maximized state.
@@ -363,6 +367,10 @@ private :
XTablet m_xtablet;
#endif
+#if defined(WITH_X11_XINPUT) && defined(X_HAVE_UTF8_STRING)
+ XIC m_xic;
+#endif
+
void icccmSetState(int state);
int icccmGetState() const;