From 41e47a56a89c7ef548f1e589ddcde5eebb207f06 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Nov 05 2019 18:31:33 +0000 Subject: Fix a number of numpad keys not working in ClanLib-0.6 based games --- diff --git a/ClanLib-0.6.5-compiler-warnings.patch b/ClanLib-0.6.5-compiler-warnings.patch new file mode 100644 index 0000000..7b4e9fb --- /dev/null +++ b/ClanLib-0.6.5-compiler-warnings.patch @@ -0,0 +1,319 @@ +diff -up ClanLib-0.6.5/Sources/Core/IOData/Generic/datafile_inputprovider.cpp~ ClanLib-0.6.5/Sources/Core/IOData/Generic/datafile_inputprovider.cpp +--- ClanLib-0.6.5/Sources/Core/IOData/Generic/datafile_inputprovider.cpp~ 2019-11-05 18:58:20.417208298 +0100 ++++ ClanLib-0.6.5/Sources/Core/IOData/Generic/datafile_inputprovider.cpp 2019-11-05 18:57:56.616025616 +0100 +@@ -304,7 +304,7 @@ int CL_InputSource_Datafile::size() cons + + void CL_InputSource_Datafile::push_position() + { +- CL_Zipped_Position indexpos; ++ CL_Zipped_Position indexpos = {}; + + indexpos.gzfile = gzfile; + // indexpos.datafile_pos = lseek(datafile_handle, 0, SEEK_CUR); +diff -up ClanLib-0.6.5/Sources/Core/IOData/Generic/inputsource_memory_generic.cpp~ ClanLib-0.6.5/Sources/Core/IOData/Generic/inputsource_memory_generic.cpp +--- ClanLib-0.6.5/Sources/Core/IOData/Generic/inputsource_memory_generic.cpp~ 2001-12-11 21:44:21.000000000 +0100 ++++ ClanLib-0.6.5/Sources/Core/IOData/Generic/inputsource_memory_generic.cpp 2019-11-05 18:56:35.535403281 +0100 +@@ -113,7 +113,7 @@ void CL_InputSource_MemoryGeneric::pop_p + + void CL_InputSource_MemoryGeneric::purge() + { +- memcpy(data, 0, length); ++ memset(data, 0, length); + } + + CL_InputSourceProvider_Memory::CL_InputSourceProvider_Memory(unsigned char *_data, unsigned int _size, bool _delete_data) +diff -up ClanLib-0.6.5/Sources/Core/IOData/Generic/outputsource_memory_generic.cpp~ ClanLib-0.6.5/Sources/Core/IOData/Generic/outputsource_memory_generic.cpp +--- ClanLib-0.6.5/Sources/Core/IOData/Generic/outputsource_memory_generic.cpp~ 2001-04-29 19:04:28.000000000 +0200 ++++ ClanLib-0.6.5/Sources/Core/IOData/Generic/outputsource_memory_generic.cpp 2019-11-05 18:58:49.664432780 +0100 +@@ -82,5 +82,5 @@ int CL_OutputSource_MemoryGeneric::size( + + void CL_OutputSource_MemoryGeneric::purge() + { +- memcpy(m_data,0,m_size); ++ memset(m_data,0,m_size); + } +diff -up ClanLib-0.6.5/Sources/Core/Math/vector2.cpp~ ClanLib-0.6.5/Sources/Core/Math/vector2.cpp +--- ClanLib-0.6.5/Sources/Core/Math/vector2.cpp~ 2001-09-15 16:54:51.000000000 +0200 ++++ ClanLib-0.6.5/Sources/Core/Math/vector2.cpp 2019-11-05 19:06:40.781048814 +0100 +@@ -66,9 +66,16 @@ bool CL_Vector2::operator!=(const CL_Vec + return fabs(x-rkVector.x) > FUZZ || fabs(y-rkVector.y) > FUZZ; + } + ++union float_uint { ++ float f; ++ unsigned int u; ++}; ++ + bool CL_Vector2::operator<(const CL_Vector2& rkVector) const + { + float fXTmp = rkVector.x, fYTmp = rkVector.y; ++ union float_uint uiTest0, uiTest1; ++ + if ( FUZZ > 0.0f ) + { + if ( fabs(x - fXTmp) <= FUZZ ) +@@ -78,22 +85,24 @@ bool CL_Vector2::operator<(const CL_Vect + } + + // compare y values +- unsigned int uiTest0 = *(unsigned int*)&y; +- unsigned int uiTest1 = *(unsigned int*)&fYTmp; +- if ( uiTest0 < uiTest1 ) ++ uiTest0.f = y; ++ uiTest1.f = fYTmp; ++ if ( uiTest0.u < uiTest1.u ) + return true; +- if ( uiTest0 > uiTest1 ) ++ if ( uiTest0.u > uiTest1.u ) + return false; + + // compare x values +- uiTest0 = *(unsigned int*)&x; +- uiTest1 = *(unsigned int*)&fXTmp; +- return uiTest0 < uiTest1; ++ uiTest0.f = x; ++ uiTest1.f = fXTmp; ++ return uiTest0.u < uiTest1.u; + } + + bool CL_Vector2::operator<=(const CL_Vector2& rkVector) const + { + float fXTmp = rkVector.x, fYTmp = rkVector.y; ++ union float_uint uiTest0, uiTest1; ++ + if ( FUZZ > 0.0f ) + { + if ( fabs(x - fXTmp) <= FUZZ ) +@@ -103,22 +112,24 @@ bool CL_Vector2::operator<=(const CL_Vec + } + + // compare y values +- unsigned int uiTest0 = *(unsigned int*)&y; +- unsigned int uiTest1 = *(unsigned int*)&fYTmp; +- if ( uiTest0 < uiTest1 ) ++ uiTest0.f = y; ++ uiTest1.f = fYTmp; ++ if ( uiTest0.u < uiTest1.u ) + return true; +- if ( uiTest0 > uiTest1 ) ++ if ( uiTest0.u > uiTest1.u ) + return false; + + // compare x values +- uiTest0 = *(unsigned int*)&x; +- uiTest1 = *(unsigned int*)&fXTmp; +- return uiTest0 <= uiTest1; ++ uiTest0.f = x; ++ uiTest1.f = fXTmp; ++ return uiTest0.u <= uiTest1.u; + } + + bool CL_Vector2::operator>(const CL_Vector2& rkVector) const + { + float fXTmp = rkVector.x, fYTmp = rkVector.y; ++ union float_uint uiTest0, uiTest1; ++ + if ( FUZZ > 0.0f ) + { + if ( fabs(x - fXTmp) <= FUZZ ) +@@ -128,22 +139,24 @@ bool CL_Vector2::operator>(const CL_Vect + } + + // compare y values +- unsigned int uiTest0 = *(unsigned int*)&y; +- unsigned int uiTest1 = *(unsigned int*)&fYTmp; +- if ( uiTest0 > uiTest1 ) ++ uiTest0.f = y; ++ uiTest1.f = fYTmp; ++ if ( uiTest0.u > uiTest1.u ) + return true; +- if ( uiTest0 < uiTest1 ) ++ if ( uiTest0.u < uiTest1.u ) + return false; + + // compare x values +- uiTest0 = *(unsigned int*)&x; +- uiTest1 = *(unsigned int*)&fXTmp; +- return uiTest0 > uiTest1; ++ uiTest0.f = x; ++ uiTest1.f = fXTmp; ++ return uiTest0.u > uiTest1.u; + } + + bool CL_Vector2::operator>=(const CL_Vector2& rkVector) const + { + float fXTmp = rkVector.x, fYTmp = rkVector.y; ++ union float_uint uiTest0, uiTest1; ++ + if ( FUZZ > 0.0f ) + { + if ( fabs(x - fXTmp) <= FUZZ ) +@@ -153,17 +166,17 @@ bool CL_Vector2::operator>=(const CL_Vec + } + + // compare y values +- unsigned int uiTest0 = *(unsigned int*)&y; +- unsigned int uiTest1 = *(unsigned int*)&fYTmp; +- if ( uiTest0 > uiTest1 ) ++ uiTest0.f = y; ++ uiTest1.f = fYTmp; ++ if ( uiTest0.u > uiTest1.u ) + return true; +- if ( uiTest0 < uiTest1 ) ++ if ( uiTest0.u < uiTest1.u ) + return false; + + // compare x values +- uiTest0 = *(unsigned int*)&x; +- uiTest1 = *(unsigned int*)&fXTmp; +- return uiTest0 >= uiTest1; ++ uiTest0.f = x; ++ uiTest1.f = fXTmp; ++ return uiTest0.u >= uiTest1.u; + } + + CL_Vector2 CL_Vector2::operator+(const CL_Vector2& rkVector) const +diff -up ClanLib-0.6.5/Sources/Display/Display/Generic/colormap.h~ ClanLib-0.6.5/Sources/Display/Display/Generic/colormap.h +--- ClanLib-0.6.5/Sources/Display/Display/Generic/colormap.h~ 2001-09-08 21:12:48.000000000 +0200 ++++ ClanLib-0.6.5/Sources/Display/Display/Generic/colormap.h 2019-11-05 19:09:31.942362545 +0100 +@@ -41,10 +41,14 @@ public: + unsigned int calc_color(float r, float g, float b, float a) + { + // paranoia: +- if (r>1) r=1; if (g>1) g=1; +- if (b>1) b=1; if (a>1) a=1; +- if (r<0) r=0; if (g<0) g=0; +- if (b<0) b=0; if (a<0) a=0; ++ if (r>1) r=1; ++ if (g>1) g=1; ++ if (b>1) b=1; ++ if (a>1) a=1; ++ if (r<0) r=0; ++ if (g<0) g=0; ++ if (b<0) b=0; ++ if (a<0) a=0; + + unsigned int red = (unsigned int) (r*((1<0;repcount--) +diff -up ClanLib-0.6.5/Sources/GUI/popupmenu_default.cpp~ ClanLib-0.6.5/Sources/GUI/popupmenu_default.cpp +--- ClanLib-0.6.5/Sources/GUI/popupmenu_default.cpp~ 2002-03-01 23:19:09.000000000 +0100 ++++ ClanLib-0.6.5/Sources/GUI/popupmenu_default.cpp 2019-11-05 19:22:27.540262347 +0100 +@@ -34,8 +34,6 @@ CL_PopupMenu_Default::CL_PopupMenu_Defau + + void CL_PopupMenu_Default::on_paint() + { +- bool focus = popupmenu->has_child(popupmenu->get_focus()); +- + int width = popupmenu->get_width(); + int height = popupmenu->get_height(); + +@@ -49,7 +47,6 @@ void CL_PopupMenu_Default::on_paint_node + CL_Component *component = node->get_component(); + + int height = component->get_height(); +- int mid = (height) / 2; + + // Draw arrow showing this item has a submenu + if(node->has_children()) +diff -up ClanLib-0.6.5/Sources/SmallJPEG/jpgd/idct.cpp~ ClanLib-0.6.5/Sources/SmallJPEG/jpgd/idct.cpp +--- ClanLib-0.6.5/Sources/SmallJPEG/jpgd/idct.cpp~ 2001-04-20 14:54:18.000000000 +0200 ++++ ClanLib-0.6.5/Sources/SmallJPEG/jpgd/idct.cpp 2019-11-05 19:22:38.574346144 +0100 +@@ -58,7 +58,7 @@ + #define FIX_2_562915447 ((int32) 20995) /* FIX(2.562915447) */ + #define FIX_3_072711026 ((int32) 25172) /* FIX(3.072711026) */ + /*----------------------------------------------------------------------------*/ +-#define DESCALE(x,n) (((x) + (SCALEDONE << ((n)-1))) >> n) ++#define DESCALE(x,n) (((x) + (SCALEDONE << ((n)-1))) >> (n)) + /*----------------------------------------------------------------------------*/ + #define MULTIPLY(var,cnst) ((var) * (cnst)) + /*----------------------------------------------------------------------------*/ +diff -up ClanLib-0.6.5/Sources/Sound/Sound/ClanSound/cdaudio_linux.cpp~ ClanLib-0.6.5/Sources/Sound/Sound/ClanSound/cdaudio_linux.cpp +--- ClanLib-0.6.5/Sources/Sound/Sound/ClanSound/cdaudio_linux.cpp~ 2002-06-22 14:58:11.000000000 +0200 ++++ ClanLib-0.6.5/Sources/Sound/Sound/ClanSound/cdaudio_linux.cpp 2019-11-05 19:17:01.993790133 +0100 +@@ -208,7 +208,6 @@ CL_CDDrive_Linux::CL_CDDrive_Linux(const + } + + file_handle = open(filename.c_str(),O_RDONLY);//|O_NONBLOCK); +- int error = errno; + if (file_handle <= 0) + { + // cout << "File handle: " << file_handle << endl; +@@ -235,7 +234,6 @@ CL_CDDrive_Linux::CL_CDDrive_Linux(const + } + else + { +- error = errno; + // cout << "Error Number: " << error << endl; + close(file_handle); + +@@ -377,10 +375,12 @@ int CL_CDDrive_Linux::get_cur_frame() + + bool CL_CDDrive_Linux::play_tracks(int track, int end_track) + { +- if((track < first_track) || (track > last_track)) ++ if ((track < first_track) || (track > last_track)) + return false; +- if((end_track < track) || (end_track > last_track)) +- return false; ++ ++ if ((end_track < track) || (end_track > last_track)) ++ return false; ++ + #ifdef __FreeBSD__ + ioc_play_msf msf; + #else +@@ -574,13 +574,12 @@ bool CL_CDDrive_Linux::readtoc() + + cur_track_info.entry.addr.lba = next_track_info.entry.addr.lba; + #else +- if(cur_track_info.cdte_ctrl == CDROM_DATA_TRACK) ++ if(cur_track_info.cdte_ctrl == CDROM_DATA_TRACK) + track.is_audio = false; +- +- +- tracks.push_back(track); +- cur_track_info.cdte_addr.lba = next_track_info.cdte_addr.lba; +- cur_track_info.cdte_ctrl = next_track_info.cdte_ctrl; ++ ++ tracks.push_back(track); ++ cur_track_info.cdte_addr.lba = next_track_info.cdte_addr.lba; ++ cur_track_info.cdte_ctrl = next_track_info.cdte_ctrl; + #endif + } + return true; +diff -up ClanLib-0.6.5/Sources/TTF/font_ttf.cpp~ ClanLib-0.6.5/Sources/TTF/font_ttf.cpp +--- ClanLib-0.6.5/Sources/TTF/font_ttf.cpp~ 2019-11-05 18:03:29.000000000 +0100 ++++ ClanLib-0.6.5/Sources/TTF/font_ttf.cpp 2019-11-05 19:23:45.533854635 +0100 +@@ -133,7 +133,7 @@ void CL_Font_TTF::generate_font() + unsigned char *buffer =(unsigned char*) canvas->get_data(); + unsigned char *bmp = (unsigned char*)face->glyph->bitmap.buffer; + +- for(int j=0;j<(face->glyph->bitmap.rows*face->glyph->bitmap.width);j++) ++ for(unsigned int j=0;j<(face->glyph->bitmap.rows*face->glyph->bitmap.width);j++) + { + *buffer = (*bmp) & a; + *(buffer+1) = (*bmp) & b; diff --git a/ClanLib-0.6.5-numpad-keys-fix.patch b/ClanLib-0.6.5-numpad-keys-fix.patch new file mode 100644 index 0000000..e0c5946 --- /dev/null +++ b/ClanLib-0.6.5-numpad-keys-fix.patch @@ -0,0 +1,37 @@ +diff -up ClanLib-0.6.5/Sources/Display/Input/X11/keyboard_x11.cpp~ ClanLib-0.6.5/Sources/Display/Input/X11/keyboard_x11.cpp +--- ClanLib-0.6.5/Sources/Display/Input/X11/keyboard_x11.cpp~ 2019-11-05 17:41:03.000000000 +0100 ++++ ClanLib-0.6.5/Sources/Display/Input/X11/keyboard_x11.cpp 2019-11-05 17:57:07.026831796 +0100 +@@ -211,6 +211,7 @@ int CL_XWindowKeyboard::map_keysym_to_id + case XK_Print: return CL_KEY_PRINT; + case XK_Insert: return CL_KEY_INSERT; + case XK_Num_Lock: return CL_KEY_NUMLOCK; ++ /* Keypad 0-9 + . numlock on */ + case XK_KP_0: return CL_KEY_KP_0; + case XK_KP_1: return CL_KEY_KP_1; + case XK_KP_2: return CL_KEY_KP_2; +@@ -221,6 +222,25 @@ int CL_XWindowKeyboard::map_keysym_to_id + case XK_KP_7: return CL_KEY_KP_7; + case XK_KP_8: return CL_KEY_KP_8; + case XK_KP_9: return CL_KEY_KP_9; ++ case XK_KP_Decimal: return CL_KEY_KP_DECIMAL; ++ /* Keypad 0-9 + . numlock off */ ++ case XK_KP_Insert: return CL_KEY_KP_0; ++ case XK_KP_End: return CL_KEY_KP_1; ++ case XK_KP_Down: return CL_KEY_KP_2; ++ case XK_KP_Page_Down: return CL_KEY_KP_3; ++ case XK_KP_Left: return CL_KEY_KP_4; ++ case XK_KP_Begin: return CL_KEY_KP_5; ++ case XK_KP_Right: return CL_KEY_KP_6; ++ case XK_KP_Home: return CL_KEY_KP_7; ++ case XK_KP_Up: return CL_KEY_KP_8; ++ case XK_KP_Page_Up: return CL_KEY_KP_9; ++ case XK_KP_Delete: return CL_KEY_KP_DECIMAL; ++ /* Keypad keys not influenced by numlock */ ++ case XK_KP_Divide: return CL_KEY_KP_DIV; ++ case XK_KP_Multiply: return CL_KEY_KP_MULT; ++ case XK_KP_Subtract: return CL_KEY_KP_MINUS; ++ case XK_KP_Add: return CL_KEY_KP_PLUS; ++ case XK_KP_Enter: return CL_KEY_KP_ENTER; + case XK_F1: return CL_KEY_F1; + case XK_F2: return CL_KEY_F2; + case XK_F3: return CL_KEY_F3; diff --git a/ClanLib06.spec b/ClanLib06.spec index b713f0f..1f6f623 100644 --- a/ClanLib06.spec +++ b/ClanLib06.spec @@ -1,7 +1,7 @@ Summary: Version 0.6 of this Cross platform C++ game library Name: ClanLib06 Version: 0.6.5 -Release: 46%{?dist} +Release: 47%{?dist} License: LGPLv2 URL: http://www.clanlib.org/ # No URL as this old version is no longer available on clanlib.org @@ -27,6 +27,8 @@ Patch13: ClanLib-0.6.5-lua52.patch Patch14: ClanLib-0.6.5-gcc6.patch Patch15: ClanLib-0.6.5-xwayland-fixes.patch Patch16: ClanLib-0.6.5-resolution-sort-fix.patch +Patch17: ClanLib-0.6.5-numpad-keys-fix.patch +Patch18: ClanLib-0.6.5-compiler-warnings.patch BuildRequires: gcc BuildRequires: gcc-c++ BuildRequires: libX11-devel libXext-devel libXt-devel libGLU-devel @@ -62,6 +64,7 @@ autoconf %build +export CXXFLAGS="$RPM_OPT_FLAGS -Wno-unused-result -Wno-write-strings -Wno-char-subscripts -Wno-deprecated-declarations" %ifarch %{ix86} ARCH_CONFIG_FLAGS=--enable-asm386 %endif @@ -93,6 +96,9 @@ chmod -x $RPM_BUILD_ROOT%{_mandir}/man1/clanlib-config.1* %changelog +* Tue Nov 5 2019 Hans de Goede - 0.6.5-47 +- Fix a number of numpad keys not working in ClanLib-0.6 based games + * Tue Nov 5 2019 Hans de Goede - 0.6.5-46 - Fix fullscreen windows not receiving events under Xwayland - Fix ClanLib sometimes selecting a non optimal resolution when going fullscreen