Fix compilation of linux

This commit is contained in:
Michael Bonfils
2018-02-10 17:08:16 +01:00
parent d940f2c39d
commit 12c3ce26f8
7 changed files with 28 additions and 15 deletions

View File

@@ -170,6 +170,7 @@ elif str(platform) == "win32":
def build_app_package(env, source, build_dir, info): def build_app_package(env, source, build_dir, info):
env.Install(build_dir, source) env.Install(build_dir, source)
elif str(platform) == "posix": elif str(platform) == "posix":
env.Append(CXXFLAGS="-include global.hpp")
def build_app_package(env, source, build_dir, info): def build_app_package(env, source, build_dir, info):
env.Install(build_dir, source) env.Install(build_dir, source)

View File

@@ -64,7 +64,7 @@ namespace ResMgr {
if(!found_hotspot) if(!found_hotspot)
std::cerr << "Cursor hotspot missing: " << fpath.string() << std::endl; std::cerr << "Cursor hotspot missing: " << fpath.string() << std::endl;
// TODO: Handle errors? // TODO: Handle errors?
CursorRsrc* cur = new cCursor(fpath.string(),x,y); CursorRsrc* cur = new Cursor(fpath.string(),x,y);
return cur; return cur;
} }
} }

View File

@@ -26,6 +26,9 @@ void init_menubar() {
void shut_down_menus(short mode) { void shut_down_menus(short mode) {
} }
void update_edit_menu() {
}
#include "cursors.hpp" #include "cursors.hpp"
#include "fileio.hpp" #include "fileio.hpp"

View File

@@ -42,7 +42,7 @@ enum cursor_type {
text_curs, // Keep this one last text_curs, // Keep this one last
}; };
class cCursor { class Cursor {
void* ptr; void* ptr;
public: public:
static cursor_type current; static cursor_type current;

View File

@@ -1,28 +1,34 @@
#include "cursors.hpp" #include "cursors.hpp"
#include "restypes.hpp" // Include before X11 to avoid macro conflicts in SFML // #include "restypes.hpp" // Include before X11 to avoid macro conflicts in SFML
#include <X11/Xlib.h> #include "res_cursor.hpp"
#include <X11/cursorfont.h>
Cursor ibeam; // = XCreateFontCursor(NULL, XC_xterm); namespace x11 {
extern cursor_type current_cursor; #include <X11/Xlib.h>
#include <X11/cursorfont.h>
}
x11::Cursor ibeam; // = XCreateFontCursor(NULL, XC_xterm);
// extern cursor_type current_cursor;
extern sf::RenderWindow mainPtr; extern sf::RenderWindow mainPtr;
cCursor::cCursor(fs::path imgPath, float hotSpotX, float hotSpotY) Cursor::Cursor(fs::path imgPath, float hotSpotX, float hotSpotY)
: ptr(nullptr) { : ptr(nullptr) {
} }
cCursor::~cCursor() { Cursor::~Cursor() {
if (ptr != nullptr) { if (ptr != nullptr) {
Cursor* realPtr = reinterpret_cast<Cursor*>(ptr); x11::Cursor* realPtr = reinterpret_cast<x11::Cursor*>(ptr);
XFreeCursor(NULL, *realPtr); x11::XFreeCursor(NULL, *realPtr);
delete realPtr; delete realPtr;
} }
} }
void cCursor::apply() { void Cursor::apply() {
// XDefineCursor(NULL, current_window, *reinterpret_cast<Cursor*>(ptr)); // XDefineCursor(NULL, current_window, *reinterpret_cast<Cursor*>(ptr));
} }
@@ -33,15 +39,16 @@ void obscureCursor() {
void set_cursor(cursor_type which_c) { void set_cursor(cursor_type which_c) {
if(which_c != watch_curs) if(which_c != watch_curs)
current_cursor = which_c; // current_cursor = which_c;
Cursor::current = which_c;
if(which_c == text_curs) { if(which_c == text_curs) {
// XDefineCursor(NULL, current_window, ibeam); // XDefineCursor(NULL, current_window, ibeam);
} else { } else {
cCursor& curs = *ResMgr::get<CursorRsrc>(cursors[which_c]); Cursor& curs = *ResMgr::get<CursorRsrc>(cursors[which_c]);
curs.apply(); curs.apply();
} }
} }
void restore_cursor() { void restore_cursor() {
set_cursor(current_cursor); set_cursor(Cursor::current);
} }

View File

@@ -21,6 +21,8 @@ std::string get_str(std::string list, short j);
#define strnicmp strncasecmp #define strnicmp strncasecmp
#elif defined(_WIN32) #elif defined(_WIN32)
#define strnicmp _strnicmp #define strnicmp _strnicmp
#elif defined(__unix__)
#define strnicmp strncasecmp
#else #else
#error Missing strnicmp / strncasecmp #error Missing strnicmp / strncasecmp
#endif #endif