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-e03cc46cb475master
parent
359fe4408b
commit
6375ee4225
|
@ -46,10 +46,10 @@ namespace irr
|
|||
|
||||
namespace
|
||||
{
|
||||
Atom X_ATOM_CLIPBOARD;
|
||||
Atom X_ATOM_TARGETS;
|
||||
Atom X_ATOM_UTF8_STRING;
|
||||
Atom X_ATOM_TEXT;
|
||||
Atom X_ATOM_CLIPBOARD;
|
||||
Atom X_ATOM_TARGETS;
|
||||
Atom X_ATOM_UTF8_STRING;
|
||||
Atom X_ATOM_TEXT;
|
||||
};
|
||||
|
||||
namespace irr
|
||||
|
@ -590,6 +590,15 @@ bool CIrrDeviceLinux::createWindow()
|
|||
{
|
||||
// attach external window
|
||||
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;
|
||||
XGetWindowAttributes(display, window, &wa);
|
||||
CreationParams.WindowSize.Width = wa.width;
|
||||
|
@ -678,7 +687,7 @@ bool CIrrDeviceLinux::createWindow()
|
|||
SoftwareImage->data = (char*) malloc(SoftwareImage->bytes_per_line * SoftwareImage->height * sizeof(char));
|
||||
}
|
||||
|
||||
initXAtoms();
|
||||
initXAtoms();
|
||||
|
||||
#endif // #ifdef _IRR_COMPILE_WITH_X11_
|
||||
return true;
|
||||
|
@ -756,7 +765,7 @@ bool CIrrDeviceLinux::run()
|
|||
while (XPending(display) > 0 && !Close)
|
||||
{
|
||||
XEvent event;
|
||||
XNextEvent(display, &event);
|
||||
XWindowEvent(display, window, -1, &event);
|
||||
|
||||
switch (event.type)
|
||||
{
|
||||
|
@ -812,10 +821,10 @@ bool CIrrDeviceLinux::run()
|
|||
irrevent.MouseInput.Control = (event.xkey.state & ControlMask) != 0;
|
||||
irrevent.MouseInput.Shift = (event.xkey.state & ShiftMask) != 0;
|
||||
|
||||
// mouse button states
|
||||
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 & Button2Mask) ? irr::EMBSM_MIDDLE : 0;
|
||||
// mouse button states
|
||||
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 & Button2Mask) ? irr::EMBSM_MIDDLE : 0;
|
||||
|
||||
postEventFromUser(irrevent);
|
||||
break;
|
||||
|
@ -829,13 +838,13 @@ bool CIrrDeviceLinux::run()
|
|||
irrevent.MouseInput.Control = (event.xkey.state & ControlMask) != 0;
|
||||
irrevent.MouseInput.Shift = (event.xkey.state & ShiftMask) != 0;
|
||||
|
||||
// mouse button states
|
||||
// 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.
|
||||
// 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 & Button3Mask) ? irr::EMBSM_RIGHT : 0;
|
||||
irrevent.MouseInput.ButtonStates |= (event.xbutton.state & Button2Mask) ? irr::EMBSM_MIDDLE : 0;
|
||||
// mouse button states
|
||||
// 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.
|
||||
// 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 & Button3Mask) ? irr::EMBSM_RIGHT : 0;
|
||||
irrevent.MouseInput.ButtonStates |= (event.xbutton.state & Button2Mask) ? irr::EMBSM_MIDDLE : 0;
|
||||
|
||||
irrevent.MouseInput.Event = irr::EMIE_COUNT;
|
||||
|
||||
|
@ -844,19 +853,19 @@ bool CIrrDeviceLinux::run()
|
|||
case Button1:
|
||||
irrevent.MouseInput.Event =
|
||||
(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;
|
||||
|
||||
case Button3:
|
||||
irrevent.MouseInput.Event =
|
||||
(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;
|
||||
|
||||
case Button2:
|
||||
irrevent.MouseInput.Event =
|
||||
(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;
|
||||
|
||||
case Button4:
|
||||
|
@ -940,48 +949,49 @@ bool CIrrDeviceLinux::run()
|
|||
}
|
||||
break;
|
||||
|
||||
case SelectionRequest:
|
||||
{
|
||||
XEvent respond;
|
||||
XSelectionRequestEvent *req = &(event.xselectionrequest);
|
||||
if ( req->target == XA_STRING)
|
||||
{
|
||||
XChangeProperty (display,
|
||||
req->requestor,
|
||||
req->property, req->target,
|
||||
8, // format
|
||||
PropModeReplace,
|
||||
(unsigned char*) Clipboard.c_str(),
|
||||
Clipboard.size());
|
||||
respond.xselection.property = req->property;
|
||||
}
|
||||
else if ( req->target == X_ATOM_TARGETS )
|
||||
{
|
||||
long data[2];
|
||||
case SelectionRequest:
|
||||
{
|
||||
XEvent respond;
|
||||
XSelectionRequestEvent *req = &(event.xselectionrequest);
|
||||
if ( req->target == XA_STRING)
|
||||
{
|
||||
XChangeProperty (display,
|
||||
req->requestor,
|
||||
req->property, req->target,
|
||||
8, // format
|
||||
PropModeReplace,
|
||||
(unsigned char*) Clipboard.c_str(),
|
||||
Clipboard.size());
|
||||
respond.xselection.property = req->property;
|
||||
}
|
||||
else if ( req->target == X_ATOM_TARGETS )
|
||||
{
|
||||
long data[2];
|
||||
|
||||
data[0] = X_ATOM_TEXT;
|
||||
data[1] = XA_STRING;
|
||||
data[0] = X_ATOM_TEXT;
|
||||
data[1] = XA_STRING;
|
||||
|
||||
XChangeProperty (display, req->requestor,
|
||||
req->property, req->target,
|
||||
8, PropModeReplace, (unsigned char *) &data,
|
||||
sizeof (data));
|
||||
respond.xselection.property = req->property;
|
||||
}
|
||||
else
|
||||
{
|
||||
respond.xselection.property= None;
|
||||
}
|
||||
respond.xselection.type= SelectionNotify;
|
||||
respond.xselection.display= req->display;
|
||||
respond.xselection.requestor= req->requestor;
|
||||
respond.xselection.selection=req->selection;
|
||||
respond.xselection.target= req->target;
|
||||
respond.xselection.time = req->time;
|
||||
XSendEvent (display, req->requestor,0,0,&respond);
|
||||
XFlush (display);
|
||||
}
|
||||
break;
|
||||
XChangeProperty (display, req->requestor,
|
||||
req->property, req->target,
|
||||
8, PropModeReplace,
|
||||
(unsigned char *) &data,
|
||||
sizeof (data));
|
||||
respond.xselection.property = req->property;
|
||||
}
|
||||
else
|
||||
{
|
||||
respond.xselection.property= None;
|
||||
}
|
||||
respond.xselection.type= SelectionNotify;
|
||||
respond.xselection.display= req->display;
|
||||
respond.xselection.requestor= req->requestor;
|
||||
respond.xselection.selection=req->selection;
|
||||
respond.xselection.target= req->target;
|
||||
respond.xselection.time = req->time;
|
||||
XSendEvent (display, req->requestor,0,0,&respond);
|
||||
XFlush (display);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
|
@ -1541,9 +1551,9 @@ void CIrrDeviceLinux::pollJoysticks()
|
|||
{
|
||||
case JS_EVENT_BUTTON:
|
||||
if (event.value)
|
||||
info.persistentData.JoystickEvent.ButtonStates |= (1 << event.number);
|
||||
info.persistentData.JoystickEvent.ButtonStates |= (1 << event.number);
|
||||
else
|
||||
info.persistentData.JoystickEvent.ButtonStates &= ~(1 << event.number);
|
||||
info.persistentData.JoystickEvent.ButtonStates &= ~(1 << event.number);
|
||||
break;
|
||||
|
||||
case JS_EVENT_AXIS:
|
||||
|
@ -1566,25 +1576,25 @@ void CIrrDeviceLinux::pollJoysticks()
|
|||
const c8* CIrrDeviceLinux::getTextFromClipboard() const
|
||||
{
|
||||
#if defined(_IRR_COMPILE_WITH_X11_)
|
||||
Window ownerWindow = XGetSelectionOwner (display, X_ATOM_CLIPBOARD);
|
||||
if ( ownerWindow == window )
|
||||
{
|
||||
return Clipboard.c_str();
|
||||
}
|
||||
Clipboard = "";
|
||||
if (ownerWindow != None )
|
||||
{
|
||||
XConvertSelection (display, X_ATOM_CLIPBOARD, XA_STRING, None, ownerWindow, CurrentTime);
|
||||
XFlush (display);
|
||||
Window ownerWindow = XGetSelectionOwner (display, X_ATOM_CLIPBOARD);
|
||||
if ( ownerWindow == window )
|
||||
{
|
||||
return Clipboard.c_str();
|
||||
}
|
||||
Clipboard = "";
|
||||
if (ownerWindow != None )
|
||||
{
|
||||
XConvertSelection (display, X_ATOM_CLIPBOARD, XA_STRING, None, ownerWindow, CurrentTime);
|
||||
XFlush (display);
|
||||
|
||||
// check for data
|
||||
Atom type;
|
||||
int format;
|
||||
unsigned long numItems, bytesLeft, dummy;
|
||||
unsigned char *data;
|
||||
XGetWindowProperty (display, ownerWindow,
|
||||
XA_STRING, // property name
|
||||
0, // offset
|
||||
// check for data
|
||||
Atom type;
|
||||
int format;
|
||||
unsigned long numItems, bytesLeft, dummy;
|
||||
unsigned char *data;
|
||||
XGetWindowProperty (display, ownerWindow,
|
||||
XA_STRING, // property name
|
||||
0, // offset
|
||||
0, // length (we only check for data, so 0)
|
||||
0, // Delete 0==false
|
||||
AnyPropertyType, // AnyPropertyType or property identifier
|
||||
|
@ -1592,23 +1602,23 @@ const c8* CIrrDeviceLinux::getTextFromClipboard() const
|
|||
&format, // return format
|
||||
&numItems, // number items
|
||||
&bytesLeft, // remaining bytes for partial reads
|
||||
&data); // data
|
||||
if ( bytesLeft > 0 )
|
||||
{
|
||||
// there is some data to get
|
||||
int result = XGetWindowProperty (display, ownerWindow, XA_STRING, 0,
|
||||
bytesLeft, 0, AnyPropertyType, &type, &format,
|
||||
&numItems, &dummy, &data);
|
||||
if (result == Success)
|
||||
Clipboard = (irr::c8*)data;
|
||||
XFree (data);
|
||||
}
|
||||
}
|
||||
&data); // data
|
||||
if ( bytesLeft > 0 )
|
||||
{
|
||||
// there is some data to get
|
||||
int result = XGetWindowProperty (display, ownerWindow, XA_STRING, 0,
|
||||
bytesLeft, 0, AnyPropertyType, &type, &format,
|
||||
&numItems, &dummy, &data);
|
||||
if (result == Success)
|
||||
Clipboard = (irr::c8*)data;
|
||||
XFree (data);
|
||||
}
|
||||
}
|
||||
|
||||
return Clipboard.c_str();
|
||||
return Clipboard.c_str();
|
||||
|
||||
#else
|
||||
return 0;
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -1616,21 +1626,21 @@ const c8* CIrrDeviceLinux::getTextFromClipboard() const
|
|||
void CIrrDeviceLinux::copyToClipboard(const c8* text) const
|
||||
{
|
||||
#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.
|
||||
// Which btw. also means that on X you lose clipboard content when closing applications.
|
||||
Clipboard = text;
|
||||
XSetSelectionOwner (display, X_ATOM_CLIPBOARD, window, CurrentTime);
|
||||
XFlush (display);
|
||||
// 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.
|
||||
Clipboard = text;
|
||||
XSetSelectionOwner (display, X_ATOM_CLIPBOARD, window, CurrentTime);
|
||||
XFlush (display);
|
||||
#endif
|
||||
}
|
||||
|
||||
void CIrrDeviceLinux::initXAtoms()
|
||||
{
|
||||
#ifdef _IRR_COMPILE_WITH_X11_
|
||||
X_ATOM_CLIPBOARD = XInternAtom(display, "CLIPBOARD", False);
|
||||
X_ATOM_TARGETS = XInternAtom(display, "TARGETS", False);
|
||||
X_ATOM_UTF8_STRING = XInternAtom (display, "UTF8_STRING", False);
|
||||
X_ATOM_TEXT = XInternAtom (display, "TEXT", False);
|
||||
X_ATOM_CLIPBOARD = XInternAtom(display, "CLIPBOARD", False);
|
||||
X_ATOM_TARGETS = XInternAtom(display, "TARGETS", False);
|
||||
X_ATOM_UTF8_STRING = XInternAtom (display, "UTF8_STRING", False);
|
||||
X_ATOM_TEXT = XInternAtom (display, "TEXT", False);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue