Some minor fixes in linux device

This commit is contained in:
Deve 2018-01-15 23:15:04 +01:00
parent a37b60ac6e
commit effa23d952

View File

@ -286,6 +286,7 @@ bool CIrrDeviceLinux::restoreResolution()
XRROutputInfo* output = XRRGetOutputInfo(display, res, output_id); XRROutputInfo* output = XRRGetOutputInfo(display, res, output_id);
if (!output || !output->crtc || output->connection == RR_Disconnected) if (!output || !output->crtc || output->connection == RR_Disconnected)
{ {
XRRFreeScreenResources(res);
XRRFreeOutputInfo(output); XRRFreeOutputInfo(output);
return false; return false;
} }
@ -293,6 +294,7 @@ bool CIrrDeviceLinux::restoreResolution()
XRRCrtcInfo* crtc = XRRGetCrtcInfo(display, res, output->crtc); XRRCrtcInfo* crtc = XRRGetCrtcInfo(display, res, output->crtc);
if (!crtc) if (!crtc)
{ {
XRRFreeScreenResources(res);
XRRFreeOutputInfo(output); XRRFreeOutputInfo(output);
return false; return false;
} }
@ -946,6 +948,8 @@ bool CIrrDeviceLinux::createWindow()
ButtonPressMask | KeyPressMask | ButtonPressMask | KeyPressMask |
ButtonReleaseMask | KeyReleaseMask; ButtonReleaseMask | KeyReleaseMask;
bool netWM = false;
Atom *list; Atom *list;
Atom type; Atom type;
int form; int form;
@ -956,8 +960,13 @@ bool CIrrDeviceLinux::createWindow()
WMCheck, 0L, 1L, False, XA_WINDOW, WMCheck, 0L, 1L, False, XA_WINDOW,
&type, &form, &len, &remain, &type, &form, &len, &remain,
(unsigned char **)&list); (unsigned char **)&list);
if (s == Success)
{
XFree(list); XFree(list);
bool netWM = (s == Success) && len; netWM = (len > 0);
}
if (!CreationParams.WindowId) if (!CreationParams.WindowId)
{ {
@ -1014,17 +1023,15 @@ bool CIrrDeviceLinux::createWindow()
Atom type; Atom type;
int format; int format;
unsigned long numItems, bytesAfter; unsigned long numItems, bytesAfter;
unsigned char* data = NULL; Atom* atoms = NULL;
int s = XGetWindowProperty(display, window, WMStateAtom, int s = XGetWindowProperty(display, window, WMStateAtom,
0l, 1024, False, XA_ATOM, &type, 0l, 1024, False, XA_ATOM, &type,
&format, &numItems, &bytesAfter, &format, &numItems, &bytesAfter,
&data); (unsigned char**)&atoms);
if (s == Success) if (s == Success)
{ {
Atom* atoms = (Atom*)data;
for (unsigned int i = 0; i < numItems; ++i) for (unsigned int i = 0; i < numItems; ++i)
{ {
if (atoms[i] == WMFullscreenAtom) if (atoms[i] == WMFullscreenAtom)
@ -1033,9 +1040,9 @@ bool CIrrDeviceLinux::createWindow()
break; break;
} }
} }
}
XFree(data); XFree(atoms);
}
if (fullscreen == true) if (fullscreen == true)
break; break;
@ -1770,13 +1777,20 @@ bool CIrrDeviceLinux::run()
case ClientMessage: case ClientMessage:
{ {
char *atom = XGetAtomName(display, event.xclient.message_type); char* atom = XGetAtomName(display, event.xclient.message_type);
if (*atom == *wmDeleteWindow)
if (atom != NULL)
{
if (strcmp(atom, "WM_PROTOCOLS") == 0)
{ {
os::Printer::log("Quit message received.", ELL_INFORMATION); os::Printer::log("Quit message received.", ELL_INFORMATION);
Close = true; Close = true;
} }
else
XFree(atom);
}
if (!Close)
{ {
// we assume it's a user message // we assume it's a user message
irrevent.EventType = irr::EET_USER_EVENT; irrevent.EventType = irr::EET_USER_EVENT;
@ -1784,7 +1798,6 @@ bool CIrrDeviceLinux::run()
irrevent.UserEvent.UserData2 = (s32)event.xclient.data.l[1]; irrevent.UserEvent.UserData2 = (s32)event.xclient.data.l[1];
postEventFromUser(irrevent); postEventFromUser(irrevent);
} }
XFree(atom);
} }
break; break;
@ -2808,9 +2821,11 @@ const c8* CIrrDeviceLinux::getTextFromClipboard() const
&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;