Commit 6375ee42 authored by hybrid's avatar hybrid

Fix indentation - Note to all: We use tabs...

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@2464 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 359fe440
...@@ -46,10 +46,10 @@ namespace irr ...@@ -46,10 +46,10 @@ namespace irr
namespace namespace
{ {
Atom X_ATOM_CLIPBOARD; Atom X_ATOM_CLIPBOARD;
Atom X_ATOM_TARGETS; Atom X_ATOM_TARGETS;
Atom X_ATOM_UTF8_STRING; Atom X_ATOM_UTF8_STRING;
Atom X_ATOM_TEXT; Atom X_ATOM_TEXT;
}; };
namespace irr namespace irr
...@@ -590,6 +590,15 @@ bool CIrrDeviceLinux::createWindow() ...@@ -590,6 +590,15 @@ bool CIrrDeviceLinux::createWindow()
{ {
// attach external window // attach external window
window = (Window)CreationParams.WindowId; window = (Window)CreationParams.WindowId;
if (!CreationParams.IgnoreInput)
{
XCreateWindow(display,
window,
0, 0, Width, Height, 0, visual->depth,
InputOutput, visual->visual,
CWBorderPixel | CWColormap | CWEventMask,
&attributes);
}
XWindowAttributes wa; XWindowAttributes wa;
XGetWindowAttributes(display, window, &wa); XGetWindowAttributes(display, window, &wa);
CreationParams.WindowSize.Width = wa.width; CreationParams.WindowSize.Width = wa.width;
...@@ -678,7 +687,7 @@ bool CIrrDeviceLinux::createWindow() ...@@ -678,7 +687,7 @@ bool CIrrDeviceLinux::createWindow()
SoftwareImage->data = (char*) malloc(SoftwareImage->bytes_per_line * SoftwareImage->height * sizeof(char)); SoftwareImage->data = (char*) malloc(SoftwareImage->bytes_per_line * SoftwareImage->height * sizeof(char));
} }
initXAtoms(); initXAtoms();
#endif // #ifdef _IRR_COMPILE_WITH_X11_ #endif // #ifdef _IRR_COMPILE_WITH_X11_
return true; return true;
...@@ -756,7 +765,7 @@ bool CIrrDeviceLinux::run() ...@@ -756,7 +765,7 @@ bool CIrrDeviceLinux::run()
while (XPending(display) > 0 && !Close) while (XPending(display) > 0 && !Close)
{ {
XEvent event; XEvent event;
XNextEvent(display, &event); XWindowEvent(display, window, -1, &event);
switch (event.type) switch (event.type)
{ {
...@@ -812,10 +821,10 @@ bool CIrrDeviceLinux::run() ...@@ -812,10 +821,10 @@ bool CIrrDeviceLinux::run()
irrevent.MouseInput.Control = (event.xkey.state & ControlMask) != 0; irrevent.MouseInput.Control = (event.xkey.state & ControlMask) != 0;
irrevent.MouseInput.Shift = (event.xkey.state & ShiftMask) != 0; irrevent.MouseInput.Shift = (event.xkey.state & ShiftMask) != 0;
// mouse button states // mouse button states
irrevent.MouseInput.ButtonStates = (event.xbutton.state & Button1Mask) ? irr::EMBSM_LEFT : 0; irrevent.MouseInput.ButtonStates = (event.xbutton.state & Button1Mask) ? irr::EMBSM_LEFT : 0;
irrevent.MouseInput.ButtonStates |= (event.xbutton.state & Button3Mask) ? irr::EMBSM_RIGHT : 0; irrevent.MouseInput.ButtonStates |= (event.xbutton.state & Button3Mask) ? irr::EMBSM_RIGHT : 0;
irrevent.MouseInput.ButtonStates |= (event.xbutton.state & Button2Mask) ? irr::EMBSM_MIDDLE : 0; irrevent.MouseInput.ButtonStates |= (event.xbutton.state & Button2Mask) ? irr::EMBSM_MIDDLE : 0;
postEventFromUser(irrevent); postEventFromUser(irrevent);
break; break;
...@@ -829,13 +838,13 @@ bool CIrrDeviceLinux::run() ...@@ -829,13 +838,13 @@ bool CIrrDeviceLinux::run()
irrevent.MouseInput.Control = (event.xkey.state & ControlMask) != 0; irrevent.MouseInput.Control = (event.xkey.state & ControlMask) != 0;
irrevent.MouseInput.Shift = (event.xkey.state & ShiftMask) != 0; irrevent.MouseInput.Shift = (event.xkey.state & ShiftMask) != 0;
// mouse button states // mouse button states
// This sets the state which the buttons had _prior_ to the event. // This sets the state which the buttons had _prior_ to the event.
// So unlike on Windows the button which just got changed has still the old state here. // So unlike on Windows the button which just got changed has still the old state here.
// We handle that below by flipping the corresponding bit later. // We handle that below by flipping the corresponding bit later.
irrevent.MouseInput.ButtonStates = (event.xbutton.state & Button1Mask) ? irr::EMBSM_LEFT : 0; irrevent.MouseInput.ButtonStates = (event.xbutton.state & Button1Mask) ? irr::EMBSM_LEFT : 0;
irrevent.MouseInput.ButtonStates |= (event.xbutton.state & Button3Mask) ? irr::EMBSM_RIGHT : 0; irrevent.MouseInput.ButtonStates |= (event.xbutton.state & Button3Mask) ? irr::EMBSM_RIGHT : 0;
irrevent.MouseInput.ButtonStates |= (event.xbutton.state & Button2Mask) ? irr::EMBSM_MIDDLE : 0; irrevent.MouseInput.ButtonStates |= (event.xbutton.state & Button2Mask) ? irr::EMBSM_MIDDLE : 0;
irrevent.MouseInput.Event = irr::EMIE_COUNT; irrevent.MouseInput.Event = irr::EMIE_COUNT;
...@@ -844,19 +853,19 @@ bool CIrrDeviceLinux::run() ...@@ -844,19 +853,19 @@ bool CIrrDeviceLinux::run()
case Button1: case Button1:
irrevent.MouseInput.Event = irrevent.MouseInput.Event =
(event.type == ButtonPress) ? irr::EMIE_LMOUSE_PRESSED_DOWN : irr::EMIE_LMOUSE_LEFT_UP; (event.type == ButtonPress) ? irr::EMIE_LMOUSE_PRESSED_DOWN : irr::EMIE_LMOUSE_LEFT_UP;
irrevent.MouseInput.ButtonStates ^= irr::EMBSM_LEFT; irrevent.MouseInput.ButtonStates ^= irr::EMBSM_LEFT;
break; break;
case Button3: case Button3:
irrevent.MouseInput.Event = irrevent.MouseInput.Event =
(event.type == ButtonPress) ? irr::EMIE_RMOUSE_PRESSED_DOWN : irr::EMIE_RMOUSE_LEFT_UP; (event.type == ButtonPress) ? irr::EMIE_RMOUSE_PRESSED_DOWN : irr::EMIE_RMOUSE_LEFT_UP;
irrevent.MouseInput.ButtonStates ^= irr::EMBSM_RIGHT; irrevent.MouseInput.ButtonStates ^= irr::EMBSM_RIGHT;
break; break;
case Button2: case Button2:
irrevent.MouseInput.Event = irrevent.MouseInput.Event =
(event.type == ButtonPress) ? irr::EMIE_MMOUSE_PRESSED_DOWN : irr::EMIE_MMOUSE_LEFT_UP; (event.type == ButtonPress) ? irr::EMIE_MMOUSE_PRESSED_DOWN : irr::EMIE_MMOUSE_LEFT_UP;
irrevent.MouseInput.ButtonStates ^= irr::EMBSM_MIDDLE; irrevent.MouseInput.ButtonStates ^= irr::EMBSM_MIDDLE;
break; break;
case Button4: case Button4:
...@@ -940,48 +949,49 @@ bool CIrrDeviceLinux::run() ...@@ -940,48 +949,49 @@ bool CIrrDeviceLinux::run()
} }
break; break;
case SelectionRequest: case SelectionRequest:
{ {
XEvent respond; XEvent respond;
XSelectionRequestEvent *req = &(event.xselectionrequest); XSelectionRequestEvent *req = &(event.xselectionrequest);
if ( req->target == XA_STRING) if ( req->target == XA_STRING)
{ {
XChangeProperty (display, XChangeProperty (display,
req->requestor, req->requestor,
req->property, req->target, req->property, req->target,
8, // format 8, // format
PropModeReplace, PropModeReplace,
(unsigned char*) Clipboard.c_str(), (unsigned char*) Clipboard.c_str(),
Clipboard.size()); Clipboard.size());
respond.xselection.property = req->property; respond.xselection.property = req->property;
} }
else if ( req->target == X_ATOM_TARGETS ) else if ( req->target == X_ATOM_TARGETS )
{ {
long data[2]; long data[2];
data[0] = X_ATOM_TEXT; data[0] = X_ATOM_TEXT;
data[1] = XA_STRING; data[1] = XA_STRING;
XChangeProperty (display, req->requestor, XChangeProperty (display, req->requestor,
req->property, req->target, req->property, req->target,
8, PropModeReplace, (unsigned char *) &data, 8, PropModeReplace,
sizeof (data)); (unsigned char *) &data,
respond.xselection.property = req->property; sizeof (data));
} respond.xselection.property = req->property;
else }
{ else
respond.xselection.property= None; {
} respond.xselection.property= None;
respond.xselection.type= SelectionNotify; }
respond.xselection.display= req->display; respond.xselection.type= SelectionNotify;
respond.xselection.requestor= req->requestor; respond.xselection.display= req->display;
respond.xselection.selection=req->selection; respond.xselection.requestor= req->requestor;
respond.xselection.target= req->target; respond.xselection.selection=req->selection;
respond.xselection.time = req->time; respond.xselection.target= req->target;
XSendEvent (display, req->requestor,0,0,&respond); respond.xselection.time = req->time;
XFlush (display); XSendEvent (display, req->requestor,0,0,&respond);
} XFlush (display);
break; }
break;
default: default:
break; break;
...@@ -1541,9 +1551,9 @@ void CIrrDeviceLinux::pollJoysticks() ...@@ -1541,9 +1551,9 @@ void CIrrDeviceLinux::pollJoysticks()
{ {
case JS_EVENT_BUTTON: case JS_EVENT_BUTTON:
if (event.value) if (event.value)
info.persistentData.JoystickEvent.ButtonStates |= (1 << event.number); info.persistentData.JoystickEvent.ButtonStates |= (1 << event.number);
else else
info.persistentData.JoystickEvent.ButtonStates &= ~(1 << event.number); info.persistentData.JoystickEvent.ButtonStates &= ~(1 << event.number);
break; break;
case JS_EVENT_AXIS: case JS_EVENT_AXIS:
...@@ -1566,25 +1576,25 @@ void CIrrDeviceLinux::pollJoysticks() ...@@ -1566,25 +1576,25 @@ void CIrrDeviceLinux::pollJoysticks()
const c8* CIrrDeviceLinux::getTextFromClipboard() const const c8* CIrrDeviceLinux::getTextFromClipboard() const
{ {
#if defined(_IRR_COMPILE_WITH_X11_) #if defined(_IRR_COMPILE_WITH_X11_)
Window ownerWindow = XGetSelectionOwner (display, X_ATOM_CLIPBOARD); Window ownerWindow = XGetSelectionOwner (display, X_ATOM_CLIPBOARD);
if ( ownerWindow == window ) if ( ownerWindow == window )
{ {
return Clipboard.c_str(); return Clipboard.c_str();
} }
Clipboard = ""; Clipboard = "";
if (ownerWindow != None ) if (ownerWindow != None )
{ {
XConvertSelection (display, X_ATOM_CLIPBOARD, XA_STRING, None, ownerWindow, CurrentTime); XConvertSelection (display, X_ATOM_CLIPBOARD, XA_STRING, None, ownerWindow, CurrentTime);
XFlush (display); XFlush (display);
// check for data // check for data
Atom type; Atom type;
int format; int format;
unsigned long numItems, bytesLeft, dummy; unsigned long numItems, bytesLeft, dummy;
unsigned char *data; unsigned char *data;
XGetWindowProperty (display, ownerWindow, XGetWindowProperty (display, ownerWindow,
XA_STRING, // property name XA_STRING, // property name
0, // offset 0, // offset
0, // length (we only check for data, so 0) 0, // length (we only check for data, so 0)
0, // Delete 0==false 0, // Delete 0==false
AnyPropertyType, // AnyPropertyType or property identifier AnyPropertyType, // AnyPropertyType or property identifier
...@@ -1592,23 +1602,23 @@ const c8* CIrrDeviceLinux::getTextFromClipboard() const ...@@ -1592,23 +1602,23 @@ const c8* CIrrDeviceLinux::getTextFromClipboard() const
&format, // return format &format, // return format
&numItems, // number items &numItems, // number items
&bytesLeft, // remaining bytes for partial reads &bytesLeft, // remaining bytes for partial reads
&data); // data &data); // data
if ( bytesLeft > 0 ) if ( bytesLeft > 0 )
{ {
// there is some data to get // there is some data to get
int result = XGetWindowProperty (display, ownerWindow, XA_STRING, 0, int result = XGetWindowProperty (display, ownerWindow, XA_STRING, 0,
bytesLeft, 0, AnyPropertyType, &type, &format, bytesLeft, 0, AnyPropertyType, &type, &format,
&numItems, &dummy, &data); &numItems, &dummy, &data);
if (result == Success) if (result == Success)
Clipboard = (irr::c8*)data; Clipboard = (irr::c8*)data;
XFree (data); XFree (data);
} }
} }
return Clipboard.c_str(); return Clipboard.c_str();
#else #else
return 0; return 0;
#endif #endif
} }
...@@ -1616,21 +1626,21 @@ const c8* CIrrDeviceLinux::getTextFromClipboard() const ...@@ -1616,21 +1626,21 @@ const c8* CIrrDeviceLinux::getTextFromClipboard() const
void CIrrDeviceLinux::copyToClipboard(const c8* text) const void CIrrDeviceLinux::copyToClipboard(const c8* text) const
{ {
#if defined(_IRR_COMPILE_WITH_X11_) #if defined(_IRR_COMPILE_WITH_X11_)
// Actually there is no clipboard on X but applications just say they own the clipboard and return text when asked. // Actually there is no clipboard on X but applications just say they own the clipboard and return text when asked.
// Which btw. also means that on X you lose clipboard content when closing applications. // Which btw. also means that on X you lose clipboard content when closing applications.
Clipboard = text; Clipboard = text;
XSetSelectionOwner (display, X_ATOM_CLIPBOARD, window, CurrentTime); XSetSelectionOwner (display, X_ATOM_CLIPBOARD, window, CurrentTime);
XFlush (display); XFlush (display);
#endif #endif
} }
void CIrrDeviceLinux::initXAtoms() void CIrrDeviceLinux::initXAtoms()
{ {
#ifdef _IRR_COMPILE_WITH_X11_ #ifdef _IRR_COMPILE_WITH_X11_
X_ATOM_CLIPBOARD = XInternAtom(display, "CLIPBOARD", False); X_ATOM_CLIPBOARD = XInternAtom(display, "CLIPBOARD", False);
X_ATOM_TARGETS = XInternAtom(display, "TARGETS", False); X_ATOM_TARGETS = XInternAtom(display, "TARGETS", False);
X_ATOM_UTF8_STRING = XInternAtom (display, "UTF8_STRING", False); X_ATOM_UTF8_STRING = XInternAtom (display, "UTF8_STRING", False);
X_ATOM_TEXT = XInternAtom (display, "TEXT", False); X_ATOM_TEXT = XInternAtom (display, "TEXT", False);
#endif #endif
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment