BEAWARE all game functionality is disabled with this commit for a while

* rework client modules
* hide main window when loading
* remake top menu functions
* rework modules autoload
* improve path resolving for otml and lua
* move core_widgets to core_lib
* fix tooltip issues
* split some styles
* add bit32 lua library
* fix assert issues
* fix compilation on linux 32 systems
* rework gcc compile options
* renable and fix some warnings
* remove unused constants
* speedup sprite cache
* move UIGame to lua (not funcional yet)
* fix a lot of issues in x11 window
* fix crash handler
* add some warnings do uiwidget
and much more...
This commit is contained in:
Eduardo Bart
2012-02-20 00:27:08 -02:00
parent 96358b317d
commit e03bf33f58
201 changed files with 1443 additions and 707 deletions

View File

@@ -80,8 +80,8 @@ public:
bool isKeyPressed(Fw::Key keyCode) { return m_keysState[keyCode]; }
bool isVisible() { return m_visible; }
bool isMaximized() { return m_maximized; }
bool isFullscreen() { return m_fullscreen; }
virtual bool isMaximized() = 0;
bool hasFocus() { return m_focused; }
void setOnClose(const SimpleCallback& onClose) { m_onClose = onClose; }
@@ -112,6 +112,7 @@ protected:
Boolean<false> m_visible;
Boolean<false> m_focused;
Boolean<false> m_fullscreen;
Boolean<false> m_maximized;
SimpleCallback m_onClose;
OnResizeCallback m_onResize;

View File

@@ -20,14 +20,22 @@
* THE SOFTWARE.
*/
#define __USE_GNU
#include "crashhandler.h"
#include <framework/global.h>
#include <execinfo.h>
#include <framework/application.h>
#include <execinfo.h>
#include <ucontext.h>
#define MAX_BACKTRACE_DEPTH 128
#define DEMANGLE_BACKTRACE_SYMBOLS
#ifndef REG_RIP
#error fuck
#endif
void crashHandler(int signum, siginfo_t* info, void* secret)
{
logError("Application crashed");
@@ -41,20 +49,8 @@ void crashHandler(int signum, siginfo_t* info, void* secret)
std::stringstream ss;
ss.flags(std::ios::hex | std::ios::showbase);
#ifdef REG_EIP
ss <<
ss << " at eip = " << context.uc_mcontext.gregs[REG_EIP] << std::endl;
ss << " eax = " << context.uc_mcontext.gregs[REG_EAX] << std::endl;
ss << " ebx = " << context.uc_mcontext.gregs[REG_EBX] << std::endl;
ss << " ecx = " << context.uc_mcontext.gregs[REG_ECX] << std::endl;
ss << " edx = " << context.uc_mcontext.gregs[REG_EDX] << std::endl;
ss << " esi = " << context.uc_mcontext.gregs[REG_ESI] << std::endl;
ss << " edi = " << context.uc_mcontext.gregs[REG_EDI] << std::endl;
ss << " ebp = " << context.uc_mcontext.gregs[REG_EBP] << std::endl;
ss << " esp = " << context.uc_mcontext.gregs[REG_ESP] << std::endl;
ss << " efl = " << context.uc_mcontext.gregs[REG_EFL] << std::endl;
ss << std::endl;
#elifdef REG_RIP
#if __WORDSIZE == 64
ss << " at rip = " << context.uc_mcontext.gregs[REG_RIP] << std::endl;
ss << " rax = " << context.uc_mcontext.gregs[REG_RAX] << std::endl;
ss << " rbx = " << context.uc_mcontext.gregs[REG_RBX] << std::endl;
@@ -66,7 +62,20 @@ void crashHandler(int signum, siginfo_t* info, void* secret)
ss << " rsp = " << context.uc_mcontext.gregs[REG_RSP] << std::endl;
ss << " efl = " << context.uc_mcontext.gregs[REG_EFL] << std::endl;
ss << std::endl;
#else
ss << " at eip = " << context.uc_mcontext.gregs[REG_EIP] << std::endl;
ss << " eax = " << context.uc_mcontext.gregs[REG_EAX] << std::endl;
ss << " ebx = " << context.uc_mcontext.gregs[REG_EBX] << std::endl;
ss << " ecx = " << context.uc_mcontext.gregs[REG_ECX] << std::endl;
ss << " edx = " << context.uc_mcontext.gregs[REG_EDX] << std::endl;
ss << " esi = " << context.uc_mcontext.gregs[REG_ESI] << std::endl;
ss << " edi = " << context.uc_mcontext.gregs[REG_EDI] << std::endl;
ss << " ebp = " << context.uc_mcontext.gregs[REG_EBP] << std::endl;
ss << " esp = " << context.uc_mcontext.gregs[REG_ESP] << std::endl;
ss << " efl = " << context.uc_mcontext.gregs[REG_EFL] << std::endl;
ss << std::endl;
#endif
ss.flags(std::ios::dec);
ss << " backtrace:" << std::endl;

View File

@@ -36,7 +36,6 @@ WIN32Window::WIN32Window()
m_deviceContext = 0;
m_glContext = 0;
m_cursor = 0;
m_maximized = false;
m_minimumSize = Size(600,480);
m_keyMap[VK_ESCAPE] = Fw::KeyEscape;
@@ -675,7 +674,9 @@ void WIN32Window::setFullscreen(bool fullscreen)
return;
DWORD dwStyle = GetWindowLong(m_window, GWL_STYLE);
static WINDOWPLACEMENT wpPrev = { sizeof(wpPrev) };
static WINDOWPLACEMENT wpPrev;
wpPrev.length = sizeof(wpPrev);
if(fullscreen) {
GetWindowPlacement(m_window, &wpPrev);
SetWindowLong(m_window, GWL_STYLE, dwStyle & ~WS_OVERLAPPEDWINDOW);

View File

@@ -75,8 +75,6 @@ public:
std::string getClipboardText();
std::string getPlatformType();
bool isMaximized() { return m_maximized; }
private:
HWND m_window;
HINSTANCE m_instance;
@@ -84,7 +82,6 @@ private:
HGLRC m_glContext;
HCURSOR m_cursor;
HCURSOR m_defaultCursor;
bool m_maximized;
Size m_minimumSize;
};

View File

@@ -261,7 +261,8 @@ void X11Window::internalCreateWindow()
Visual *vis;
int depth;
unsigned int attrsMask = CWEventMask;
XSetWindowAttributes attrs = {0};
XSetWindowAttributes attrs;
memset(&attrs, 0, sizeof(attrs));
attrs.event_mask = KeyPressMask | KeyReleaseMask |
ButtonPressMask | ButtonReleaseMask | PointerMotionMask |
@@ -290,6 +291,8 @@ void X11Window::internalCreateWindow()
InputOutput,
vis,
attrsMask, &attrs);
m_visible = true;
if(!m_window)
logFatal("Unable to create X11 window!");
@@ -474,12 +477,9 @@ bool X11Window::isExtensionSupported(const char *ext)
void X11Window::move(const Point& pos)
{
bool wasVisible = isVisible();
if(!wasVisible)
show();
XMoveWindow(m_display, m_window, pos.x, pos.y);
if(!wasVisible)
hide();
m_position = pos;
if(m_visible)
XMoveWindow(m_display, m_window, m_position.x, m_position.y);
}
void X11Window::resize(const Size& size)
@@ -489,33 +489,45 @@ void X11Window::resize(const Size& size)
void X11Window::show()
{
m_visible = true;
XMapWindow(m_display, m_window);
XMoveWindow(m_display, m_window, m_position.x, m_position.y);
XFlush(m_display);
if(m_maximized)
maximize();
if(m_fullscreen)
setFullscreen(true);
}
void X11Window::hide()
{
m_visible = false;
XUnmapWindow(m_display, m_window);
XFlush(m_display);
}
void X11Window::maximize()
{
Atom wmState = XInternAtom(m_display, "_NET_WM_STATE", False);
Atom wmStateMaximizedVert = XInternAtom(m_display, "_NET_WM_STATE_MAXIMIZED_VERT", False);
Atom wmStateMaximizedHorz = XInternAtom(m_display, "_NET_WM_STATE_MAXIMIZED_HORZ", False);
if(m_visible) {
Atom wmState = XInternAtom(m_display, "_NET_WM_STATE", False);
Atom wmStateMaximizedVert = XInternAtom(m_display, "_NET_WM_STATE_MAXIMIZED_VERT", False);
Atom wmStateMaximizedHorz = XInternAtom(m_display, "_NET_WM_STATE_MAXIMIZED_HORZ", False);
XEvent e = {0};
e.xany.type = ClientMessage;
e.xclient.send_event = True;
e.xclient.message_type = wmState;
e.xclient.format = 32;
e.xclient.window = m_window;
e.xclient.data.l[0] = 1;
e.xclient.data.l[1] = wmStateMaximizedVert;
e.xclient.data.l[2] = wmStateMaximizedHorz;
e.xclient.data.l[3] = 0;
XEvent e = {0};
e.xany.type = ClientMessage;
e.xclient.send_event = True;
e.xclient.message_type = wmState;
e.xclient.format = 32;
e.xclient.window = m_window;
e.xclient.data.l[0] = 1;
e.xclient.data.l[1] = wmStateMaximizedVert;
e.xclient.data.l[2] = wmStateMaximizedHorz;
e.xclient.data.l[3] = 0;
XSendEvent(m_display, m_rootWindow, 0, SubstructureNotifyMask | SubstructureRedirectMask, &e);
XFlush(m_display);
XSendEvent(m_display, m_rootWindow, 0, SubstructureNotifyMask | SubstructureRedirectMask, &e);
XFlush(m_display);
}
m_maximized = true;
}
void X11Window::poll()
@@ -543,7 +555,7 @@ void X11Window::poll()
// lookup keysym and translate it
KeySym keysym;
char buf[32];
int len = XLookupString(&xkey, buf, sizeof(buf), &keysym, 0);
XLookupString(&xkey, buf, sizeof(buf), &keysym, 0);
Fw::Key keyCode = Fw::KeyUnknown;
if(m_keyMap.find(keysym) != m_keyMap.end())
@@ -580,8 +592,41 @@ void X11Window::poll()
needsResizeUpdate = true;
}
// checks if the window is maximized
if(m_visible) {
m_maximized = false;
Atom wmState = XInternAtom(m_display, "_NET_WM_STATE", False);
Atom wmStateMaximizedVert = XInternAtom(m_display, "_NET_WM_STATE_MAXIMIZED_VERT", False);
Atom wmStateMaximizedHorz = XInternAtom(m_display, "_NET_WM_STATE_MAXIMIZED_HORZ", False);
Atom actualType;
ulong i, numItems, bytesAfter;
uchar *propertyValue = NULL;
int actualFormat;
if(XGetWindowProperty(m_display, m_window, wmState,
0, 1024, False, XA_ATOM, &actualType,
&actualFormat, &numItems, &bytesAfter,
&propertyValue) == Success) {
Atom *atoms = (Atom*)propertyValue;
int maximizedMask = 0;
for(i=0; i<numItems; ++i) {
if(atoms[i] == wmStateMaximizedVert)
maximizedMask |= 1;
else if(atoms[i] == wmStateMaximizedHorz)
maximizedMask |= 2;
}
if(maximizedMask == 3)
m_maximized = true;
XFree(propertyValue);
}
}
// updates window pos
m_position = newPos;
if(m_visible)
m_position = newPos;
updateUnmaximizedCoords();
break;
}
@@ -754,7 +799,8 @@ void X11Window::hideMouse()
char bm[] = { 0, 0, 0, 0, 0, 0, 0, 0 };
Pixmap pix = XCreateBitmapFromData(m_display, m_window, bm, 8, 8);
XColor black = {0};
XColor black;
memset(&black, 0, sizeof(black));
black.flags = DoRed | DoGreen | DoBlue;
m_cursor = XCreatePixmapCursor(m_display, pix, pix, &black, &black, 0, 0);
XFreePixmap(m_display, pix);
@@ -843,7 +889,8 @@ void X11Window::setTitle(const std::string& title)
void X11Window::setMinimumSize(const Size& minimumSize)
{
XSizeHints sizeHints = {0};
XSizeHints sizeHints;
memset(&sizeHints, 0, sizeof(sizeHints));
sizeHints.flags = PMinSize;
sizeHints.min_width = minimumSize.width();
sizeHints.min_height= minimumSize.height();
@@ -852,7 +899,7 @@ void X11Window::setMinimumSize(const Size& minimumSize)
void X11Window::setFullscreen(bool fullscreen)
{
if(m_fullscreen != fullscreen) {
if(m_visible) {
Atom wmState = XInternAtom(m_display, "_NET_WM_STATE", False);
Atom wmStateFullscreen = XInternAtom(m_display, "_NET_WM_STATE_FULLSCREEN", False);
@@ -869,9 +916,8 @@ void X11Window::setFullscreen(bool fullscreen)
XSendEvent(m_display, m_rootWindow, False, SubstructureRedirectMask | SubstructureNotifyMask, &xev);
XFlush(m_display);
m_fullscreen = fullscreen;
}
m_fullscreen = fullscreen;
}
void X11Window::setVerticalSync(bool enable)
@@ -1001,40 +1047,3 @@ std::string X11Window::getPlatformType()
return "X11-EGL";
#endif
}
bool X11Window::isMaximized()
{
if(!m_display || !m_window)
return false;
Atom wmState = XInternAtom(m_display, "_NET_WM_STATE", False);
Atom wmStateMaximizedVert = XInternAtom(m_display, "_NET_WM_STATE_MAXIMIZED_VERT", False);
Atom wmStateMaximizedHorz = XInternAtom(m_display, "_NET_WM_STATE_MAXIMIZED_HORZ", False);
Atom actualType;
ulong i, numItems, bytesAfter;
uchar *propertyValue = NULL;
int actualFormat;
bool maximized = false;
if(XGetWindowProperty(m_display, m_window, wmState,
0, 1024, False, XA_ATOM, &actualType,
&actualFormat, &numItems, &bytesAfter,
&propertyValue) == Success) {
Atom *atoms = (Atom*)propertyValue;
int maximizedMask = 0;
for(i=0; i<numItems; ++i) {
if(atoms[i] == wmStateMaximizedVert)
maximizedMask |= 1;
else if(atoms[i] == wmStateMaximizedHorz)
maximizedMask |= 2;
}
if(maximizedMask == 3)
maximized = true;
XFree(propertyValue);
}
return maximized;
}