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
diff options
context:
space:
mode:
Diffstat (limited to 'intern/ghost/intern/GHOST_SystemX11.cpp')
-rw-r--r--intern/ghost/intern/GHOST_SystemX11.cpp144
1 files changed, 87 insertions, 57 deletions
diff --git a/intern/ghost/intern/GHOST_SystemX11.cpp b/intern/ghost/intern/GHOST_SystemX11.cpp
index e93a56cc8d4..bed9cd6c784 100644
--- a/intern/ghost/intern/GHOST_SystemX11.cpp
+++ b/intern/ghost/intern/GHOST_SystemX11.cpp
@@ -506,8 +506,9 @@ static void destroyIMCallback(XIM /*xim*/, XPointer ptr, XPointer /*data*/)
{
GHOST_PRINT("XIM server died\n");
- if (ptr)
+ if (ptr) {
*(XIM *)ptr = nullptr;
+ }
}
bool GHOST_SystemX11::openX11_IM()
@@ -519,8 +520,9 @@ bool GHOST_SystemX11::openX11_IM()
XSetLocaleModifiers("");
m_xim = XOpenIM(m_display, nullptr, (char *)GHOST_X11_RES_NAME, (char *)GHOST_X11_RES_CLASS);
- if (!m_xim)
+ if (!m_xim) {
return false;
+ }
XIMCallback destroy;
destroy.callback = (XIMProc)destroyIMCallback;
@@ -641,10 +643,11 @@ bool GHOST_SystemX11::processEvents(bool waitForEvent)
SleepTillEvent(m_display, -1);
}
else {
- int64_t maxSleep = next - getMilliSeconds();
+ const int64_t maxSleep = next - getMilliSeconds();
- if (maxSleep >= 0)
+ if (maxSleep >= 0) {
SleepTillEvent(m_display, next - getMilliSeconds());
+ }
}
}
@@ -692,8 +695,9 @@ bool GHOST_SystemX11::processEvents(bool waitForEvent)
}
else if (xevent.type == KeyPress) {
if ((xevent.xkey.keycode == m_last_release_keycode) &&
- ((xevent.xkey.time <= m_last_release_time)))
+ ((xevent.xkey.time <= m_last_release_time))) {
continue;
+ }
}
processEvent(&xevent);
@@ -733,7 +737,7 @@ bool GHOST_SystemX11::processEvents(bool waitForEvent)
XK_Super_R,
};
- for (int i = 0; i < (sizeof(modifiers) / sizeof(*modifiers)); i++) {
+ for (int i = 0; i < (int)(sizeof(modifiers) / sizeof(*modifiers)); i++) {
KeyCode kc = XKeysymToKeycode(m_display, modifiers[i]);
if (kc != 0 && ((xevent.xkeymap.key_vector[kc >> 3] >> (kc & 7)) & 1) != 0) {
pushEvent(new GHOST_EventKey(getMilliSeconds(),
@@ -1233,36 +1237,46 @@ void GHOST_SystemX11::processEvent(XEvent *xe)
/* process wheel mouse events and break, only pass on press events */
if (xbe.button == Button4) {
- if (xbe.type == ButtonPress)
+ if (xbe.type == ButtonPress) {
g_event = new GHOST_EventWheel(getMilliSeconds(), window, 1);
+ }
break;
}
- else if (xbe.button == Button5) {
- if (xbe.type == ButtonPress)
+ if (xbe.button == Button5) {
+ if (xbe.type == ButtonPress) {
g_event = new GHOST_EventWheel(getMilliSeconds(), window, -1);
+ }
break;
}
/* process rest of normal mouse buttons */
- if (xbe.button == Button1)
+ if (xbe.button == Button1) {
gbmask = GHOST_kButtonMaskLeft;
- else if (xbe.button == Button2)
+ }
+ else if (xbe.button == Button2) {
gbmask = GHOST_kButtonMaskMiddle;
- else if (xbe.button == Button3)
+ }
+ else if (xbe.button == Button3) {
gbmask = GHOST_kButtonMaskRight;
- /* It seems events 6 and 7 are for horizontal scrolling.
- * you can re-order button mapping like this... (swaps 6,7 with 8,9)
- * `xmodmap -e "pointer = 1 2 3 4 5 8 9 6 7"` */
- else if (xbe.button == 6)
+ /* It seems events 6 and 7 are for horizontal scrolling.
+ * you can re-order button mapping like this... (swaps 6,7 with 8,9)
+ * `xmodmap -e "pointer = 1 2 3 4 5 8 9 6 7"` */
+ }
+ else if (xbe.button == 6) {
gbmask = GHOST_kButtonMaskButton6;
- else if (xbe.button == 7)
+ }
+ else if (xbe.button == 7) {
gbmask = GHOST_kButtonMaskButton7;
- else if (xbe.button == 8)
+ }
+ else if (xbe.button == 8) {
gbmask = GHOST_kButtonMaskButton4;
- else if (xbe.button == 9)
+ }
+ else if (xbe.button == 9) {
gbmask = GHOST_kButtonMaskButton5;
- else
+ }
+ else {
break;
+ }
g_event = new GHOST_EventButton(
getMilliSeconds(), type, window, gbmask, window->GetTabletData());
@@ -1326,8 +1340,9 @@ void GHOST_SystemX11::processEvent(XEvent *xe)
if (XGetWindowAttributes(m_display, xcme.window, &attr) == True) {
if (XGetInputFocus(m_display, &fwin, &revert_to) == True) {
if (attr.map_state == IsViewable) {
- if (fwin != xcme.window)
+ if (fwin != xcme.window) {
XSetInputFocus(m_display, xcme.window, RevertToParent, xcme.data.l[1]);
+ }
}
}
}
@@ -1376,10 +1391,12 @@ void GHOST_SystemX11::processEvent(XEvent *xe)
// printf("X: %s window %d\n",
// xce.type == EnterNotify ? "entering" : "leaving", (int) xce.window);
- if (xce.type == EnterNotify)
+ if (xce.type == EnterNotify) {
m_windowManager->setActiveWindow(window);
- else
+ }
+ else {
m_windowManager->setWindowInactive(window);
+ }
break;
}
@@ -1645,10 +1662,10 @@ static GHOST_TSuccess getCursorPosition_impl(Display *display,
&mask_return) == False) {
return GHOST_kFailure;
}
- else {
- x = rx;
- y = ry;
- }
+
+ x = rx;
+ y = ry;
+
return GHOST_kSuccess;
}
@@ -1955,18 +1972,19 @@ void GHOST_SystemX11::getClipboard_xcout(const XEvent *evt,
return;
case XCLIB_XCOUT_SENTCONVSEL:
- if (evt->type != SelectionNotify)
+ if (evt->type != SelectionNotify) {
return;
+ }
if (target == m_atom.UTF8_STRING && evt->xselection.property == None) {
*context = XCLIB_XCOUT_FALLBACK_UTF8;
return;
}
- else if (target == m_atom.COMPOUND_TEXT && evt->xselection.property == None) {
+ if (target == m_atom.COMPOUND_TEXT && evt->xselection.property == None) {
*context = XCLIB_XCOUT_FALLBACK_COMP;
return;
}
- else if (target == m_atom.TEXT && evt->xselection.property == None) {
+ if (target == m_atom.TEXT && evt->xselection.property == None) {
*context = XCLIB_XCOUT_FALLBACK_TEXT;
return;
}
@@ -2042,12 +2060,14 @@ void GHOST_SystemX11::getClipboard_xcout(const XEvent *evt,
* then read it, delete it, etc. */
/* make sure that the event is relevant */
- if (evt->type != PropertyNotify)
+ if (evt->type != PropertyNotify) {
return;
+ }
/* skip unless the property has a new value */
- if (evt->xproperty.state != PropertyNewValue)
+ if (evt->xproperty.state != PropertyNewValue) {
return;
+ }
/* check size and format of the property */
XGetWindowProperty(m_display,
@@ -2121,7 +2141,6 @@ void GHOST_SystemX11::getClipboard_xcout(const XEvent *evt,
XFlush(m_display);
return;
}
- return;
}
char *GHOST_SystemX11::getClipboard(bool selection) const
@@ -2136,10 +2155,12 @@ char *GHOST_SystemX11::getClipboard(bool selection) const
XEvent evt;
unsigned int context = XCLIB_XCOUT_NONE;
- if (selection == True)
+ if (selection == True) {
sseln = m_atom.PRIMARY;
- else
+ }
+ else {
sseln = m_atom.CLIPBOARD;
+ }
const vector<GHOST_IWindow *> &win_vec = m_windowManager->getWindows();
vector<GHOST_IWindow *>::const_iterator win_it = win_vec.begin();
@@ -2154,20 +2175,18 @@ char *GHOST_SystemX11::getClipboard(bool selection) const
strcpy(sel_buf, txt_cut_buffer);
return sel_buf;
}
- else {
- sel_buf = (char *)malloc(strlen(txt_select_buffer) + 1);
- strcpy(sel_buf, txt_select_buffer);
- return sel_buf;
- }
+ sel_buf = (char *)malloc(strlen(txt_select_buffer) + 1);
+ strcpy(sel_buf, txt_select_buffer);
+ return sel_buf;
}
- else if (owner == None) {
+ if (owner == None) {
return nullptr;
}
/* Restore events so copy doesn't swallow other event types (keyboard/mouse). */
vector<XEvent> restore_events;
- while (1) {
+ while (true) {
/* only get an event if xcout() is doing something */
bool restore_this_event = false;
if (context != XCLIB_XCOUT_NONE) {
@@ -2188,26 +2207,27 @@ char *GHOST_SystemX11::getClipboard(bool selection) const
target = m_atom.STRING;
continue;
}
- else if (context == XCLIB_XCOUT_FALLBACK_UTF8) {
+ if (context == XCLIB_XCOUT_FALLBACK_UTF8) {
/* utf8 fail, move to compound text. */
context = XCLIB_XCOUT_NONE;
target = m_atom.COMPOUND_TEXT;
continue;
}
- else if (context == XCLIB_XCOUT_FALLBACK_COMP) {
+ if (context == XCLIB_XCOUT_FALLBACK_COMP) {
/* Compound text fail, move to text. */
context = XCLIB_XCOUT_NONE;
target = m_atom.TEXT;
continue;
}
- else if (context == XCLIB_XCOUT_FALLBACK_TEXT) {
+ if (context == XCLIB_XCOUT_FALLBACK_TEXT) {
/* Text fail, nothing else to try, break. */
context = XCLIB_XCOUT_NONE;
}
/* Only continue if #xcout() is doing something. */
- if (context == XCLIB_XCOUT_NONE)
+ if (context == XCLIB_XCOUT_NONE) {
break;
+ }
}
while (!restore_events.empty()) {
@@ -2221,10 +2241,12 @@ char *GHOST_SystemX11::getClipboard(bool selection) const
memcpy(tmp_data, (char *)sel_buf, sel_len);
tmp_data[sel_len] = '\0';
- if (sseln == m_atom.STRING)
+ if (sseln == m_atom.STRING) {
XFree(sel_buf);
- else
+ }
+ else {
free(sel_buf);
+ }
return tmp_data;
}
@@ -2244,8 +2266,9 @@ void GHOST_SystemX11::putClipboard(const char *buffer, bool selection) const
if (selection == False) {
XSetSelectionOwner(m_display, m_atom.CLIPBOARD, m_window, CurrentTime);
owner = XGetSelectionOwner(m_display, m_atom.CLIPBOARD);
- if (txt_cut_buffer)
+ if (txt_cut_buffer) {
free((void *)txt_cut_buffer);
+ }
txt_cut_buffer = (char *)malloc(strlen(buffer) + 1);
strcpy(txt_cut_buffer, buffer);
@@ -2253,15 +2276,17 @@ void GHOST_SystemX11::putClipboard(const char *buffer, bool selection) const
else {
XSetSelectionOwner(m_display, m_atom.PRIMARY, m_window, CurrentTime);
owner = XGetSelectionOwner(m_display, m_atom.PRIMARY);
- if (txt_select_buffer)
+ if (txt_select_buffer) {
free((void *)txt_select_buffer);
+ }
txt_select_buffer = (char *)malloc(strlen(buffer) + 1);
strcpy(txt_select_buffer, buffer);
}
- if (owner != m_window)
+ if (owner != m_window) {
fprintf(stderr, "failed to own primary\n");
+ }
}
}
@@ -2374,7 +2399,7 @@ GHOST_TSuccess GHOST_SystemX11::showMessageBox(const char *title,
const char *help_label,
const char *continue_label,
const char *link,
- GHOST_DialogOptions) const
+ GHOST_DialogOptions /*dialog_options*/) const
{
char **text_splitted = nullptr;
int textLines = 0;
@@ -2557,18 +2582,23 @@ static bool match_token(const char *haystack, const char *needle)
{
const char *h, *n;
for (h = haystack; *h;) {
- while (*h && is_filler_char(*h))
+ while (*h && is_filler_char(*h)) {
h++;
- if (!*h)
+ }
+ if (!*h) {
break;
+ }
- for (n = needle; *n && *h && tolower(*h) == tolower(*n); n++)
+ for (n = needle; *n && *h && tolower(*h) == tolower(*n); n++) {
h++;
- if (!*n && (is_filler_char(*h) || !*h))
+ }
+ if (!*n && (is_filler_char(*h) || !*h)) {
return true;
+ }
- while (*h && !is_filler_char(*h))
+ while (*h && !is_filler_char(*h)) {
h++;
+ }
}
return false;
}