diff --git a/CHANGES.md b/CHANGES.md index 85e5e4267c..9598fa4502 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,8 +1,15 @@ -# 1.6.5 (future) +# 1.6.6 (future) +- 3DS: Fixes serious performance regression that affected every core; rewind was always implicitly enabled. - AUDIO: MOD/S3M/XM sound should now be properly mixed in with the core's sound. +- GUI: Performance optimizations for XMB menu driver. - LOCALIZATION: Update Italian translation - INPUT: Overlay controller response - when we press buttons on the gamepad or keyboard, the corresponding buttons on the overlay will be highlighted as well. - NETBSD: Silence some compilation warnings. +- COMMON: Fixed bug 'Deleting an entry from a playlist would not update the list view inside XMB'. + +# 1.6.5 +Skipped this one. + # 1.6.4 diff --git a/Makefile.common b/Makefile.common index 698187ecd2..00bd4f74dd 100644 --- a/Makefile.common +++ b/Makefile.common @@ -380,106 +380,62 @@ OBJ += $(OBJS_TLS_CRYPTO) $(OBJS_TLS_X509) $(OBJS_TLS) endif ifeq ($(HAVE_LIBUI), 1) -ifeq ($(HAVE_GTKPLUS), 1) -CFLAGS += -I/usr/include/gtk-3.0 -I/usr/include/pango-1.0 -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/atk-1.0 -LIBS += -lgtk-3 -lgdk-3 -lpangocairo-1.0 -lpango-1.0 -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 -OBJ += deps/libui/gtk/alloc.o \ - deps/libui/gtk/area.o \ - deps/libui/gtk/box.o \ - deps/libui/gtk/button.o \ - deps/libui/gtk/cellrendererbutton.o \ - deps/libui/gtk/checkbox.o \ - deps/libui/gtk/child.o \ - deps/libui/gtk/colorbutton.o \ - deps/libui/gtk/combobox.o \ - deps/libui/gtk/control.o \ - deps/libui/gtk/datetimepicker.o \ - deps/libui/gtk/debug.o \ - deps/libui/gtk/draw.o \ - deps/libui/gtk/drawmatrix.o \ - deps/libui/gtk/drawpath.o \ - deps/libui/gtk/drawtext.o \ - deps/libui/gtk/editablecombo.o \ - deps/libui/gtk/entry.o \ - deps/libui/gtk/fontbutton.o \ - deps/libui/gtk/form.o \ - deps/libui/gtk/future.o \ - deps/libui/gtk/graphemes.o \ - deps/libui/gtk/grid.o \ - deps/libui/gtk/group.o \ - deps/libui/gtk/image.o \ - deps/libui/gtk/label.o \ - deps/libui/gtk/main.o \ - deps/libui/gtk/menu.o \ - deps/libui/gtk/multilineentry.o \ - deps/libui/gtk/progressbar.o \ - deps/libui/gtk/radiobuttons.o \ - deps/libui/gtk/separator.o \ - deps/libui/gtk/slider.o \ - deps/libui/gtk/spinbox.o \ - deps/libui/gtk/stddialogs.o \ - deps/libui/gtk/tab.o \ - deps/libui/gtk/text.o \ - deps/libui/gtk/util.o \ - deps/libui/gtk/window.o -endif - +DEFINES += -DHAVE_LIBUI ifneq ($(findstring Win32,$(OS)),) -OBJ += deps/libui/win32/alloc.o \ - deps/libui/win32/area.o \ - deps/libui/win32/areadraw.o \ - deps/libui/win32/areaevents.o \ - deps/libui/win32/areascroll.o \ - deps/libui/win32/areautil.o \ - deps/libui/win32/box.o \ - deps/libui/win32/button.o \ - deps/libui/win32/checkbox.o \ - deps/libui/win32/colorbutton.o \ - deps/libui/win32/colordialog.o \ - deps/libui/win32/combobox.o \ - deps/libui/win32/container.o \ - deps/libui/win32/control.o \ - deps/libui/win32/d2dscratch.o \ - deps/libui/win32/datetimepicker.o \ - deps/libui/win32/debug.o \ - deps/libui/win32/draw.o \ - deps/libui/win32/drawmatrix.o \ - deps/libui/win32/drawpath.o \ - deps/libui/win32/drawtext.o \ - deps/libui/win32/dwrite.o \ - deps/libui/win32/editablecombo.o \ - deps/libui/win32/entry.o \ - deps/libui/win32/events.o \ - deps/libui/win32/fontbutton.o \ - deps/libui/win32/fontdialog.o \ - deps/libui/win32/form.o \ - deps/libui/win32/graphemes.o \ - deps/libui/win32/grid.o \ - deps/libui/win32/group.o \ - deps/libui/win32/init.o \ - deps/libui/win32/label.o \ - deps/libui/win32/main.o \ - deps/libui/win32/menu.o \ - deps/libui/win32/multilineentry.o \ - deps/libui/win32/parent.o \ - deps/libui/win32/progressbar.o \ - deps/libui/win32/radiobuttons.o \ - deps/libui/win32/separator.o \ - deps/libui/win32/sizing.o \ - deps/libui/win32/slider.o \ - deps/libui/win32/spinbox.o \ - deps/libui/win32/stddialogs.o \ - deps/libui/win32/tab.o \ - deps/libui/win32/tabpage.o \ - deps/libui/win32/text.o \ - deps/libui/win32/utf16.o \ - deps/libui/win32/utilwin.o \ - deps/libui/win32/window.o \ - deps/libui/win32/winpublic.o \ - deps/libui/win32/winutil.o +OBJ += deps/libui/windows/alloc.o \ + deps/libui/windows/area.o \ + deps/libui/windows/areadraw.o \ + deps/libui/windows/areaevents.o \ + deps/libui/windows/areascroll.o \ + deps/libui/windows/areautil.o \ + deps/libui/windows/box.o \ + deps/libui/windows/button.o \ + deps/libui/windows/checkbox.o \ + deps/libui/windows/colorbutton.o \ + deps/libui/windows/colordialog.o \ + deps/libui/windows/combobox.o \ + deps/libui/windows/container.o \ + deps/libui/windows/control.o \ + deps/libui/windows/d2dscratch.o \ + deps/libui/windows/datetimepicker.o \ + deps/libui/windows/debug.o \ + deps/libui/windows/draw.o \ + deps/libui/windows/drawmatrix.o \ + deps/libui/windows/drawpath.o \ + deps/libui/windows/drawtext.o \ + deps/libui/windows/dwrite.o \ + deps/libui/windows/editablecombo.o \ + deps/libui/windows/entry.o \ + deps/libui/windows/events.o \ + deps/libui/windows/fontbutton.o \ + deps/libui/windows/fontdialog.o \ + deps/libui/windows/form.o \ + deps/libui/windows/graphemes.o \ + deps/libui/windows/grid.o \ + deps/libui/windows/group.o \ + deps/libui/windows/init.o \ + deps/libui/windows/label.o \ + deps/libui/windows/main.o \ + deps/libui/windows/menu.o \ + deps/libui/windows/multilineentry.o \ + deps/libui/windows/parent.o \ + deps/libui/windows/progressbar.o \ + deps/libui/windows/radiobuttons.o \ + deps/libui/windows/separator.o \ + deps/libui/windows/sizing.o \ + deps/libui/windows/slider.o \ + deps/libui/windows/spinbox.o \ + deps/libui/windows/stddialogs.o \ + deps/libui/windows/tab.o \ + deps/libui/windows/tabpage.o \ + deps/libui/windows/text.o \ + deps/libui/windows/utf16.o \ + deps/libui/windows/utilwin.o \ + deps/libui/windows/window.o \ + deps/libui/windows/winpublic.o \ + deps/libui/windows/winutil.o LIBS += -luxtheme -ld2d1 -ldwrite -lusp10 -endif - +else ifneq ($(findstring Darwin,$(OS)),) OBJ += deps/libui/darwin/alloc.o \ deps/libui/darwin/area.o \ @@ -519,6 +475,49 @@ OBJ += deps/libui/darwin/alloc.o \ deps/libui/darwin/util.o \ deps/libui/darwin/window.o \ deps/libui/darwin/winmoveresize.o +else +CFLAGS += -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/gtk-3.0 -I/usr/include/pango-1.0 -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/atk-1.0 +LIBS += -lgtk-3 -lgdk-3 -lpangocairo-1.0 -lpango-1.0 -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 +OBJ += deps/libui/unix/alloc.o \ + deps/libui/unix/area.o \ + deps/libui/unix/box.o \ + deps/libui/unix/button.o \ + deps/libui/unix/cellrendererbutton.o \ + deps/libui/unix/checkbox.o \ + deps/libui/unix/child.o \ + deps/libui/unix/colorbutton.o \ + deps/libui/unix/combobox.o \ + deps/libui/unix/control.o \ + deps/libui/unix/datetimepicker.o \ + deps/libui/unix/debug.o \ + deps/libui/unix/draw.o \ + deps/libui/unix/drawmatrix.o \ + deps/libui/unix/drawpath.o \ + deps/libui/unix/drawtext.o \ + deps/libui/unix/editablecombo.o \ + deps/libui/unix/entry.o \ + deps/libui/unix/fontbutton.o \ + deps/libui/unix/form.o \ + deps/libui/unix/future.o \ + deps/libui/unix/graphemes.o \ + deps/libui/unix/grid.o \ + deps/libui/unix/group.o \ + deps/libui/unix/image.o \ + deps/libui/unix/label.o \ + deps/libui/unix/main.o \ + deps/libui/unix/menu.o \ + deps/libui/unix/multilineentry.o \ + deps/libui/unix/progressbar.o \ + deps/libui/unix/radiobuttons.o \ + deps/libui/unix/separator.o \ + deps/libui/unix/slider.o \ + deps/libui/unix/spinbox.o \ + deps/libui/unix/stddialogs.o \ + deps/libui/unix/tab.o \ + deps/libui/unix/text.o \ + deps/libui/unix/util.o \ + deps/libui/unix/window.o +endif endif OBJ += deps/libui/common/areaevents.o \ diff --git a/Makefile.ps3 b/Makefile.ps3 index 944839aed5..2a106b97a2 100644 --- a/Makefile.ps3 +++ b/Makefile.ps3 @@ -1,4 +1,4 @@ -RARCH_VERSION = "1.6.4.0" +RARCH_VERSION = "1.6.5.0" #which compiler to build with - GCC or SNC #set to GCC for debug builds for use with debugger diff --git a/Makefile.psl1ght b/Makefile.psl1ght index 0569e41311..c0f1d611f1 100644 --- a/Makefile.psl1ght +++ b/Makefile.psl1ght @@ -1,4 +1,4 @@ -RARCH_VERSION = "1.6.4.0" +RARCH_VERSION = "1.6.5.0" DEBUG = 0 HAVE_LOGGER = 0 diff --git a/audio/drivers/wasapi.c b/audio/drivers/wasapi.c index 117d0f3fb4..089bee8978 100644 --- a/audio/drivers/wasapi.c +++ b/audio/drivers/wasapi.c @@ -741,9 +741,9 @@ static ssize_t wasapi_write(void *wh, const void *data, size_t size) for (writen = 0, ir = -1; writen < size; writen += ir) { if (w->exclusive) - ir = wasapi_write_ex(w, data + writen, size - writen); + ir = wasapi_write_ex(w, (char*)data + writen, size - writen); else - ir = wasapi_write_sh(w, data + writen, size - writen); + ir = wasapi_write_sh(w, (char*)data + writen, size - writen); if (ir == -1) return -1; } diff --git a/command.c b/command.c index 69907bf40b..5cafba1d2d 100644 --- a/command.c +++ b/command.c @@ -1865,13 +1865,17 @@ bool command_event(enum event_command cmd, void *data) if (settings->bools.cheevos_hardcore_mode_enable) return false; #endif + if (settings->bools.rewind_enable) + { #ifdef HAVE_NETWORKING - /* Only enable state manager if netplay is not underway - TODO: Add a setting for these tweaks */ - if (settings->bools.rewind_enable - && !netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_ENABLED, NULL)) + /* Only enable state manager if netplay is not underway +TODO: Add a setting for these tweaks */ + if (!netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_ENABLED, NULL)) #endif - state_manager_event_init((unsigned)settings->rewind_buffer_size); + { + state_manager_event_init((unsigned)settings->rewind_buffer_size); + } + } } break; case CMD_EVENT_REWIND_TOGGLE: @@ -1895,7 +1899,7 @@ bool command_event(enum event_command cmd, void *data) #ifdef HAVE_THREADS { #ifdef HAVE_NETWORKING - /* Only enable state manager if netplay is not underway + /* Only enable state manager if netplay is not underway TODO: Add a setting for these tweaks */ settings_t *settings = config_get_ptr(); if (settings->uints.autosave_interval != 0 @@ -2147,7 +2151,7 @@ bool command_event(enum event_command cmd, void *data) * need to make sure to keep a copy */ struct retro_hw_render_callback hwr_copy; struct retro_hw_render_callback *hwr = video_driver_get_hw_context(); - const struct retro_hw_render_context_negotiation_interface *iface = + const struct retro_hw_render_context_negotiation_interface *iface = video_driver_get_context_negotiation_interface(); memcpy(&hwr_copy, hwr, sizeof(hwr_copy)); @@ -2231,7 +2235,7 @@ bool command_event(enum event_command cmd, void *data) RARCH_LOG("%s\n", msg_hash_to_str(MSG_PAUSED)); command_event(CMD_EVENT_AUDIO_STOP, NULL); - runloop_msg_queue_push(msg_hash_to_str(MSG_PAUSED), 1, + runloop_msg_queue_push(msg_hash_to_str(MSG_PAUSED), 1, 1, true); if (!is_idle) @@ -2314,15 +2318,15 @@ bool command_event(enum event_command cmd, void *data) command_event(CMD_EVENT_NETPLAY_DEINIT, NULL); - if (!init_netplay(NULL, hostname ? hostname : + if (!init_netplay(NULL, hostname ? hostname : settings->paths.netplay_server, settings->uints.netplay_port)) { command_event(CMD_EVENT_NETPLAY_DEINIT, NULL); return false; } - - /* Disable rewind & sram autosave if it was enabled + + /* Disable rewind & sram autosave if it was enabled TODO: Add a setting for these tweaks */ state_manager_event_deinit(); #ifdef HAVE_THREADS @@ -2340,12 +2344,12 @@ bool command_event(enum event_command cmd, void *data) command_event(CMD_EVENT_NETPLAY_DEINIT, NULL); - RARCH_LOG("[netplay] connecting to %s:%d\n", - hostname->elems[0].data, !string_is_empty(hostname->elems[1].data) + RARCH_LOG("[netplay] connecting to %s:%d\n", + hostname->elems[0].data, !string_is_empty(hostname->elems[1].data) ? atoi(hostname->elems[1].data) : 55435); - if (!init_netplay(NULL, hostname->elems[0].data, - !string_is_empty(hostname->elems[1].data) + if (!init_netplay(NULL, hostname->elems[0].data, + !string_is_empty(hostname->elems[1].data) ? atoi(hostname->elems[1].data) : 55435)) { command_event(CMD_EVENT_NETPLAY_DEINIT, NULL); @@ -2355,7 +2359,7 @@ bool command_event(enum event_command cmd, void *data) string_list_free(hostname); - /* Disable rewind if it was enabled + /* Disable rewind if it was enabled TODO: Add a setting for these tweaks */ state_manager_event_deinit(); #ifdef HAVE_THREADS @@ -2373,12 +2377,12 @@ bool command_event(enum event_command cmd, void *data) command_event(CMD_EVENT_NETPLAY_DEINIT, NULL); - RARCH_LOG("[netplay] connecting to %s:%d\n", - hostname->elems[0].data, !string_is_empty(hostname->elems[1].data) + RARCH_LOG("[netplay] connecting to %s:%d\n", + hostname->elems[0].data, !string_is_empty(hostname->elems[1].data) ? atoi(hostname->elems[1].data) : 55435); if (!init_netplay_deferred(hostname->elems[0].data, - !string_is_empty(hostname->elems[1].data) + !string_is_empty(hostname->elems[1].data) ? atoi(hostname->elems[1].data) : 55435)) { command_event(CMD_EVENT_NETPLAY_DEINIT, NULL); @@ -2388,7 +2392,7 @@ bool command_event(enum event_command cmd, void *data) string_list_free(hostname); - /* Disable rewind if it was enabled + /* Disable rewind if it was enabled TODO: Add a setting for these tweaks */ state_manager_event_deinit(); #ifdef HAVE_THREADS @@ -2565,7 +2569,7 @@ bool command_event(enum event_command cmd, void *data) { static bool game_focus_state = false; intptr_t mode = (intptr_t)data; - + /* mode = -1: restores current game focus state * mode = 1: force set game focus, instead of toggling * any other: toggle @@ -2630,7 +2634,7 @@ bool command_event(enum event_command cmd, void *data) command_event_restore_default_shader_preset(); break; case CMD_EVENT_LIBUI_TEST: -#if 0 +#if HAVE_LIBUI libui_main(); #endif break; diff --git a/deps/libui/LICENSE b/deps/libui/LICENSE new file mode 100644 index 0000000000..2351d66d93 --- /dev/null +++ b/deps/libui/LICENSE @@ -0,0 +1,9 @@ +Copyright (c) 2014 Pietro Gagliardi + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +(this is called the MIT License or Expat License; see http://www.opensource.org/licenses/MIT) diff --git a/deps/libui/common/CMakeLists.txt b/deps/libui/common/CMakeLists.txt new file mode 100644 index 0000000000..91d794936f --- /dev/null +++ b/deps/libui/common/CMakeLists.txt @@ -0,0 +1,16 @@ +# 3 june 2016 + +list(APPEND _LIBUI_SOURCES + common/areaevents.c + common/control.c + common/debug.c + common/matrix.c + common/shouldquit.c + common/userbugs.c +) +set(_LIBUI_SOURCES ${_LIBUI_SOURCES} PARENT_SCOPE) + +list(APPEND _LIBUI_INCLUDEDIRS + common +) +set(_LIBUI_INCLUDEDIRS ${_LIBUI_INCLUDEDIRS} PARENT_SCOPE) diff --git a/deps/libui/common/control.c b/deps/libui/common/control.c index 0f4a9499be..2806646168 100644 --- a/deps/libui/common/control.c +++ b/deps/libui/common/control.c @@ -61,9 +61,11 @@ void uiControlDisable(uiControl *c) uiControl *uiAllocControl(size_t size, uint32_t OSsig, uint32_t typesig, const char *typenamestr) { - uiControl *c = (uiControl *) uiAlloc(size, typenamestr); - c->Signature = uiControlSignature; - c->OSSignature = OSsig; + uiControl *c; + + c = (uiControl *) uiAlloc(size, typenamestr); + c->Signature = uiControlSignature; + c->OSSignature = OSsig; c->TypeSignature = typesig; return c; } @@ -90,11 +92,10 @@ void uiControlVerifySetParent(uiControl *c, uiControl *parent) int uiControlEnabledToUser(uiControl *c) { - while (c != NULL) - { - if (!uiControlEnabled(c)) - return 0; - c = uiControlParent(c); - } + while (c != NULL) { + if (!uiControlEnabled(c)) + return 0; + c = uiControlParent(c); + } return 1; } diff --git a/deps/libui/common/controlsigs.h b/deps/libui/common/controlsigs.h index 14507e7b8d..1cbf18d5da 100644 --- a/deps/libui/common/controlsigs.h +++ b/deps/libui/common/controlsigs.h @@ -1,4 +1,4 @@ -/* 24 april 2016 */ +// 24 april 2016 #define uiAreaSignature 0x41726561 #define uiBoxSignature 0x426F784C diff --git a/deps/libui/common/matrix.c b/deps/libui/common/matrix.c index 4e44681a7b..676885d1bf 100644 --- a/deps/libui/common/matrix.c +++ b/deps/libui/common/matrix.c @@ -1,4 +1,4 @@ -/* 11 october 2015 */ +// 11 october 2015 #include #include "../ui.h" #include "uipriv.h" @@ -13,17 +13,17 @@ void uiDrawMatrixSetIdentity(uiDrawMatrix *m) m->M32 = 0; } -/* The rest of this file provides basic utilities in case the platform doesn't provide any of its own for these tasks. - * Keep these as minimal as possible. They should generally not call other fallbacks. +// The rest of this file provides basic utilities in case the platform doesn't provide any of its own for these tasks. +// Keep these as minimal as possible. They should generally not call other fallbacks. - * see https://msdn.microsoft.com/en-us/library/windows/desktop/ff684171%28v=vs.85%29.aspx#skew_transform - * TODO see if there's a way we can avoid the multiplication */ +// see https://msdn.microsoft.com/en-us/library/windows/desktop/ff684171%28v=vs.85%29.aspx#skew_transform +// TODO see if there's a way we can avoid the multiplication void fallbackSkew(uiDrawMatrix *m, double x, double y, double xamount, double yamount) { uiDrawMatrix n; uiDrawMatrixSetIdentity(&n); - /* TODO explain this */ + // TODO explain this n.M12 = tan(yamount); n.M21 = tan(xamount); n.M31 = -y * tan(xamount); @@ -37,13 +37,13 @@ void scaleCenter(double xCenter, double yCenter, double *x, double *y) *y = yCenter - (*y * yCenter); } -/* the basic algorithm is from cairo - * but it's the same algorithm as the transform point, - * just without M31 and M32 taken into account, so let's just do that instead */ +// the basic algorithm is from cairo +// but it's the same algorithm as the transform point, just without M31 and M32 taken into account, so let's just do that instead void fallbackTransformSize(uiDrawMatrix *m, double *x, double *y) { - uiDrawMatrix m2 = *m; + uiDrawMatrix m2; + m2 = *m; m2.M31 = 0; m2.M32 = 0; uiDrawMatrixTransformPoint(&m2, x, y); diff --git a/deps/libui/common/uipriv.h b/deps/libui/common/uipriv.h index e7c9940a83..d6b54e89ad 100644 --- a/deps/libui/common/uipriv.h +++ b/deps/libui/common/uipriv.h @@ -1,4 +1,4 @@ -/* 6 april 2015 */ +// 6 april 2015 #ifdef __cplusplus extern "C" { #endif @@ -13,7 +13,7 @@ extern void *uiAlloc(size_t, const char *); extern void *uiRealloc(void *, size_t, const char *); extern void uiFree(void *); -/* ugh, this was only introduced in MSVC 2015... */ +// ugh, this was only introduced in MSVC 2015... #ifdef _MSC_VER #define __func__ __FUNCTION__ #endif @@ -25,17 +25,16 @@ extern void _implbug(const char *file, const char *line, const char *func, const extern void _userbug(const char *file, const char *line, const char *func, const char *format, ...); #define userbug(...) _userbug(__FILE__, _ns(__LINE__), __func__, __VA_ARGS__) -/* control.c */ +// control.c extern uiControl *newControl(size_t size, uint32_t OSsig, uint32_t typesig, const char *typenamestr); -/* shouldquit.c */ +// shouldquit.c extern int shouldQuit(void); -/* areaevents.c */ +// areaevents.c typedef struct clickCounter clickCounter; - -/* you should call Reset() to zero-initialize a new instance - * it doesn't matter that all the non-count fields are zero: the first click will fail the curButton test straightaway, so it'll return 1 and set the rest of the structure accordingly */ +// you should call Reset() to zero-initialize a new instance +// it doesn't matter that all the non-count fields are zero: the first click will fail the curButton test straightaway, so it'll return 1 and set the rest of the structure accordingly struct clickCounter { int curButton; int rectX0; @@ -49,7 +48,7 @@ int clickCounterClick(clickCounter *c, int button, int x, int y, uintptr_t time, extern void clickCounterReset(clickCounter *); extern int fromScancode(uintptr_t, uiAreaKeyEvent *); -/* matrix.c */ +// matrix.c extern void fallbackSkew(uiDrawMatrix *, double, double, double, double); extern void scaleCenter(double, double, double *, double *); extern void fallbackTransformSize(uiDrawMatrix *, double *, double *); diff --git a/deps/libui/darwin/CMakeLists.txt b/deps/libui/darwin/CMakeLists.txt new file mode 100644 index 0000000000..dbef5d432c --- /dev/null +++ b/deps/libui/darwin/CMakeLists.txt @@ -0,0 +1,79 @@ +# 3 june 2016 + +list(APPEND _LIBUI_SOURCES + darwin/alloc.m + darwin/area.m + darwin/areaevents.m + darwin/autolayout.m + darwin/box.m + darwin/button.m + darwin/checkbox.m + darwin/colorbutton.m + darwin/combobox.m + darwin/control.m + darwin/datetimepicker.m + darwin/debug.m + darwin/draw.m + darwin/drawtext.m + darwin/editablecombo.m + darwin/entry.m + darwin/fontbutton.m + darwin/form.m + darwin/grid.m + darwin/group.m + darwin/image.m + darwin/label.m + darwin/main.m + darwin/map.m + darwin/menu.m + darwin/multilineentry.m + darwin/progressbar.m + darwin/radiobuttons.m + darwin/scrollview.m + darwin/separator.m + darwin/slider.m + darwin/spinbox.m + darwin/stddialogs.m + darwin/tab.m + darwin/text.m + darwin/util.m + darwin/window.m + darwin/winmoveresize.m +) +set(_LIBUI_SOURCES ${_LIBUI_SOURCES} PARENT_SCOPE) + +list(APPEND _LIBUI_INCLUDEDIRS + darwin +) +set(_LIBUI_INCLUDEDIRS _LIBUI_INCLUDEDIRS PARENT_SCOPE) + +set(_LIBUINAME libui PARENT_SCOPE) +if(NOT BUILD_SHARED_LIBS) + set(_LIBUINAME libui-temporary PARENT_SCOPE) +endif() +# thanks to Mr-Hide in irc.freenode.net/#cmake +macro(_handle_static) + set_target_properties(${_LIBUINAME} PROPERTIES + ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}") + set(_aname $) + set(_lname libui-combined.list) + set(_oname libui-combined.o) + add_custom_command( + OUTPUT ${_oname} + COMMAND + nm -m ${_aname} | sed -E -n "'s/^[0-9a-f]* \\([A-Z_]+,[a-z_]+\\) external //p'" > ${_lname} + COMMAND + ld -exported_symbols_list ${_lname} -r -all_load ${_aname} -o ${_oname} + COMMENT "Removing hidden symbols") + add_library(libui STATIC ${_oname}) + # otherwise cmake won't know which linker to use + set_target_properties(libui PROPERTIES + LINKER_LANGUAGE C) + set(_aname) + set(_lname) + set(_oname) +endmacro() + +set(_LIBUI_LIBS + objc "-framework Foundation" "-framework AppKit" +PARENT_SCOPE) diff --git a/deps/libui/ui.h b/deps/libui/ui.h index b6c9e728a8..5a2069e8a7 100644 --- a/deps/libui/ui.h +++ b/deps/libui/ui.h @@ -1,6 +1,6 @@ -/* 6 april 2015 */ +// 6 april 2015 -/* TODO add a uiVerifyControlType() function that can be used by control implementations to verify controls */ +// TODO add a uiVerifyControlType() function that can be used by control implementations to verify controls #ifndef __LIBUI_UI_H__ #define __LIBUI_UI_H__ @@ -12,7 +12,7 @@ extern "C" { #endif -/* this macro is generated by cmake */ +// this macro is generated by cmake #ifdef libui_EXPORTS #ifdef _WIN32 #define _UI_EXTERN __declspec(dllexport) extern @@ -20,19 +20,19 @@ extern "C" { #define _UI_EXTERN __attribute__((visibility("default"))) extern #endif #else -/* TODO add __declspec(dllimport) on windows, but only if not static */ +// TODO add __declspec(dllimport) on windows, but only if not static #define _UI_EXTERN extern #endif -/* C++ is really really really really really really dumb about enums, so screw that and just make them anonymous - * This has the advantage of being ABI-able should we ever need an ABI... */ +// C++ is really really really really really really dumb about enums, so screw that and just make them anonymous +// This has the advantage of being ABI-able should we ever need an ABI... #define _UI_ENUM(s) typedef unsigned int s; enum -/* This constant is provided because M_PI is nonstandard. - * This comes from Go's math.Pi, which in turn comes from http://oeis.org/A000796. */ +// This constant is provided because M_PI is nonstandard. +// This comes from Go's math.Pi, which in turn comes from http://oeis.org/A000796. #define uiPi 3.14159265358979323846264338327950288419716939937510582097494459 -/* TODO uiBool? */ +// TODO uiBool? typedef struct uiInitOptions uiInitOptions; @@ -73,7 +73,7 @@ struct uiControl { void (*Enable)(uiControl *); void (*Disable)(uiControl *); }; -/* TOOD add argument names to all arguments */ +// TOOD add argument names to all arguments #define uiControl(this) ((uiControl *) (this)) _UI_EXTERN void uiControlDestroy(uiControl *); _UI_EXTERN uintptr_t uiControlHandle(uiControl *); @@ -90,7 +90,7 @@ _UI_EXTERN void uiControlDisable(uiControl *); _UI_EXTERN uiControl *uiAllocControl(size_t n, uint32_t OSsig, uint32_t typesig, const char *typenamestr); _UI_EXTERN void uiFreeControl(uiControl *); -/* TODO make sure all controls have these */ +// TODO make sure all controls have these _UI_EXTERN void uiControlVerifySetParent(uiControl *, uiControl *); _UI_EXTERN int uiControlEnabledToUser(uiControl *); @@ -174,11 +174,10 @@ _UI_EXTERN int uiGroupMargined(uiGroup *g); _UI_EXTERN void uiGroupSetMargined(uiGroup *g, int margined); _UI_EXTERN uiGroup *uiNewGroup(const char *title); -/* spinbox/slider rules: - * setting value outside of range will automatically clamp - * initial value is minimum - * complaint if min >= max? - */ +// spinbox/slider rules: +// setting value outside of range will automatically clamp +// initial value is minimum +// complaint if min >= max? typedef struct uiSpinbox uiSpinbox; #define uiSpinbox(this) ((uiSpinbox *) (this)) @@ -218,7 +217,7 @@ typedef struct uiEditableCombobox uiEditableCombobox; _UI_EXTERN void uiEditableComboboxAppend(uiEditableCombobox *c, const char *text); _UI_EXTERN char *uiEditableComboboxText(uiEditableCombobox *c); _UI_EXTERN void uiEditableComboboxSetText(uiEditableCombobox *c, const char *text); -/* TODO what do we call a function that sets the currently selected item and fills the text field with it? editable comboboxes have no consistent concept of selected item */ +// TODO what do we call a function that sets the currently selected item and fills the text field with it? editable comboboxes have no consistent concept of selected item _UI_EXTERN void uiEditableComboboxOnChanged(uiEditableCombobox *c, void (*f)(uiEditableCombobox *c, void *data), void *data); _UI_EXTERN uiEditableCombobox *uiNewEditableCombobox(void); @@ -236,7 +235,7 @@ _UI_EXTERN uiDateTimePicker *uiNewDateTimePicker(void); _UI_EXTERN uiDateTimePicker *uiNewDatePicker(void); _UI_EXTERN uiDateTimePicker *uiNewTimePicker(void); -/* TODO provide a facility for entering tab stops? */ +// TODO provide a facility for entering tab stops? typedef struct uiMultilineEntry uiMultilineEntry; #define uiMultilineEntry(this) ((uiMultilineEntry *) (this)) _UI_EXTERN char *uiMultilineEntryText(uiMultilineEntry *e); @@ -292,8 +291,7 @@ struct uiAreaHandler { // TODO RTL layouts? // TODO reconcile edge and corner naming -_UI_ENUM(uiWindowResizeEdge) -{ +_UI_ENUM(uiWindowResizeEdge) { uiWindowResizeEdgeLeft, uiWindowResizeEdgeTop, uiWindowResizeEdgeRight, @@ -301,10 +299,10 @@ _UI_ENUM(uiWindowResizeEdge) uiWindowResizeEdgeTopLeft, uiWindowResizeEdgeTopRight, uiWindowResizeEdgeBottomLeft, - uiWindowResizeEdgeBottomRight - /* TODO have one for keyboard resizes? - * TODO GDK doesn't seem to have any others, including for keyboards... - * TODO way to bring up the system menu instead? */ + uiWindowResizeEdgeBottomRight, + // TODO have one for keyboard resizes? + // TODO GDK doesn't seem to have any others, including for keyboards... + // TODO way to bring up the system menu instead? }; #define uiArea(this) ((uiArea *) (this)) @@ -348,29 +346,29 @@ _UI_ENUM(uiDrawBrushType) { uiDrawBrushTypeSolid, uiDrawBrushTypeLinearGradient, uiDrawBrushTypeRadialGradient, - uiDrawBrushTypeImage + uiDrawBrushTypeImage, }; _UI_ENUM(uiDrawLineCap) { uiDrawLineCapFlat, uiDrawLineCapRound, - uiDrawLineCapSquare + uiDrawLineCapSquare, }; _UI_ENUM(uiDrawLineJoin) { uiDrawLineJoinMiter, uiDrawLineJoinRound, - uiDrawLineJoinBevel + uiDrawLineJoinBevel, }; -/* this is the default for botoh cairo and Direct2D (in the latter case, from the C++ helper functions) - * Core Graphics doesn't explicitly specify a default, but NSBezierPath allows you to choose one, and this is the initial value - * so we're good to use it too! */ +// this is the default for botoh cairo and Direct2D (in the latter case, from the C++ helper functions) +// Core Graphics doesn't explicitly specify a default, but NSBezierPath allows you to choose one, and this is the initial value +// so we're good to use it too! #define uiDrawDefaultMiterLimit 10.0 _UI_ENUM(uiDrawFillMode) { uiDrawFillModeWinding, - uiDrawFillModeAlternate + uiDrawFillModeAlternate, }; struct uiDrawMatrix { @@ -385,13 +383,13 @@ struct uiDrawMatrix { struct uiDrawBrush { uiDrawBrushType Type; - /* solid brushes */ + // solid brushes double R; double G; double B; double A; - /* gradient brushes */ + // gradient brushes double X0; // linear: start X, radial: start X double Y0; // linear: start Y, radial: start Y double X1; // linear: end X, radial: outer circle center X @@ -504,13 +502,13 @@ _UI_ENUM(uiDrawTextWeight) { uiDrawTextWeightBold, uiDrawTextWeightUltraBold, uiDrawTextWeightHeavy, - uiDrawTextWeightUltraHeavy + uiDrawTextWeightUltraHeavy, }; _UI_ENUM(uiDrawTextItalic) { uiDrawTextItalicNormal, uiDrawTextItalicOblique, - uiDrawTextItalicItalic + uiDrawTextItalicItalic, }; _UI_ENUM(uiDrawTextStretch) { @@ -522,7 +520,7 @@ _UI_ENUM(uiDrawTextStretch) { uiDrawTextStretchSemiExpanded, uiDrawTextStretchExpanded, uiDrawTextStretchExtraExpanded, - uiDrawTextStretchUltraExpanded + uiDrawTextStretchUltraExpanded, }; struct uiDrawTextFontDescriptor { @@ -563,10 +561,10 @@ _UI_EXTERN void uiDrawTextLayoutSetColor(uiDrawTextLayout *layout, int startChar _UI_EXTERN void uiDrawText(uiDrawContext *c, double x, double y, uiDrawTextLayout *layout); _UI_ENUM(uiModifiers) { - uiModifierCtrl = 1 << 0, - uiModifierAlt = 1 << 1, + uiModifierCtrl = 1 << 0, + uiModifierAlt = 1 << 1, uiModifierShift = 1 << 2, - uiModifierSuper = 1 << 3 + uiModifierSuper = 1 << 3, }; // TODO document drag captures @@ -628,7 +626,7 @@ _UI_ENUM(uiExtKey) { uiExtKeyNAdd, uiExtKeyNSubtract, uiExtKeyNMultiply, - uiExtKeyNDivide + uiExtKeyNDivide, }; struct uiAreaKeyEvent { @@ -643,9 +641,9 @@ struct uiAreaKeyEvent { typedef struct uiFontButton uiFontButton; #define uiFontButton(this) ((uiFontButton *) (this)) -/* TODO document this returns a new font */ +// TODO document this returns a new font _UI_EXTERN uiDrawTextFont *uiFontButtonFont(uiFontButton *b); -/* TOOD SetFont, mechanics */ +// TOOD SetFont, mechanics _UI_EXTERN void uiFontButtonOnChanged(uiFontButton *b, void (*f)(uiFontButton *, void *), void *data); _UI_EXTERN uiFontButton *uiNewFontButton(void); @@ -668,14 +666,14 @@ _UI_ENUM(uiAlign) { uiAlignFill, uiAlignStart, uiAlignCenter, - uiAlignEnd + uiAlignEnd, }; _UI_ENUM(uiAt) { uiAtLeading, uiAtTop, uiAtTrailing, - uiAtBottom + uiAtBottom, }; typedef struct uiGrid uiGrid; diff --git a/deps/libui/ui_unix.h b/deps/libui/ui_unix.h index 091965e7a7..5a91257bdd 100644 --- a/deps/libui/ui_unix.h +++ b/deps/libui/ui_unix.h @@ -1,4 +1,4 @@ -/* 7 april 2015 */ +// 7 april 2015 /* This file assumes that you have included and "ui.h" beforehand. It provides API-specific functions for interfacing with foreign controls on Unix systems that use GTK+ to provide their UI (currently all except Mac OS X). @@ -19,7 +19,7 @@ struct uiUnixControl { void (*SetContainer)(uiUnixControl *, GtkContainer *, gboolean); }; #define uiUnixControl(this) ((uiUnixControl *) (this)) -/* TODO document */ +// TODO document _UI_EXTERN void uiUnixControlSetContainer(uiUnixControl *, GtkContainer *, gboolean); #define uiUnixControlDefaultDestroy(type) \ @@ -80,7 +80,7 @@ _UI_EXTERN void uiUnixControlSetContainer(uiUnixControl *, GtkContainer *, gbool { \ gtk_widget_set_sensitive(type(c)->widget, FALSE); \ } -/* TODO this whole addedBefore stuff is a MASSIVE HACK. */ +// TODO this whole addedBefore stuff is a MASSIVE HACK. #define uiUnixControlDefaultSetContainer(type) \ static void type ## SetContainer(uiUnixControl *c, GtkContainer *container, gboolean remove) \ { \ @@ -112,7 +112,7 @@ _UI_EXTERN void uiUnixControlSetContainer(uiUnixControl *, GtkContainer *, gbool uiUnixControlDefaultDestroy(type) \ uiUnixControlAllDefaultsExceptDestroy(type) -/* TODO document */ +// TODO document #define uiUnixNewControl(type, var) \ var = type(uiUnixAllocControl(sizeof (type), type ## Signature, #type)); \ uiControl(var)->Destroy = type ## Destroy; \ @@ -127,10 +127,10 @@ _UI_EXTERN void uiUnixControlSetContainer(uiUnixControl *, GtkContainer *, gbool uiControl(var)->Enable = type ## Enable; \ uiControl(var)->Disable = type ## Disable; \ uiUnixControl(var)->SetContainer = type ## SetContainer; -/* TODO document */ +// TODO document _UI_EXTERN uiUnixControl *uiUnixAllocControl(size_t n, uint32_t typesig, const char *typenamestr); -/* uiUnixStrdupText() takes the given string and produces a copy of it suitable for being freed by uiFreeText(). */ +// uiUnixStrdupText() takes the given string and produces a copy of it suitable for being freed by uiFreeText(). _UI_EXTERN char *uiUnixStrdupText(const char *); #ifdef __cplusplus diff --git a/deps/libui/unix/CMakeLists.txt b/deps/libui/unix/CMakeLists.txt new file mode 100644 index 0000000000..9300bcb701 --- /dev/null +++ b/deps/libui/unix/CMakeLists.txt @@ -0,0 +1,85 @@ +# 3 june 2016 + +find_package(PkgConfig REQUIRED) +pkg_check_modules(GTK REQUIRED gtk+-3.0) + +list(APPEND _LIBUI_SOURCES + unix/alloc.c + unix/area.c + unix/box.c + unix/button.c + unix/cellrendererbutton.c + unix/checkbox.c + unix/child.c + unix/colorbutton.c + unix/combobox.c + unix/control.c + unix/datetimepicker.c + unix/debug.c + unix/draw.c + unix/drawmatrix.c + unix/drawpath.c + unix/drawtext.c + unix/editablecombo.c + unix/entry.c + unix/fontbutton.c + unix/form.c + unix/future.c + unix/graphemes.c + unix/grid.c + unix/group.c + unix/image.c + unix/label.c + unix/main.c + unix/menu.c + unix/multilineentry.c + unix/progressbar.c + unix/radiobuttons.c + unix/separator.c + unix/slider.c + unix/spinbox.c + unix/stddialogs.c + unix/tab.c + unix/text.c + unix/util.c + unix/window.c +) +set(_LIBUI_SOURCES ${_LIBUI_SOURCES} PARENT_SCOPE) + +list(APPEND _LIBUI_INCLUDEDIRS + unix +) +set(_LIBUI_INCLUDEDIRS _LIBUI_INCLUDEDIRS PARENT_SCOPE) + +set(_LIBUINAME libui PARENT_SCOPE) +if(NOT BUILD_SHARED_LIBS) + set(_LIBUINAME libui-temporary PARENT_SCOPE) +endif() +macro(_handle_static) + set_target_properties(${_LIBUINAME} PROPERTIES + ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}") + set(_aname $) + set(_oname libui-combined.o) + add_custom_command( + OUTPUT ${_oname} + COMMAND + ld -r --whole-archive ${_aname} -o ${_oname} + COMMAND + objcopy --localize-hidden ${_oname} + COMMENT "Removing hidden symbols") + add_library(libui STATIC ${_oname}) + # otherwise cmake won't know which linker to use + set_target_properties(libui PROPERTIES + LINKER_LANGUAGE C) + set(_aname) + set(_oname) +endmacro() + +# TODO the other variables don't work? +set(_LIBUI_CFLAGS + ${GTK_CFLAGS} +PARENT_SCOPE) + +set(_LIBUI_LIBS + ${GTK_LDFLAGS} m ${CMAKE_DL_LIBS} +PARENT_SCOPE) diff --git a/deps/libui/gtk/alloc.c b/deps/libui/unix/alloc.c similarity index 89% rename from deps/libui/gtk/alloc.c rename to deps/libui/unix/alloc.c index 53f2e7aa5b..2561efa6e2 100644 --- a/deps/libui/gtk/alloc.c +++ b/deps/libui/unix/alloc.c @@ -1,4 +1,4 @@ -/* 7 april 2015 */ +// 7 april 2015 #include #include "uipriv_unix.h" @@ -20,8 +20,8 @@ void initAlloc(void) static void uninitComplain(gpointer ptr, gpointer data) { - char *str2 = NULL; - char **str = (char **)data; + char **str = (char **) data; + char *str2; if (*str == NULL) *str = g_strdup_printf(""); @@ -34,12 +34,10 @@ void uninitAlloc(void) { char *str = NULL; - if (allocations->len == 0) - { - g_ptr_array_free(allocations, TRUE); - return; - } - + if (allocations->len == 0) { + g_ptr_array_free(allocations, TRUE); + return; + } g_ptr_array_foreach(allocations, uninitComplain, &str); userbug("Some data was leaked; either you left a uiControl lying around or there's a bug in libui itself. Leaked data:\n%s", str); g_free(str); @@ -47,8 +45,9 @@ void uninitAlloc(void) void *uiAlloc(size_t size, const char *type) { - void *out = g_malloc0(EXTRA + size); + void *out; + out = g_malloc0(EXTRA + size); *SIZE(out) = size; *TYPE(out) = type; g_ptr_array_add(allocations, out); diff --git a/deps/libui/gtk/area.c b/deps/libui/unix/area.c similarity index 70% rename from deps/libui/gtk/area.c rename to deps/libui/unix/area.c index 11089bbb9a..c46447cc33 100644 --- a/deps/libui/gtk/area.c +++ b/deps/libui/unix/area.c @@ -114,10 +114,10 @@ static void loadAreaSize(uiArea *a, double *width, double *height) static gboolean areaWidget_draw(GtkWidget *w, cairo_t *cr) { + areaWidget *aw = areaWidget(w); + uiArea *a = aw->a; uiAreaDrawParams dp; double clipX0, clipY0, clipX1, clipY1; - areaWidget *aw = areaWidget(w); - uiArea *a = aw->a; dp.Context = newContext(cr); @@ -129,30 +129,25 @@ static gboolean areaWidget_draw(GtkWidget *w, cairo_t *cr) dp.ClipWidth = clipX1 - clipX0; dp.ClipHeight = clipY1 - clipY0; - /* no need to save or restore the graphics state - * to reset transformations; GTK+ does that for us */ + // no need to save or restore the graphics state to reset transformations; GTK+ does that for us (*(a->ah->Draw))(a->ah, a, &dp); freeContext(dp.Context); return FALSE; } -/* to do this properly for scrolling areas, we need to - * - return the same value for min and nat - * - call gtk_widget_queue_resize() when the size changes - * thanks to Company in irc.gimp.net/#gtk+ */ -static void areaWidget_get_preferred_height(GtkWidget *w, - gint *min, gint *nat) +// to do this properly for scrolling areas, we need to +// - return the same value for min and nat +// - call gtk_widget_queue_resize() when the size changes +// thanks to Company in irc.gimp.net/#gtk+ +static void areaWidget_get_preferred_height(GtkWidget *w, gint *min, gint *nat) { areaWidget *aw = areaWidget(w); uiArea *a = aw->a; // always chain up just in case - GTK_WIDGET_CLASS(areaWidget_parent_class)-> - get_preferred_height(w, min, nat); - - if (a->scrolling) - { + GTK_WIDGET_CLASS(areaWidget_parent_class)->get_preferred_height(w, min, nat); + if (a->scrolling) { *min = a->scrollHeight; *nat = a->scrollHeight; } @@ -163,54 +158,51 @@ static void areaWidget_get_preferred_width(GtkWidget *w, gint *min, gint *nat) areaWidget *aw = areaWidget(w); uiArea *a = aw->a; - /* always chain up just in case */ + // always chain up just in case GTK_WIDGET_CLASS(areaWidget_parent_class)->get_preferred_width(w, min, nat); - if (a->scrolling) - { - *min = a->scrollWidth; - *nat = a->scrollWidth; - } + if (a->scrolling) { + *min = a->scrollWidth; + *nat = a->scrollWidth; + } } static guint translateModifiers(guint state, GdkWindow *window) { - GdkModifierType statetype; + GdkModifierType statetype; - /* GDK doesn't initialize the modifier flags fully; we have to - * explicitly tell it to (thanks to Daniel_S and daniels - * (two different people) in irc.gimp.net/#gtk+) */ - statetype = state; - gdk_keymap_add_virtual_modifiers( - gdk_keymap_get_for_display(gdk_window_get_display(window)), - &statetype); - return statetype; + // GDK doesn't initialize the modifier flags fully; we have to explicitly tell it to (thanks to Daniel_S and daniels (two different people) in irc.gimp.net/#gtk+) + statetype = state; + gdk_keymap_add_virtual_modifiers( + gdk_keymap_get_for_display(gdk_window_get_display(window)), + &statetype); + return statetype; } static uiModifiers toModifiers(guint state) { - uiModifiers m = 0; + uiModifiers m; - if ((state & GDK_CONTROL_MASK) != 0) - m |= uiModifierCtrl; - if ((state & GDK_META_MASK) != 0) - m |= uiModifierAlt; - /* GTK+ itself requires this to be Alt (just read through gtkaccelgroup.c) */ - if ((state & GDK_MOD1_MASK) != 0) - m |= uiModifierAlt; - if ((state & GDK_SHIFT_MASK) != 0) - m |= uiModifierShift; - if ((state & GDK_SUPER_MASK) != 0) - m |= uiModifierSuper; - return m; + m = 0; + if ((state & GDK_CONTROL_MASK) != 0) + m |= uiModifierCtrl; + if ((state & GDK_META_MASK) != 0) + m |= uiModifierAlt; + if ((state & GDK_MOD1_MASK) != 0) // GTK+ itself requires this to be Alt (just read through gtkaccelgroup.c) + m |= uiModifierAlt; + if ((state & GDK_SHIFT_MASK) != 0) + m |= uiModifierShift; + if ((state & GDK_SUPER_MASK) != 0) + m |= uiModifierSuper; + return m; } -/* capture on drag is done automatically on GTK+ */ +// capture on drag is done automatically on GTK+ static void finishMouseEvent(uiArea *a, uiAreaMouseEvent *me, guint mb, gdouble x, gdouble y, guint state, GdkWindow *window) { - /* on GTK+, mouse buttons 4-7 are for scrolling; if we got here, that's a mistake */ + // on GTK+, mouse buttons 4-7 are for scrolling; if we got here, that's a mistake if (mb >= 4 && mb <= 7) return; - /* if the button ID >= 8, continue counting from 4, as in the MouseEvent spec */ + // if the button ID >= 8, continue counting from 4, as in the MouseEvent spec if (me->Down >= 8) me->Down -= 4; if (me->Up >= 8) @@ -219,7 +211,7 @@ static void finishMouseEvent(uiArea *a, uiAreaMouseEvent *me, guint mb, gdouble state = translateModifiers(state, window); me->Modifiers = toModifiers(state); - /* the mb != # checks exclude the Up/Down button from Held */ + // the mb != # checks exclude the Up/Down button from Held me->Held1To64 = 0; if (mb != 1 && (state & GDK_BUTTON1_MASK) != 0) me->Held1To64 |= 1 << 0; @@ -227,19 +219,12 @@ static void finishMouseEvent(uiArea *a, uiAreaMouseEvent *me, guint mb, gdouble me->Held1To64 |= 1 << 1; if (mb != 3 && (state & GDK_BUTTON3_MASK) != 0) me->Held1To64 |= 1 << 2; + // don't check GDK_BUTTON4_MASK or GDK_BUTTON5_MASK because those are for the scrolling buttons mentioned above + // GDK expressly does not support any more buttons in the GdkModifierType; see https://git.gnome.org/browse/gtk+/tree/gdk/x11/gdkdevice-xi2.c#n763 (thanks mclasen in irc.gimp.net/#gtk+) - /* don't check GDK_BUTTON4_MASK or GDK_BUTTON5_MASK because those - * are for the scrolling buttons mentioned above - * - * GDK expressly does not support any more buttons in the - * GdkModifierType; see - * https://git.gnome.org/browse/gtk+/tree/gdk/x11/gdkdevice-xi2.c#n763 - * (thanks mclasen in irc.gimp.net/#gtk+) - */ - - /* these are already in drawing space coordinates - * the size of drawing space has the same value as the widget allocation - * thanks to tristan in irc.gimp.net/#gtk+ */ + // these are already in drawing space coordinates + // the size of drawing space has the same value as the widget allocation + // thanks to tristan in irc.gimp.net/#gtk+ me->X = x; me->Y = y; @@ -250,43 +235,37 @@ static void finishMouseEvent(uiArea *a, uiAreaMouseEvent *me, guint mb, gdouble static gboolean areaWidget_button_press_event(GtkWidget *w, GdkEventButton *e) { + areaWidget *aw = areaWidget(w); + uiArea *a = aw->a; gint maxTime, maxDistance; + GtkSettings *settings; uiAreaMouseEvent me; - areaWidget *aw = areaWidget(w); - uiArea *a = aw->a; - GtkSettings *settings = NULL; - /* clicking doesn't automatically transfer keyboard focus; - * we must do so manually (thanks tristan in irc.gimp.net/#gtk+) */ + // clicking doesn't automatically transfer keyboard focus; we must do so manually (thanks tristan in irc.gimp.net/#gtk+) gtk_widget_grab_focus(w); - /* we handle multiple clicks ourselves here, - * in the same way as we do on Windows */ - - /* ignore GDK's generated double-clicks and beyond */ + // we handle multiple clicks ourselves here, in the same way as we do on Windows if (e->type != GDK_BUTTON_PRESS) + // ignore GDK's generated double-clicks and beyond return GDK_EVENT_PROPAGATE; - settings = gtk_widget_get_settings(w); - g_object_get(settings, "gtk-double-click-time", &maxTime, "gtk-double-click-distance", &maxDistance, NULL); - - /* don't unref settings; it's transfer-none (thanks gregier in irc.gimp.net/#gtk+) - * e->time is guint32 - * e->x and e->y are floating-point; just make them 32-bit integers - * maxTime and maxDistance... are gint, which *should* fit, hopefully... */ + // don't unref settings; it's transfer-none (thanks gregier in irc.gimp.net/#gtk+) + // e->time is guint32 + // e->x and e->y are floating-point; just make them 32-bit integers + // maxTime and maxDistance... are gint, which *should* fit, hopefully... me.Count = clickCounterClick(a->cc, me.Down, e->x, e->y, e->time, maxTime, maxDistance, maxDistance); me.Down = e->button; - me.Up = 0; + me.Up = 0; - /* and set things up for window drags */ + // and set things up for window drags a->dragevent = e; finishMouseEvent(a, &me, e->button, e->x, e->y, e->state, e->window); a->dragevent = NULL; @@ -295,37 +274,32 @@ static gboolean areaWidget_button_press_event(GtkWidget *w, GdkEventButton *e) static gboolean areaWidget_button_release_event(GtkWidget *w, GdkEventButton *e) { - uiAreaMouseEvent me; - areaWidget *aw = areaWidget(w); - uiArea *a = aw->a; + areaWidget *aw = areaWidget(w); + uiArea *a = aw->a; + uiAreaMouseEvent me; - me.Down = 0; - me.Up = e->button; - me.Count = 0; - finishMouseEvent(a, &me, e->button, e->x, e->y, e->state, e->window); - return GDK_EVENT_PROPAGATE; + me.Down = 0; + me.Up = e->button; + me.Count = 0; + finishMouseEvent(a, &me, e->button, e->x, e->y, e->state, e->window); + return GDK_EVENT_PROPAGATE; } static gboolean areaWidget_motion_notify_event(GtkWidget *w, GdkEventMotion *e) { - uiAreaMouseEvent me; areaWidget *aw = areaWidget(w); - uiArea *a = aw->a; + uiArea *a = aw->a; + uiAreaMouseEvent me; - me.Down = 0; - me.Up = 0; - me.Count = 0; + me.Down = 0; + me.Up = 0; + me.Count = 0; finishMouseEvent(a, &me, 0, e->x, e->y, e->state, e->window); return GDK_EVENT_PROPAGATE; } -/* we want switching away from the control to reset the double-click counter, - * like with WM_ACTIVATE on Windows - * - * according to tristan in irc.gimp.net/#gtk+, doing this on both - * enter-notify-event and leave-notify-event is correct (and it seems to be - * true in my own tests; plus the events DO get sent when switching programs - * with the keyboard (just pointing that out)) */ +// we want switching away from the control to reset the double-click counter, like with WM_ACTIVATE on Windows +// according to tristan in irc.gimp.net/#gtk+, doing this on both enter-notify-event and leave-notify-event is correct (and it seems to be true in my own tests; plus the events DO get sent when switching programs with the keyboard (just pointing that out)) static gboolean onCrossing(areaWidget *aw, int left) { uiArea *a = aw->a; @@ -345,15 +319,11 @@ static gboolean areaWidget_leave_notify_event(GtkWidget *w, GdkEventCrossing *e) return onCrossing(areaWidget(w), 1); } -/* note: there is no equivalent to WM_CAPTURECHANGED on GTK+; there literally - * is no way to break a grab like that (at least not on X11 and Wayland) - * - * even if I invoke the task switcher and switch processes, the mouse grab will - * still be held until I let go of all buttons - * therefore, no DragBroken() - * - * we use GDK_KEY_Print as a sentinel because libui will never support the print screen key; that key belongs to the user - */ +// note: there is no equivalent to WM_CAPTURECHANGED on GTK+; there literally is no way to break a grab like that (at least not on X11 and Wayland) +// even if I invoke the task switcher and switch processes, the mouse grab will still be held until I let go of all buttons +// therefore, no DragBroken() + +// we use GDK_KEY_Print as a sentinel because libui will never support the print screen key; that key belongs to the user static const struct { guint keyval; @@ -382,7 +352,7 @@ static const struct { { GDK_KEY_F10, uiExtKeyF10 }, { GDK_KEY_F11, uiExtKeyF11 }, { GDK_KEY_F12, uiExtKeyF12 }, - /* numpad numeric keys and . are handled in events.c */ + // numpad numeric keys and . are handled in events.c { GDK_KEY_KP_Enter, uiExtKeyNEnter }, { GDK_KEY_KP_Add, uiExtKeyNAdd }, { GDK_KEY_KP_Subtract, uiExtKeyNSubtract }, @@ -424,25 +394,23 @@ static int areaKeyEvent(uiArea *a, int up, GdkEventKey *e) ke.Up = up; for (i = 0; extKeys[i].keyval != GDK_KEY_Print; i++) - if (extKeys[i].keyval == e->keyval) - { + if (extKeys[i].keyval == e->keyval) { ke.ExtKey = extKeys[i].extkey; goto keyFound; } for (i = 0; modKeys[i].keyval != GDK_KEY_Print; i++) - if (modKeys[i].keyval == e->keyval) - { - ke.Modifier = modKeys[i].mod; - /* don't include the modifier in ke.Modifiers */ - ke.Modifiers &= ~ke.Modifier; - goto keyFound; - } + if (modKeys[i].keyval == e->keyval) { + ke.Modifier = modKeys[i].mod; + // don't include the modifier in ke.Modifiers + ke.Modifiers &= ~ke.Modifier; + goto keyFound; + } if (fromScancode(e->hardware_keycode - 8, &ke)) goto keyFound; - /* no supported key found; treat as unhandled */ + // no supported key found; treat as unhandled return 0; keyFound: @@ -452,7 +420,7 @@ keyFound: static gboolean areaWidget_key_press_event(GtkWidget *w, GdkEventKey *e) { areaWidget *aw = areaWidget(w); - uiArea *a = aw->a; + uiArea *a = aw->a; if (areaKeyEvent(a, 0, e)) return GDK_EVENT_STOP; @@ -478,16 +446,15 @@ static GParamSpec *pspecArea; static void areaWidget_set_property(GObject *obj, guint prop, const GValue *value, GParamSpec *pspec) { - areaWidget *aw = areaWidget(obj); + areaWidget *aw = areaWidget(obj); - switch (prop) - { - case pArea: - aw->a = (uiArea *) g_value_get_pointer(value); - aw->a->cc = &(aw->cc); - return; - } - G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, prop, pspec); + switch (prop) { + case pArea: + aw->a = (uiArea *) g_value_get_pointer(value); + aw->a->cc = &(aw->cc); + return; + } + G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, prop, pspec); } static void areaWidget_get_property(GObject *obj, guint prop, GValue *value, GParamSpec *pspec) @@ -541,8 +508,8 @@ void uiAreaQueueRedrawAll(uiArea *a) void uiAreaScrollTo(uiArea *a, double x, double y, double width, double height) { - /* TODO - * TODO adjust adjustments and find source for that */ + // TODO + // TODO adjust adjustments and find source for that } void uiAreaBeginUserWindowMove(uiArea *a) @@ -551,23 +518,25 @@ void uiAreaBeginUserWindowMove(uiArea *a) if (a->dragevent == NULL) userbug("cannot call uiAreaBeginUserWindowMove() outside of a Mouse() with Down != 0"); - /* TODO don't we have a libui function for this? did I scrap it? - * TODO widget or areaWidget? */ + // TODO don't we have a libui function for this? did I scrap it? + // TODO widget or areaWidget? toplevel = gtk_widget_get_toplevel(a->widget); - // TODO - if (toplevel == NULL) + if (toplevel == NULL) { + // TODO return; - /* the docs say to do this */ - - /* TODO */ - if (!gtk_widget_is_toplevel(toplevel)) + } + // the docs say to do this + if (!gtk_widget_is_toplevel(toplevel)) { + // TODO return; - /* TODO */ - if (!GTK_IS_WINDOW(toplevel)) + } + if (!GTK_IS_WINDOW(toplevel)) { + // TODO return; + } gtk_window_begin_move_drag(GTK_WINDOW(toplevel), a->dragevent->button, - a->dragevent->x_root, /* TODO are these correct? */ + a->dragevent->x_root, // TODO are these correct? a->dragevent->y_root, a->dragevent->time); } @@ -589,25 +558,26 @@ void uiAreaBeginUserWindowResize(uiArea *a, uiWindowResizeEdge edge) if (a->dragevent == NULL) userbug("cannot call uiAreaBeginUserWindowResize() outside of a Mouse() with Down != 0"); - /* TODO don't we have a libui function for this? did I scrap it? - * TODO widget or areaWidget? */ + // TODO don't we have a libui function for this? did I scrap it? + // TODO widget or areaWidget? toplevel = gtk_widget_get_toplevel(a->widget); - - /* TODO */ - if (toplevel == NULL) + if (toplevel == NULL) { + // TODO return; - /* the docs say to do this */ - - /* TODO */ - if (!gtk_widget_is_toplevel(toplevel)) + } + // the docs say to do this + if (!gtk_widget_is_toplevel(toplevel)) { + // TODO return; - /* TODO */ - if (!GTK_IS_WINDOW(toplevel)) + } + if (!GTK_IS_WINDOW(toplevel)) { + // TODO return; + } gtk_window_begin_resize_drag(GTK_WINDOW(toplevel), edges[edge], a->dragevent->button, - a->dragevent->x_root, /* TODO are these correct? */ + a->dragevent->x_root, // TODO are these correct? a->dragevent->y_root, a->dragevent->time); } @@ -656,8 +626,7 @@ uiArea *uiNewScrollingArea(uiAreaHandler *ah, int width, int height) a->widget = a->swidget; gtk_container_add(a->scontainer, a->areaWidget); - /* and make the area visible; only the scrolled - * window's visibility is controlled by libui */ + // and make the area visible; only the scrolled window's visibility is controlled by libui gtk_widget_show(a->areaWidget); return a; diff --git a/deps/libui/gtk/box.c b/deps/libui/unix/box.c similarity index 76% rename from deps/libui/gtk/box.c rename to deps/libui/unix/box.c index 6c716930e7..23fb7f7c6c 100644 --- a/deps/libui/gtk/box.c +++ b/deps/libui/unix/box.c @@ -1,26 +1,24 @@ // 7 april 2015 #include "uipriv_unix.h" -struct boxChild -{ - uiControl *c; - int stretchy; - gboolean oldhexpand; - GtkAlign oldhalign; - gboolean oldvexpand; - GtkAlign oldvalign; +struct boxChild { + uiControl *c; + int stretchy; + gboolean oldhexpand; + GtkAlign oldhalign; + gboolean oldvexpand; + GtkAlign oldvalign; }; -struct uiBox -{ - uiUnixControl c; - GtkWidget *widget; - GtkContainer *container; - GtkBox *box; - GArray *controls; - int vertical; - int padded; - GtkSizeGroup *stretchygroup; /* ensures all stretchy controls have the same size */ +struct uiBox { + uiUnixControl c; + GtkWidget *widget; + GtkContainer *container; + GtkBox *box; + GArray *controls; + int vertical; + int padded; + GtkSizeGroup *stretchygroup; // ensures all stretchy controls have the same size }; uiUnixControlAllDefaultsExceptDestroy(uiBox) @@ -33,19 +31,18 @@ static void uiBoxDestroy(uiControl *c) struct boxChild *bc; guint i; - /* kill the size group */ + // kill the size group g_object_unref(b->stretchygroup); - /* free all controls */ - for (i = 0; i < b->controls->len; i++) - { - bc = ctrl(b, i); - uiControlSetParent(bc->c, NULL); - /* and make sure the widget itself stays alive */ - uiUnixControlSetContainer(uiUnixControl(bc->c), b->container, TRUE); - uiControlDestroy(bc->c); - } + // free all controls + for (i = 0; i < b->controls->len; i++) { + bc = ctrl(b, i); + uiControlSetParent(bc->c, NULL); + // and make sure the widget itself stays alive + uiUnixControlSetContainer(uiUnixControl(bc->c), b->container, TRUE); + uiControlDestroy(bc->c); + } g_array_free(b->controls, TRUE); - /* and then ourselves */ + // and then ourselves g_object_unref(b->widget); uiFreeControl(uiControl(b)); } @@ -53,7 +50,7 @@ static void uiBoxDestroy(uiControl *c) void uiBoxAppend(uiBox *b, uiControl *c, int stretchy) { struct boxChild bc; - GtkWidget *widget = NULL; + GtkWidget *widget; bc.c = c; bc.stretchy = stretchy; @@ -77,7 +74,7 @@ void uiBoxAppend(uiBox *b, uiControl *c, int stretchy) gtk_widget_set_vexpand(widget, FALSE); else gtk_widget_set_hexpand(widget, FALSE); - /* and make them fill the opposite direction */ + // and make them fill the opposite direction if (b->vertical) { gtk_widget_set_hexpand(widget, TRUE); gtk_widget_set_halign(widget, GTK_ALIGN_FILL); @@ -93,8 +90,11 @@ void uiBoxAppend(uiBox *b, uiControl *c, int stretchy) void uiBoxDelete(uiBox *b, int index) { - struct boxChild *bc = ctrl(b, index); - GtkWidget *widget = GTK_WIDGET(uiControlHandle(bc->c)); + struct boxChild *bc; + GtkWidget *widget; + + bc = ctrl(b, index); + widget = GTK_WIDGET(uiControlHandle(bc->c)); uiControlSetParent(bc->c, NULL); uiUnixControlSetContainer(uiUnixControl(bc->c), b->container, TRUE); diff --git a/deps/libui/gtk/button.c b/deps/libui/unix/button.c similarity index 94% rename from deps/libui/gtk/button.c rename to deps/libui/unix/button.c index 44266ee893..00a87f491a 100644 --- a/deps/libui/gtk/button.c +++ b/deps/libui/unix/button.c @@ -1,8 +1,7 @@ // 10 june 2015 #include "uipriv_unix.h" -struct uiButton -{ +struct uiButton { uiUnixControl c; GtkWidget *widget; GtkButton *button; @@ -21,7 +20,7 @@ static void onClicked(GtkButton *button, gpointer data) static void defaultOnClicked(uiButton *b, void *data) { - /* do nothing */ + // do nothing } char *uiButtonText(uiButton *b) @@ -36,7 +35,7 @@ void uiButtonSetText(uiButton *b, const char *text) void uiButtonOnClicked(uiButton *b, void (*f)(uiButton *, void *), void *data) { - b->onClicked = f; + b->onClicked = f; b->onClickedData = data; } diff --git a/deps/libui/gtk/cellrendererbutton.c b/deps/libui/unix/cellrendererbutton.c similarity index 100% rename from deps/libui/gtk/cellrendererbutton.c rename to deps/libui/unix/cellrendererbutton.c diff --git a/deps/libui/gtk/checkbox.c b/deps/libui/unix/checkbox.c similarity index 100% rename from deps/libui/gtk/checkbox.c rename to deps/libui/unix/checkbox.c diff --git a/deps/libui/gtk/child.c b/deps/libui/unix/child.c similarity index 94% rename from deps/libui/gtk/child.c rename to deps/libui/unix/child.c index 636495b97b..b4a0967740 100644 --- a/deps/libui/gtk/child.c +++ b/deps/libui/unix/child.c @@ -28,7 +28,7 @@ struct child { struct child *newChild(uiControl *child, uiControl *parent, GtkContainer *parentContainer) { - struct child *c = NULL; + struct child *c; if (child == NULL) return NULL; @@ -51,8 +51,8 @@ struct child *newChild(uiControl *child, uiControl *parent, GtkContainer *parent struct child *newChildWithBox(uiControl *child, uiControl *parent, GtkContainer *parentContainer, int margined) { - struct child *c = NULL; - GtkWidget *box = NULL; + struct child *c; + GtkWidget *box; if (child == NULL) return NULL; @@ -87,11 +87,11 @@ void childRemove(struct child *c) void childDestroy(struct child *c) { - uiControl *child = NULL; + uiControl *child; - child = c->c; - childRemove(c); - uiControlDestroy(child); + child = c->c; + childRemove(c); + uiControlDestroy(child); } GtkWidget *childWidget(struct child *c) diff --git a/deps/libui/gtk/colorbutton.c b/deps/libui/unix/colorbutton.c similarity index 100% rename from deps/libui/gtk/colorbutton.c rename to deps/libui/unix/colorbutton.c diff --git a/deps/libui/gtk/combobox.c b/deps/libui/unix/combobox.c similarity index 100% rename from deps/libui/gtk/combobox.c rename to deps/libui/unix/combobox.c diff --git a/deps/libui/gtk/control.c b/deps/libui/unix/control.c similarity index 100% rename from deps/libui/gtk/control.c rename to deps/libui/unix/control.c diff --git a/deps/libui/gtk/datetimepicker.c b/deps/libui/unix/datetimepicker.c similarity index 81% rename from deps/libui/gtk/datetimepicker.c rename to deps/libui/unix/datetimepicker.c index 315150a3d9..19689a2205 100644 --- a/deps/libui/gtk/datetimepicker.c +++ b/deps/libui/unix/datetimepicker.c @@ -14,31 +14,30 @@ typedef struct dateTimePickerWidget dateTimePickerWidget; typedef struct dateTimePickerWidgetClass dateTimePickerWidgetClass; -struct dateTimePickerWidget -{ - GtkToggleButton parent_instance; +struct dateTimePickerWidget { + GtkToggleButton parent_instance; - gulong toggledSignal; + gulong toggledSignal; - gboolean hasTime; - gboolean hasDate; + gboolean hasTime; + gboolean hasDate; - GtkWidget *window; - GtkWidget *box; - GtkWidget *calendar; - GtkWidget *timebox; - GtkWidget *hours; - GtkWidget *minutes; - GtkWidget *seconds; - GtkWidget *ampm; + GtkWidget *window; + GtkWidget *box; + GtkWidget *calendar; + GtkWidget *timebox; + GtkWidget *hours; + GtkWidget *minutes; + GtkWidget *seconds; + GtkWidget *ampm; - gulong hoursBlock; - gulong minutesBlock; - gulong secondsBlock; - gulong ampmBlock; + gulong hoursBlock; + gulong minutesBlock; + gulong secondsBlock; + gulong ampmBlock; - GdkDevice *keyboard; - GdkDevice *mouse; + GdkDevice *keyboard; + GdkDevice *mouse; }; struct dateTimePickerWidgetClass { @@ -49,7 +48,9 @@ G_DEFINE_TYPE(dateTimePickerWidget, dateTimePickerWidget, GTK_TYPE_TOGGLE_BUTTON static int realSpinValue(GtkSpinButton *spinButton) { - GtkAdjustment *adj = gtk_spin_button_get_adjustment(spinButton); + GtkAdjustment *adj; + + adj = gtk_spin_button_get_adjustment(spinButton); return (int) gtk_adjustment_get_value(adj); } @@ -69,14 +70,11 @@ static GDateTime *selected(dateTimePickerWidget *d) guint year = 1970, month = 1, day = 1; guint hour = 0, minute = 0, second = 0; - if (d->hasDate) - { + if (d->hasDate) { gtk_calendar_get_date(GTK_CALENDAR(d->calendar), &year, &month, &day); - month++; /* GtkCalendar/GDateTime differences */ + month++; // GtkCalendar/GDateTime differences } - - if (d->hasTime) - { + if (d->hasTime) { hour = realSpinValue(GTK_SPIN_BUTTON(d->hours)); if (realSpinValue(GTK_SPIN_BUTTON(d->ampm)) != 0) hour += 12; @@ -88,22 +86,21 @@ static GDateTime *selected(dateTimePickerWidget *d) static void setLabel(dateTimePickerWidget *d) { - char *fmt = NULL; - char *msg = NULL; - GDateTime *dt = selected(d); - gboolean free = FALSE; + GDateTime *dt; + char *fmt; + char *msg; + gboolean free; - if (d->hasDate && d->hasTime) - { - /* don't use D_T_FMT; that's too verbose */ - fmt = g_strdup_printf("%s %s", nl_langinfo(D_FMT), nl_langinfo(T_FMT)); + dt = selected(d); + free = FALSE; + if (d->hasDate && d->hasTime) { + // don't use D_T_FMT; that's too verbose + fmt = g_strdup_printf("%s %s", nl_langinfo(D_FMT), nl_langinfo(T_FMT)); free = TRUE; - } - else if (d->hasDate) - fmt = nl_langinfo(D_FMT); + } else if (d->hasDate) + fmt = nl_langinfo(D_FMT); else fmt = nl_langinfo(T_FMT); - msg = g_date_time_format(dt, fmt); gtk_button_set_label(GTK_BUTTON(d), msg); g_free(msg); @@ -147,31 +144,32 @@ static void hidePopup(dateTimePickerWidget *d) // this consolidates a good chunk of what GtkComboBox does static gboolean startGrab(dateTimePickerWidget *d) { + GdkDevice *dev; guint32 time; - GdkWindow *window = NULL; - GdkDevice *keyboard = NULL; - GdkDevice *mouse = NULL; - GdkDevice *dev = gtk_get_current_event_device(); + GdkWindow *window; + GdkDevice *keyboard, *mouse; - if (dev == NULL) - { + dev = gtk_get_current_event_device(); + if (dev == NULL) { // this is what GtkComboBox does // since no device was set, just use the first available "master device" - GdkDisplay *disp = gtk_widget_get_display(GTK_WIDGET(d)); - GdkDeviceManager *dm = gdk_display_get_device_manager(disp); - GList *list = gdk_device_manager_list_devices(dm, GDK_DEVICE_TYPE_MASTER); + GdkDisplay *disp; + GdkDeviceManager *dm; + GList *list; + + disp = gtk_widget_get_display(GTK_WIDGET(d)); + dm = gdk_display_get_device_manager(disp); + list = gdk_device_manager_list_devices(dm, GDK_DEVICE_TYPE_MASTER); dev = (GdkDevice *) (list->data); g_list_free(list); } - time = gtk_get_current_event_time(); + time = gtk_get_current_event_time(); keyboard = dev; - mouse = gdk_device_get_associated_device(dev); - - if (gdk_device_get_source(dev) != GDK_SOURCE_KEYBOARD) - { - dev = mouse; - mouse = keyboard; + mouse = gdk_device_get_associated_device(dev); + if (gdk_device_get_source(dev) != GDK_SOURCE_KEYBOARD) { + dev = mouse; + mouse = keyboard; keyboard = dev; } @@ -198,7 +196,7 @@ static gboolean startGrab(dateTimePickerWidget *d) return TRUE; } -/* based on gtk_combo_box_list_position() in the GTK+ source code */ +// based on gtk_combo_box_list_position() in the GTK+ source code static void allocationToScreen(dateTimePickerWidget *d, gint *x, gint *y) { GdkWindow *window; @@ -279,17 +277,15 @@ static gboolean grabBroken(GtkWidget *w, GdkEventGrabBroken *e, gpointer data) static gboolean buttonReleased(GtkWidget *w, GdkEventButton *e, gpointer data) { + dateTimePickerWidget *d = dateTimePickerWidget(data); int winx, winy; GtkAllocation wina; gboolean in; - dateTimePickerWidget *d = dateTimePickerWidget(data); gtk_widget_get_allocation(d->window, &wina); winx = 0; winy = 0; - - if (!gtk_widget_get_has_window(d->window)) - { + if (!gtk_widget_get_has_window(d->window)) { winx = wina.x; winy = wina.y; } @@ -311,9 +307,11 @@ static gboolean buttonReleased(GtkWidget *w, GdkEventButton *e, gpointer data) static gint hoursSpinboxInput(GtkSpinButton *sb, gpointer ptr, gpointer data) { double *out = (double *) ptr; - const gchar *text = gtk_entry_get_text(GTK_ENTRY(sb)); - int value = (int) g_strtod(text, NULL); + const gchar *text; + int value; + text = gtk_entry_get_text(GTK_ENTRY(sb)); + value = (int) g_strtod(text, NULL); if (value < 0 || value > 12) return GTK_INPUT_ERROR; if (value == 12) // 12 to the user is 0 internally @@ -324,9 +322,10 @@ static gint hoursSpinboxInput(GtkSpinButton *sb, gpointer ptr, gpointer data) static gboolean hoursSpinboxOutput(GtkSpinButton *sb, gpointer data) { - gchar *text = NULL; - int value = realSpinValue(sb); + gchar *text; + int value; + value = realSpinValue(sb); if (value == 0) // 0 internally is 12 to the user value = 12; text = g_strdup_printf("%d", value); @@ -337,9 +336,11 @@ static gboolean hoursSpinboxOutput(GtkSpinButton *sb, gpointer data) static gboolean zeroPadSpinbox(GtkSpinButton *sb, gpointer data) { - int value = realSpinValue(sb); - gchar *text = g_strdup_printf("%02d", value); + gchar *text; + int value; + value = realSpinValue(sb); + text = g_strdup_printf("%02d", value); gtk_entry_set_text(GTK_ENTRY(sb), text); g_free(text); return TRUE; @@ -348,20 +349,19 @@ static gboolean zeroPadSpinbox(GtkSpinButton *sb, gpointer data) // this is really hacky but we can't use GtkCombobox here :( static gint ampmSpinboxInput(GtkSpinButton *sb, gpointer ptr, gpointer data) { - double *out = (double *) ptr; - const gchar *text = gtk_entry_get_text(GTK_ENTRY(sb)); - // LONGTERM don't use ASCII here for case insensitivity - char firstAM = g_ascii_tolower(nl_langinfo(AM_STR)[0]); - char firstPM = g_ascii_tolower(nl_langinfo(PM_STR)[0]); + double *out = (double *) ptr; + const gchar *text; + char firstAM, firstPM; + text = gtk_entry_get_text(GTK_ENTRY(sb)); + // LONGTERM don't use ASCII here for case insensitivity + firstAM = g_ascii_tolower(nl_langinfo(AM_STR)[0]); + firstPM = g_ascii_tolower(nl_langinfo(PM_STR)[0]); for (; *text != '\0'; text++) - if (g_ascii_tolower(*text) == firstAM) - { + if (g_ascii_tolower(*text) == firstAM) { *out = 0; return TRUE; - } - else if (g_ascii_tolower(*text) == firstPM) - { + } else if (g_ascii_tolower(*text) == firstPM) { *out = 1; return TRUE; } @@ -387,21 +387,20 @@ static void spinboxChanged(GtkSpinButton *sb, gpointer data) dateTimeChanged(d); } -static GtkWidget *newSpinbox(dateTimePickerWidget *d, int min, int max, - gint (*input)(GtkSpinButton *, gpointer, gpointer), - gboolean (*output)(GtkSpinButton *, gpointer), gulong *block) +static GtkWidget *newSpinbox(dateTimePickerWidget *d, int min, int max, gint (*input)(GtkSpinButton *, gpointer, gpointer), gboolean (*output)(GtkSpinButton *, gpointer), gulong *block) { - GtkWidget *sb = gtk_spin_button_new_with_range(min, max, 1); + GtkWidget *sb; - gtk_spin_button_set_digits(GTK_SPIN_BUTTON(sb), 0); - gtk_spin_button_set_wrap(GTK_SPIN_BUTTON(sb), TRUE); - gtk_orientable_set_orientation(GTK_ORIENTABLE(sb), GTK_ORIENTATION_VERTICAL); - *block = g_signal_connect(sb, "value-changed", G_CALLBACK(spinboxChanged), d); - if (input != NULL) - g_signal_connect(sb, "input", G_CALLBACK(input), NULL); - if (output != NULL) - g_signal_connect(sb, "output", G_CALLBACK(output), NULL); - return sb; + sb = gtk_spin_button_new_with_range(min, max, 1); + gtk_spin_button_set_digits(GTK_SPIN_BUTTON(sb), 0); + gtk_spin_button_set_wrap(GTK_SPIN_BUTTON(sb), TRUE); + gtk_orientable_set_orientation(GTK_ORIENTABLE(sb), GTK_ORIENTATION_VERTICAL); + *block = g_signal_connect(sb, "value-changed", G_CALLBACK(spinboxChanged), d); + if (input != NULL) + g_signal_connect(sb, "input", G_CALLBACK(input), NULL); + if (output != NULL) + g_signal_connect(sb, "output", G_CALLBACK(output), NULL); + return sb; } static void dateChanged(GtkCalendar *c, gpointer data) @@ -537,14 +536,18 @@ static void dateTimePickerWidget_class_init(dateTimePickerWidgetClass *class) static GtkWidget *newDTP(void) { - GtkWidget *w = GTK_WIDGET(g_object_new(dateTimePickerWidgetType, "label", "", NULL)); + GtkWidget *w; + + w = GTK_WIDGET(g_object_new(dateTimePickerWidgetType, "label", "", NULL)); setLabel(dateTimePickerWidget(w)); return w; } static GtkWidget *newDP(void) { - GtkWidget *w = GTK_WIDGET(g_object_new(dateTimePickerWidgetType, "label", "", NULL)); + GtkWidget *w; + + w = GTK_WIDGET(g_object_new(dateTimePickerWidgetType, "label", "", NULL)); setDateOnly(dateTimePickerWidget(w)); setLabel(dateTimePickerWidget(w)); return w; @@ -552,17 +555,18 @@ static GtkWidget *newDP(void) static GtkWidget *newTP(void) { - GtkWidget *w = GTK_WIDGET(g_object_new(dateTimePickerWidgetType, "label", "", NULL)); + GtkWidget *w; + + w = GTK_WIDGET(g_object_new(dateTimePickerWidgetType, "label", "", NULL)); setTimeOnly(dateTimePickerWidget(w)); setLabel(dateTimePickerWidget(w)); return w; } -struct uiDateTimePicker -{ - uiUnixControl c; - GtkWidget *widget; - dateTimePickerWidget *d; +struct uiDateTimePicker { + uiUnixControl c; + GtkWidget *widget; + dateTimePickerWidget *d; }; uiUnixControlAllDefaults(uiDateTimePicker) @@ -574,7 +578,7 @@ uiDateTimePicker *finishNewDateTimePicker(GtkWidget *(*fn)(void)) uiUnixNewControl(uiDateTimePicker, d); d->widget = (*fn)(); - d->d = dateTimePickerWidget(d->widget); + d->d = dateTimePickerWidget(d->widget); return d; } diff --git a/deps/libui/gtk/debug.c b/deps/libui/unix/debug.c similarity index 100% rename from deps/libui/gtk/debug.c rename to deps/libui/unix/debug.c diff --git a/deps/libui/gtk/draw.c b/deps/libui/unix/draw.c similarity index 100% rename from deps/libui/gtk/draw.c rename to deps/libui/unix/draw.c diff --git a/deps/libui/gtk/draw.h b/deps/libui/unix/draw.h similarity index 100% rename from deps/libui/gtk/draw.h rename to deps/libui/unix/draw.h diff --git a/deps/libui/gtk/drawmatrix.c b/deps/libui/unix/drawmatrix.c similarity index 100% rename from deps/libui/gtk/drawmatrix.c rename to deps/libui/unix/drawmatrix.c diff --git a/deps/libui/gtk/drawpath.c b/deps/libui/unix/drawpath.c similarity index 100% rename from deps/libui/gtk/drawpath.c rename to deps/libui/unix/drawpath.c diff --git a/deps/libui/gtk/drawtext.c b/deps/libui/unix/drawtext.c similarity index 100% rename from deps/libui/gtk/drawtext.c rename to deps/libui/unix/drawtext.c diff --git a/deps/libui/gtk/editablecombo.c b/deps/libui/unix/editablecombo.c similarity index 100% rename from deps/libui/gtk/editablecombo.c rename to deps/libui/unix/editablecombo.c diff --git a/deps/libui/gtk/entry.c b/deps/libui/unix/entry.c similarity index 100% rename from deps/libui/gtk/entry.c rename to deps/libui/unix/entry.c diff --git a/deps/libui/gtk/fontbutton.c b/deps/libui/unix/fontbutton.c similarity index 100% rename from deps/libui/gtk/fontbutton.c rename to deps/libui/unix/fontbutton.c diff --git a/deps/libui/gtk/form.c b/deps/libui/unix/form.c similarity index 77% rename from deps/libui/gtk/form.c rename to deps/libui/unix/form.c index c2e479526f..54422b3d40 100644 --- a/deps/libui/gtk/form.c +++ b/deps/libui/unix/form.c @@ -1,27 +1,25 @@ // 8 june 2016 #include "uipriv_unix.h" -struct formChild -{ - uiControl *c; - int stretchy; - GtkWidget *label; - gboolean oldhexpand; - GtkAlign oldhalign; - gboolean oldvexpand; - GtkAlign oldvalign; - GBinding *labelBinding; +struct formChild { + uiControl *c; + int stretchy; + GtkWidget *label; + gboolean oldhexpand; + GtkAlign oldhalign; + gboolean oldvexpand; + GtkAlign oldvalign; + GBinding *labelBinding; }; -struct uiForm -{ - uiUnixControl c; - GtkWidget *widget; - GtkContainer *container; - GtkGrid *grid; - GArray *children; - int padded; - GtkSizeGroup *stretchygroup; /* ensures all stretchy controls have the same size */ +struct uiForm { + uiUnixControl c; + GtkWidget *widget; + GtkContainer *container; + GtkGrid *grid; + GArray *children; + int padded; + GtkSizeGroup *stretchygroup; // ensures all stretchy controls have the same size }; uiUnixControlAllDefaultsExceptDestroy(uiForm) @@ -34,19 +32,18 @@ static void uiFormDestroy(uiControl *c) struct formChild *fc; guint i; - /* kill the size group */ + // kill the size group g_object_unref(f->stretchygroup); - /* free all controls */ - for (i = 0; i < f->children->len; i++) - { - fc = ctrl(f, i); - uiControlSetParent(fc->c, NULL); - uiUnixControlSetContainer(uiUnixControl(fc->c), f->container, TRUE); - uiControlDestroy(fc->c); - gtk_widget_destroy(fc->label); - } + // free all controls + for (i = 0; i < f->children->len; i++) { + fc = ctrl(f, i); + uiControlSetParent(fc->c, NULL); + uiUnixControlSetContainer(uiUnixControl(fc->c), f->container, TRUE); + uiControlDestroy(fc->c); + gtk_widget_destroy(fc->label); + } g_array_free(f->children, TRUE); - /* and then ourselves */ + // and then ourselves g_object_unref(f->widget); uiFreeControl(uiControl(f)); } @@ -71,7 +68,7 @@ void uiFormAppend(uiForm *f, const char *label, uiControl *c, int stretchy) gtk_size_group_add_widget(f->stretchygroup, widget); } else gtk_widget_set_vexpand(widget, FALSE); - /* and make them fill horizontally */ + // and make them fill horizontally gtk_widget_set_hexpand(widget, TRUE); gtk_widget_set_halign(widget, GTK_ALIGN_FILL); @@ -88,7 +85,7 @@ void uiFormAppend(uiForm *f, const char *label, uiControl *c, int stretchy) gtk_grid_attach(f->grid, fc.label, 0, row, 1, 1); - /* and make them share visibility so if the control is hidden, so is its label */ + // and make them share visibility so if the control is hidden, so is its label fc.labelBinding = g_object_bind_property(GTK_WIDGET(uiControlHandle(fc.c)), "visible", fc.label, "visible", G_BINDING_SYNC_CREATE); @@ -97,7 +94,7 @@ void uiFormAppend(uiForm *f, const char *label, uiControl *c, int stretchy) uiUnixControlSetContainer(uiUnixControl(fc.c), f->container, FALSE); g_array_append_val(f->children, fc); - /* move the widget to the correct place */ + // move the widget to the correct place gtk_container_child_set(f->container, widget, "left-attach", 1, "top-attach", row, diff --git a/deps/libui/gtk/future.c b/deps/libui/unix/future.c similarity index 100% rename from deps/libui/gtk/future.c rename to deps/libui/unix/future.c diff --git a/deps/libui/gtk/graphemes.c b/deps/libui/unix/graphemes.c similarity index 100% rename from deps/libui/gtk/graphemes.c rename to deps/libui/unix/graphemes.c diff --git a/deps/libui/gtk/grid.c b/deps/libui/unix/grid.c similarity index 100% rename from deps/libui/gtk/grid.c rename to deps/libui/unix/grid.c diff --git a/deps/libui/gtk/group.c b/deps/libui/unix/group.c similarity index 100% rename from deps/libui/gtk/group.c rename to deps/libui/unix/group.c diff --git a/deps/libui/gtk/image.c b/deps/libui/unix/image.c similarity index 88% rename from deps/libui/gtk/image.c rename to deps/libui/unix/image.c index 742128f4ff..a79e550f93 100644 --- a/deps/libui/gtk/image.c +++ b/deps/libui/unix/image.c @@ -52,10 +52,8 @@ void uiImageAppend(uiImage *i, void *pixels, int pixelWidth, int pixelHeight, in cs = cairo_image_surface_create_for_data(buf, CAIRO_FORMAT_ARGB32, pixelWidth, pixelHeight, cstride); - - /* TODO */ - if (cairo_surface_status(cs) != CAIRO_STATUS_SUCCESS) { } - + if (cairo_surface_status(cs) != CAIRO_STATUS_SUCCESS) + /* TODO */; cairo_surface_flush(cs); g_ptr_array_add(i->images, cs); } @@ -69,7 +67,7 @@ struct matcher { gboolean foundLarger; }; -/* TODO is this the right algorithm? */ +// TODO is this the right algorithm? static void match(gpointer surface, gpointer data) { cairo_surface_t *cs = (cairo_surface_t *) surface; @@ -83,11 +81,11 @@ static void match(gpointer surface, gpointer data) goto writeMatch; if (x < m->targetX && y < m->targetY) - if (m->foundLarger) /* always prefer larger ones */ + if (m->foundLarger) + // always prefer larger ones return; - - /* we set foundLarger below */ if (x >= m->targetX && y >= m->targetY && !m->foundLarger) + // we set foundLarger below goto writeMatch; x2 = abs(m->targetX - x); @@ -95,11 +93,11 @@ static void match(gpointer surface, gpointer data) if (x2 < m->distX && y2 < m->distY) goto writeMatch; - /* TODO weight one dimension? threshhold? */ + // TODO weight one dimension? threshhold? return; writeMatch: - /* must set this here too; otherwise the first image will never have ths set */ + // must set this here too; otherwise the first image will never have ths set if (x >= m->targetX && y >= m->targetY && !m->foundLarger) m->foundLarger = TRUE; m->best = cs; diff --git a/deps/libui/gtk/label.c b/deps/libui/unix/label.c similarity index 100% rename from deps/libui/gtk/label.c rename to deps/libui/unix/label.c diff --git a/deps/libui/gtk/main.c b/deps/libui/unix/main.c similarity index 66% rename from deps/libui/gtk/main.c rename to deps/libui/unix/main.c index 199c9184ca..2998bf3194 100644 --- a/deps/libui/gtk/main.c +++ b/deps/libui/unix/main.c @@ -6,15 +6,14 @@ uiInitOptions options; const char *uiInit(uiInitOptions *o) { GError *err = NULL; + const char *msg; - options = *o; - - if (gtk_init_with_args(NULL, NULL, NULL, NULL, NULL, &err) == FALSE) - { - const char *msg = g_strdup(err->message); - g_error_free(err); - return msg; - } + options = *o; + if (gtk_init_with_args(NULL, NULL, NULL, NULL, NULL, &err) == FALSE) { + msg = g_strdup(err->message); + g_error_free(err); + return msg; + } initAlloc(); loadFutures(); return NULL; @@ -41,9 +40,8 @@ void uiMain(void) static gboolean stepsQuit = FALSE; -/* the only difference is we ignore the return value from gtk_main_iteration_do(), - * since it will always be TRUE if gtk_main() was never called - * gtk_main_iteration_do() will still run the main loop regardless */ +// the only difference is we ignore the return value from gtk_main_iteration_do(), since it will always be TRUE if gtk_main() was never called +// gtk_main_iteration_do() will still run the main loop regardless static gboolean stepsIteration(gboolean block) { gtk_main_iteration_do(block); @@ -57,7 +55,9 @@ void uiMainSteps(void) int uiMainStep(int wait) { - gboolean block = FALSE; + gboolean block; + + block = FALSE; if (wait) block = TRUE; return (*iteration)(block) == FALSE; @@ -70,8 +70,7 @@ static gboolean quit(gpointer data) { if (iteration == stepsIteration) stepsQuit = TRUE; - /* TODO run a gtk_main() here just to do the cleanup steps of - * syncing the clipboard and other stuff gtk_main() does before it returns */ + // TODO run a gtk_main() here just to do the cleanup steps of syncing the clipboard and other stuff gtk_main() does before it returns else gtk_main_quit(); return FALSE; @@ -98,12 +97,12 @@ static gboolean doqueued(gpointer data) void uiQueueMain(void (*f)(void *data), void *data) { - struct queued *q = g_new0(struct queued, 1); + struct queued *q; - /* we have to use g_new0()/g_free() because uiAlloc() - * is only safe to call on the main thread - * for some reason it didn't affect me, but it did affect krakjoe */ - q->f = f; + // we have to use g_new0()/g_free() because uiAlloc() is only safe to call on the main thread + // for some reason it didn't affect me, but it did affect krakjoe + q = g_new0(struct queued, 1); + q->f = f; q->data = data; gdk_threads_add_idle(doqueued, q); } diff --git a/deps/libui/gtk/menu.c b/deps/libui/unix/menu.c similarity index 86% rename from deps/libui/gtk/menu.c rename to deps/libui/unix/menu.c index 6f6906a056..5ccb4a51a3 100644 --- a/deps/libui/gtk/menu.c +++ b/deps/libui/unix/menu.c @@ -121,8 +121,10 @@ int uiMenuItemChecked(uiMenuItem *item) void uiMenuItemSetChecked(uiMenuItem *item, int checked) { - /* use explicit values */ - gboolean c = FALSE; + gboolean c; + + // use explicit values + c = FALSE; if (checked) c = TRUE; setChecked(item, c); @@ -130,55 +132,55 @@ void uiMenuItemSetChecked(uiMenuItem *item, int checked) static uiMenuItem *newItem(uiMenu *m, int type, const char *name) { - uiMenuItem *item; + uiMenuItem *item; - if (menusFinalized) - userbug("You cannot create a new menu item after menus have been finalized."); + if (menusFinalized) + userbug("You cannot create a new menu item after menus have been finalized."); - item = uiNew(uiMenuItem); + item = uiNew(uiMenuItem); - g_array_append_val(m->items, item); + g_array_append_val(m->items, item); - item->type = type; - switch (item->type) { - case typeQuit: - item->name = g_strdup("Quit"); - break; - case typePreferences: - item->name = g_strdup("Preferences..."); - break; - case typeAbout: - item->name = g_strdup("About"); - break; - case typeSeparator: - break; - default: - item->name = g_strdup(name); - break; - } + item->type = type; + switch (item->type) { + case typeQuit: + item->name = g_strdup("Quit"); + break; + case typePreferences: + item->name = g_strdup("Preferences..."); + break; + case typeAbout: + item->name = g_strdup("About"); + break; + case typeSeparator: + break; + default: + item->name = g_strdup(name); + break; + } - if (item->type == typeQuit) { - // can't call uiMenuItemOnClicked() here - item->onClicked = onQuitClicked; - item->onClickedData = NULL; - } else - uiMenuItemOnClicked(item, defaultOnClicked, NULL); + if (item->type == typeQuit) { + // can't call uiMenuItemOnClicked() here + item->onClicked = onQuitClicked; + item->onClickedData = NULL; + } else + uiMenuItemOnClicked(item, defaultOnClicked, NULL); - switch (item->type) { - case typeCheckbox: - item->gtype = GTK_TYPE_CHECK_MENU_ITEM; - break; - case typeSeparator: - item->gtype = GTK_TYPE_SEPARATOR_MENU_ITEM; - break; - default: - item->gtype = GTK_TYPE_MENU_ITEM; - break; - } + switch (item->type) { + case typeCheckbox: + item->gtype = GTK_TYPE_CHECK_MENU_ITEM; + break; + case typeSeparator: + item->gtype = GTK_TYPE_SEPARATOR_MENU_ITEM; + break; + default: + item->gtype = GTK_TYPE_MENU_ITEM; + break; + } - item->windows = g_hash_table_new(g_direct_hash, g_direct_equal); + item->windows = g_hash_table_new(g_direct_hash, g_direct_equal); - return item; + return item; } uiMenuItem *uiMenuAppendItem(uiMenu *m, const char *name) diff --git a/deps/libui/gtk/multilineentry.c b/deps/libui/unix/multilineentry.c similarity index 100% rename from deps/libui/gtk/multilineentry.c rename to deps/libui/unix/multilineentry.c diff --git a/deps/libui/gtk/progressbar.c b/deps/libui/unix/progressbar.c similarity index 100% rename from deps/libui/gtk/progressbar.c rename to deps/libui/unix/progressbar.c diff --git a/deps/libui/gtk/radiobuttons.c b/deps/libui/unix/radiobuttons.c similarity index 100% rename from deps/libui/gtk/radiobuttons.c rename to deps/libui/unix/radiobuttons.c diff --git a/deps/libui/gtk/separator.c b/deps/libui/unix/separator.c similarity index 100% rename from deps/libui/gtk/separator.c rename to deps/libui/unix/separator.c diff --git a/deps/libui/gtk/slider.c b/deps/libui/unix/slider.c similarity index 100% rename from deps/libui/gtk/slider.c rename to deps/libui/unix/slider.c diff --git a/deps/libui/gtk/spinbox.c b/deps/libui/unix/spinbox.c similarity index 77% rename from deps/libui/gtk/spinbox.c rename to deps/libui/unix/spinbox.c index 8ca01f774a..90a5d3c1db 100644 --- a/deps/libui/gtk/spinbox.c +++ b/deps/libui/unix/spinbox.c @@ -32,10 +32,9 @@ int uiSpinboxValue(uiSpinbox *s) void uiSpinboxSetValue(uiSpinbox *s, int value) { - /* we need to inhibit sending of ::value-changed - * because this WILL send a ::value-changed otherwise */ + // we need to inhibit sending of ::value-changed because this WILL send a ::value-changed otherwise g_signal_handler_block(s->spinButton, s->onChangedSignal); - /* this clamps for us */ + // this clamps for us gtk_spin_button_set_value(s->spinButton, (gdouble) value); g_signal_handler_unblock(s->spinButton, s->onChangedSignal); } @@ -48,23 +47,22 @@ void uiSpinboxOnChanged(uiSpinbox *s, void (*f)(uiSpinbox *, void *), void *data uiSpinbox *uiNewSpinbox(int min, int max) { + uiSpinbox *s; int temp; - uiSpinbox *s = NULL; - if (min >= max) - { - temp = min; - min = max; - max = temp; - } + if (min >= max) { + temp = min; + min = max; + max = temp; + } uiUnixNewControl(uiSpinbox, s); - s->widget = gtk_spin_button_new_with_range(min, max, 1); - s->entry = GTK_ENTRY(s->widget); + s->widget = gtk_spin_button_new_with_range(min, max, 1); + s->entry = GTK_ENTRY(s->widget); s->spinButton = GTK_SPIN_BUTTON(s->widget); - /* ensure integers, just to be safe */ + // ensure integers, just to be safe gtk_spin_button_set_digits(s->spinButton, 0); s->onChangedSignal = g_signal_connect(s->spinButton, "value-changed", G_CALLBACK(onChanged), s); diff --git a/deps/libui/gtk/stddialogs.c b/deps/libui/unix/stddialogs.c similarity index 100% rename from deps/libui/gtk/stddialogs.c rename to deps/libui/unix/stddialogs.c diff --git a/deps/libui/gtk/tab.c b/deps/libui/unix/tab.c similarity index 67% rename from deps/libui/gtk/tab.c rename to deps/libui/unix/tab.c index 30699e5c64..552e0e31a5 100644 --- a/deps/libui/gtk/tab.c +++ b/deps/libui/unix/tab.c @@ -15,18 +15,16 @@ uiUnixControlAllDefaultsExceptDestroy(uiTab) static void uiTabDestroy(uiControl *c) { + uiTab *t = uiTab(c); guint i; - uiTab *t = uiTab(c); - struct child *page = NULL; + struct child *page; - for (i = 0; i < t->pages->len; i++) - { + for (i = 0; i < t->pages->len; i++) { page = g_array_index(t->pages, struct child *, i); childDestroy(page); } - g_array_free(t->pages, TRUE); - /* and free ourselves */ + // and free ourselves g_object_unref(t->widget); uiFreeControl(uiControl(t)); } @@ -38,8 +36,10 @@ void uiTabAppend(uiTab *t, const char *name, uiControl *child) void uiTabInsertAt(uiTab *t, const char *name, int n, uiControl *child) { - /* this will create a tab, because of gtk_container_add() */ - struct child *page = newChildWithBox(child, uiControl(t), t->container, 0); + struct child *page; + + // this will create a tab, because of gtk_container_add() + page = newChildWithBox(child, uiControl(t), t->container, 0); gtk_notebook_set_tab_label_text(t->notebook, childBox(page), name); gtk_notebook_reorder_child(t->notebook, childBox(page), n); @@ -49,10 +49,10 @@ void uiTabInsertAt(uiTab *t, const char *name, int n, uiControl *child) void uiTabDelete(uiTab *t, int n) { - struct child *page = g_array_index(t->pages, struct child *, n); - /* this will remove the tab, - * because gtk_widget_destroy() calls gtk_container_remove() */ + struct child *page; + page = g_array_index(t->pages, struct child *, n); + // this will remove the tab, because gtk_widget_destroy() calls gtk_container_remove() childRemove(page); g_array_remove_index(t->pages, n); } @@ -64,28 +64,30 @@ int uiTabNumPages(uiTab *t) int uiTabMargined(uiTab *t, int n) { - struct child *page = g_array_index(t->pages, struct child *, n); + struct child *page; + page = g_array_index(t->pages, struct child *, n); return childFlag(page); } void uiTabSetMargined(uiTab *t, int n, int margined) { - struct child *page = g_array_index(t->pages, struct child *, n); + struct child *page; + page = g_array_index(t->pages, struct child *, n); childSetFlag(page, margined); childSetMargined(page, childFlag(page)); } uiTab *uiNewTab(void) { - uiTab *t = NULL;; + uiTab *t; uiUnixNewControl(uiTab, t); - t->widget = gtk_notebook_new(); + t->widget = gtk_notebook_new(); t->container = GTK_CONTAINER(t->widget); - t->notebook = GTK_NOTEBOOK(t->widget); + t->notebook = GTK_NOTEBOOK(t->widget); gtk_notebook_set_scrollable(t->notebook, TRUE); diff --git a/deps/libui/gtk/text.c b/deps/libui/unix/text.c similarity index 100% rename from deps/libui/gtk/text.c rename to deps/libui/unix/text.c diff --git a/deps/libui/gtk/uipriv_unix.h b/deps/libui/unix/uipriv_unix.h similarity index 89% rename from deps/libui/gtk/uipriv_unix.h rename to deps/libui/unix/uipriv_unix.h index 3015c30172..33ff1e3553 100644 --- a/deps/libui/gtk/uipriv_unix.h +++ b/deps/libui/unix/uipriv_unix.h @@ -1,11 +1,11 @@ -/* 22 april 2015 */ +// 22 april 2015 #define GLIB_VERSION_MIN_REQUIRED GLIB_VERSION_2_40 #define GLIB_VERSION_MAX_ALLOWED GLIB_VERSION_2_40 #define GDK_VERSION_MIN_REQUIRED GDK_VERSION_3_10 #define GDK_VERSION_MAX_ALLOWED GDK_VERSION_3_10 #include #include -#include /* see drawtext.c */ +#include // see drawtext.c #include #include #include @@ -18,19 +18,19 @@ #define gtkXPadding 12 #define gtkYPadding 6 -/* menu.c */ +// menu.c extern GtkWidget *makeMenubar(uiWindow *); extern void freeMenubar(GtkWidget *); extern void uninitMenus(void); -/* alloc.c */ +// alloc.c extern void initAlloc(void); extern void uninitAlloc(void); -/* util.c */ +// util.c extern void setMargined(GtkContainer *, int); -/* child.c */ +// child.c extern struct child *newChild(uiControl *child, uiControl *parent, GtkContainer *parentContainer); extern struct child *newChildWithBox(uiControl *child, uiControl *parent, GtkContainer *parentContainer, int margined); extern void childRemove(struct child *c); @@ -41,25 +41,25 @@ extern void childSetFlag(struct child *c, int flag); extern GtkWidget *childBox(struct child *c); extern void childSetMargined(struct child *c, int margined); -/* draw.c */ +// draw.c extern uiDrawContext *newContext(cairo_t *); extern void freeContext(uiDrawContext *); -/* drawtext.c */ +// drawtext.c extern uiDrawTextFont *mkTextFont(PangoFont *f, gboolean add); extern PangoFont *pangoDescToPangoFont(PangoFontDescription *pdesc); -/* graphemes.c */ +// graphemes.c extern ptrdiff_t *graphemes(const char *text, PangoContext *context); -/* image.c */ +// image.c /*TODO remove this*/typedef struct uiImage uiImage; extern cairo_surface_t *imageAppropriateSurface(uiImage *i, GtkWidget *w); -/* cellrendererbutton.c */ +// cellrendererbutton.c extern GtkCellRenderer *newCellRendererButton(void); -/* future.c */ +// future.c extern void loadFutures(void); extern PangoAttribute *FUTURE_pango_attr_foreground_alpha_new(guint16 alpha); extern gboolean FUTURE_gtk_widget_path_iter_set_object_name(GtkWidgetPath *path, gint pos, const char *name); diff --git a/deps/libui/gtk/util.c b/deps/libui/unix/util.c similarity index 100% rename from deps/libui/gtk/util.c rename to deps/libui/unix/util.c diff --git a/deps/libui/gtk/window.c b/deps/libui/unix/window.c similarity index 81% rename from deps/libui/gtk/window.c rename to deps/libui/unix/window.c index 0251f64943..ea9ba370f4 100644 --- a/deps/libui/gtk/window.c +++ b/deps/libui/unix/window.c @@ -1,43 +1,40 @@ // 11 june 2015 #include "uipriv_unix.h" -struct uiWindow -{ - uiUnixControl c; +struct uiWindow { + uiUnixControl c; - GtkWidget *widget; - GtkContainer *container; - GtkWindow *window; + GtkWidget *widget; + GtkContainer *container; + GtkWindow *window; - GtkWidget *vboxWidget; - GtkContainer *vboxContainer; - GtkBox *vbox; + GtkWidget *vboxWidget; + GtkContainer *vboxContainer; + GtkBox *vbox; - GtkWidget *childHolderWidget; - GtkContainer *childHolderContainer; + GtkWidget *childHolderWidget; + GtkContainer *childHolderContainer; - GtkWidget *menubar; + GtkWidget *menubar; - uiControl *child; - int margined; + uiControl *child; + int margined; - int (*onClosing)(uiWindow *, void *); - void *onClosingData; - void (*onContentSizeChanged)(uiWindow *, void *); - void *onContentSizeChangedData; - gboolean fullscreen; + int (*onClosing)(uiWindow *, void *); + void *onClosingData; + void (*onContentSizeChanged)(uiWindow *, void *); + void *onContentSizeChangedData; + gboolean fullscreen; }; static gboolean onClosing(GtkWidget *win, GdkEvent *e, gpointer data) { uiWindow *w = uiWindow(data); - /* manually destroy the window ourselves; don't let - * the delete-event handler do it */ + // manually destroy the window ourselves; don't let the delete-event handler do it if ((*(w->onClosing))(w, w->onClosingData)) uiControlDestroy(uiControl(w)); - /* don't continue to the default delete-event handler; - * we destroyed the window by now */ + // don't continue to the default delete-event handler; we destroyed the window by now return TRUE; } @@ -45,7 +42,7 @@ static void onSizeAllocate(GtkWidget *widget, GdkRectangle *allocation, gpointer { uiWindow *w = uiWindow(data); - /* TODO deal with spurious size-allocates */ + // TODO deal with spurious size-allocates (*(w->onContentSizeChanged))(w, w->onContentSizeChangedData); } @@ -56,30 +53,28 @@ static int defaultOnClosing(uiWindow *w, void *data) static void defaultOnPositionContentSizeChanged(uiWindow *w, void *data) { - /* do nothing */ + // do nothing } static void uiWindowDestroy(uiControl *c) { uiWindow *w = uiWindow(c); - /* first hide ourselves */ + // first hide ourselves gtk_widget_hide(w->widget); - /* now destroy the child */ - if (w->child != NULL) - { - uiControlSetParent(w->child, NULL); - uiUnixControlSetContainer(uiUnixControl(w->child), w->childHolderContainer, TRUE); - uiControlDestroy(w->child); - } - /* now destroy the menus, if any */ + // now destroy the child + if (w->child != NULL) { + uiControlSetParent(w->child, NULL); + uiUnixControlSetContainer(uiUnixControl(w->child), w->childHolderContainer, TRUE); + uiControlDestroy(w->child); + } + // now destroy the menus, if any if (w->menubar != NULL) freeMenubar(w->menubar); gtk_widget_destroy(w->childHolderWidget); gtk_widget_destroy(w->vboxWidget); - /* and finally free ourselves - * use gtk_widget_destroy() instead of g_object_unref() - * because GTK+ has internal references (see #165) */ + // and finally free ourselves + // use gtk_widget_destroy() instead of g_object_unref() because GTK+ has internal references (see #165) gtk_widget_destroy(w->widget); uiFreeControl(uiControl(w)); } @@ -107,11 +102,9 @@ static void uiWindowShow(uiControl *c) { uiWindow *w = uiWindow(c); - /* don't use gtk_widget_show_all() as that - * will show all children, regardless of user settings - * don't use gtk_widget_show(); that doesn't bring to - * front or give keyboard focus - * (gtk_window_present() does call gtk_widget_show() though) */ + // don't use gtk_widget_show_all() as that will show all children, regardless of user settings + // don't use gtk_widget_show(); that doesn't bring to front or give keyboard focus + // (gtk_window_present() does call gtk_widget_show() though) gtk_window_present(w->window); } @@ -119,8 +112,7 @@ uiUnixControlDefaultHide(uiWindow) uiUnixControlDefaultEnabled(uiWindow) uiUnixControlDefaultEnable(uiWindow) uiUnixControlDefaultDisable(uiWindow) - -/* TODO? */ +// TODO? uiUnixControlDefaultSetContainer(uiWindow) char *uiWindowTitle(uiWindow *w) diff --git a/deps/libui/win32/datetimepicker.cpp b/deps/libui/win32/datetimepicker.cpp deleted file mode 100644 index c14359379d..0000000000 --- a/deps/libui/win32/datetimepicker.cpp +++ /dev/null @@ -1,198 +0,0 @@ -/* 22 may 2015 */ -#include "uipriv_windows.hpp" - -struct uiDateTimePicker { - uiWindowsControl c; - HWND hwnd; -}; - -#ifndef DTM_GETIDEALSIZE -#define DTM_GETIDEALSIZE 0x100f -#endif - -/* utility functions */ - -#define GLI(what, buf, n) GetLocaleInfoEx(LOCALE_NAME_USER_DEFAULT, what, buf, n) - -/* The real date/time picker does a manual replacement of "yy" with "yyyy" for DTS_SHORTDATECENTURYFORMAT. - * Because we're also duplicating its functionality (see below), we have to do it too. */ -static WCHAR *expandYear(WCHAR *dts, int n) -{ - WCHAR *p = NULL; - int ny = 0; - - /* allocate more than we need to be safe */ - WCHAR *out = (WCHAR *) uiAlloc((n * 3) * sizeof (WCHAR), "WCHAR[]"); - WCHAR *q = out; - - for (p = dts; *p != L'\0'; p++) - { - /* first, if the current character is a y, increment the number of consecutive ys - * otherwise, stop counting, and if there were only two, add two more to make four */ - if (*p != L'y') { - if (ny == 2) { - *q++ = L'y'; - *q++ = L'y'; - } - ny = 0; - } else - ny++; - /* next, handle quoted blocks - * we do this AFTER the above so yy'abc' becomes yyyy'abc' and not yy'abc'yy - * this handles the case of 'a''b' elegantly as well */ - if (*p == L'\'') { - /* copy the opening quote */ - *q++ = *p; - /* copy the contents */ - for (;;) { - p++; - if (*p == L'\'') - break; - if (*p == L'\0') - implbug("unterminated quote in system-provided locale date string in expandYear()"); - *q++ = *p; - } - /* and fall through to copy the closing quote */ - } - /* copy the current character */ - *q++ = *p; - } - /* handle trailing yy */ - if (ny == 2) { - *q++ = L'y'; - *q++ = L'y'; - } - *q++ = L'\0'; - return out; -} - -/* Windows has no combined date/time prebuilt constant; - * we have to build the format string ourselves - * TODO use a default format if one fails */ -static void setDateTimeFormat(HWND hwnd) -{ - WCHAR *unexpandedDate, *date; - WCHAR *time; - WCHAR *datetime; - int ntime; - int ndate = GLI(LOCALE_SSHORTDATE, NULL, 0); - - if (ndate == 0) - logLastError(L"error getting date string length"); - date = (WCHAR *) uiAlloc(ndate * sizeof (WCHAR), "WCHAR[]"); - if (GLI(LOCALE_SSHORTDATE, date, ndate) == 0) - logLastError(L"error geting date string"); - unexpandedDate = date; /* so we can free it */ - date = expandYear(unexpandedDate, ndate); - uiFree(unexpandedDate); - - ntime = GLI(LOCALE_STIMEFORMAT, NULL, 0); - if (ndate == 0) - logLastError(L"error getting time string length"); - time = (WCHAR *) uiAlloc(ntime * sizeof (WCHAR), "WCHAR[]"); - if (GLI(LOCALE_STIMEFORMAT, time, ntime) == 0) - logLastError(L"error geting time string"); - - datetime = strf(L"%s %s", date, time); - if (SendMessageW(hwnd, DTM_SETFORMAT, 0, (LPARAM) datetime) == 0) - logLastError(L"error applying format string to date/time picker"); - - uiFree(datetime); - uiFree(time); - uiFree(date); -} - -/* control implementation */ - -static void uiDateTimePickerDestroy(uiControl *c) -{ - uiDateTimePicker *d = uiDateTimePicker(c); - - uiWindowsUnregisterReceiveWM_WININICHANGE(d->hwnd); - uiWindowsEnsureDestroyWindow(d->hwnd); - uiFreeControl(uiControl(d)); -} - -uiWindowsControlAllDefaultsExceptDestroy(uiDateTimePicker) - -/* the height returned from DTM_GETIDEALSIZE is unreliable; see http://stackoverflow.com/questions/30626549/what-is-the-proper-use-of-dtm-getidealsize-treating-the-returned-size-as-pixels - * from http://msdn.microsoft.com/en-us/library/windows/desktop/dn742486.aspx#sizingandspacing */ -#define entryHeight 14 - -static void uiDateTimePickerMinimumSize(uiWindowsControl *c, int *width, int *height) -{ - SIZE s; - uiWindowsSizing sizing; - uiDateTimePicker *d = uiDateTimePicker(c); - int y; - - s.cx = 0; - s.cy = 0; - SendMessageW(d->hwnd, DTM_GETIDEALSIZE, 0, (LPARAM) (&s)); - *width = s.cx; - - y = entryHeight; - uiWindowsGetSizing(d->hwnd, &sizing); - uiWindowsSizingDlgUnitsToPixels(&sizing, NULL, &y); - *height = y; -} - -static uiDateTimePicker *finishNewDateTimePicker(DWORD style) -{ - uiDateTimePicker *d; - - uiWindowsNewControl(uiDateTimePicker, d); - - d->hwnd = uiWindowsEnsureCreateControlHWND(WS_EX_CLIENTEDGE, - DATETIMEPICK_CLASSW, L"", - style | WS_TABSTOP, - hInstance, NULL, - TRUE); - - /* automatically update date/time format when user changes locale settings - * for the standard styles, this is in the date-time picker itself - * for our date/time mode, we do it in a subclass assigned in uiNewDateTimePicker() */ - uiWindowsRegisterReceiveWM_WININICHANGE(d->hwnd); - - return d; -} - -static LRESULT CALLBACK datetimepickerSubProc(HWND hwnd, UINT uMsg, WPARAM wParam, - LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData) -{ - switch (uMsg) - { - case WM_WININICHANGE: - // we can optimize this by only doing it when the real date/time picker does it - // unfortunately, I don't know when that is :/ - // hopefully this won't hurt - setDateTimeFormat(hwnd); - return 0; - case WM_NCDESTROY: - if (RemoveWindowSubclass(hwnd, datetimepickerSubProc, uIdSubclass) == FALSE) - logLastError(L"error removing date-time picker locale change handling subclass"); - break; - } - return DefSubclassProc(hwnd, uMsg, wParam, lParam); -} - -uiDateTimePicker *uiNewDateTimePicker(void) -{ - uiDateTimePicker *d = finishNewDateTimePicker(0); - - setDateTimeFormat(d->hwnd); - if (SetWindowSubclass(d->hwnd, datetimepickerSubProc, 0, (DWORD_PTR) d) == FALSE) - logLastError(L"error subclassing date-time-picker to assist in locale change handling"); - /* TODO set a suitable default in this case */ - return d; -} - -uiDateTimePicker *uiNewDatePicker(void) -{ - return finishNewDateTimePicker(DTS_SHORTDATECENTURYFORMAT); -} - -uiDateTimePicker *uiNewTimePicker(void) -{ - return finishNewDateTimePicker(DTS_TIMEFORMAT); -} diff --git a/deps/libui/win32/text.cpp b/deps/libui/win32/text.cpp deleted file mode 100644 index d3e0131eab..0000000000 --- a/deps/libui/win32/text.cpp +++ /dev/null @@ -1,105 +0,0 @@ -/* 9 april 2015 */ -#include "uipriv_windows.hpp" - -WCHAR *windowTextAndLen(HWND hwnd, LRESULT *len) -{ - WCHAR *text = NULL; - LRESULT n = SendMessageW(hwnd, WM_GETTEXTLENGTH, 0, 0); - - if (len != NULL) - *len = n; - /* WM_GETTEXTLENGTH does not include the null terminator */ - text = (WCHAR *) uiAlloc((n + 1) * sizeof (WCHAR), "WCHAR[]"); - /* note the comparison: the size includes the - * null terminator, but the return does not */ - if (GetWindowTextW(hwnd, text, n + 1) != n) - { - logLastError(L"error getting window text"); - /* on error, return an empty string to be safe */ - *text = L'\0'; - if (len != NULL) - *len = 0; - } - return text; -} - -WCHAR *windowText(HWND hwnd) -{ - return windowTextAndLen(hwnd, NULL); -} - -void setWindowText(HWND hwnd, WCHAR *wtext) -{ - if (SetWindowTextW(hwnd, wtext) == 0) - logLastError(L"error setting window text"); -} - -void uiFreeText(char *text) -{ - uiFree(text); -} - -int uiWindowsWindowTextWidth(HWND hwnd) -{ - LRESULT len; - HDC dc; - HFONT prevfont; - SIZE size; - WCHAR *text = windowTextAndLen(hwnd, &len); - - size.cx = 0; - size.cy = 0; - - if (len == 0) /* no text; nothing to do */ - goto noTextOrError; - - /* now we can do the calculations */ - dc = GetDC(hwnd); - if (dc == NULL) - { - logLastError(L"error getting DC"); - /* on any error, assume no text */ - goto noTextOrError; - } - prevfont = (HFONT) SelectObject(dc, hMessageFont); - if (prevfont == NULL) - { - logLastError(L"error loading control font into device context"); - ReleaseDC(hwnd, dc); - goto noTextOrError; - } - if (GetTextExtentPoint32W(dc, text, len, &size) == 0) - { - logLastError(L"error getting text extent point"); - /* continue anyway, assuming size is 0 */ - size.cx = 0; - size.cy = 0; - } - /* continue on errors; we got what we want */ - if (SelectObject(dc, prevfont) != hMessageFont) - logLastError(L"error restoring previous font into device context"); - if (ReleaseDC(hwnd, dc) == 0) - logLastError(L"error releasing DC"); - - uiFree(text); - return size.cx; - -noTextOrError: - uiFree(text); - return 0; -} - -char *uiWindowsWindowText(HWND hwnd) -{ - WCHAR *wtext = windowText(hwnd); - char *text = toUTF8(wtext); - uiFree(wtext); - return text; -} - -void uiWindowsSetWindowText(HWND hwnd, const char *text) -{ - WCHAR *wtext = toUTF16(text); - setWindowText(hwnd, wtext); - uiFree(wtext); -} diff --git a/deps/libui/win32/utilwin.cpp b/deps/libui/win32/utilwin.cpp deleted file mode 100644 index 9b9a3ac8f4..0000000000 --- a/deps/libui/win32/utilwin.cpp +++ /dev/null @@ -1,87 +0,0 @@ -/* 14 may 2015 */ -#include "uipriv_windows.hpp" -#include "../../verbosity.h" - -/* The utility window is a special window that performs certain tasks internal to libui. - * It is not a message-only window, and it is always hidden and disabled. - * Its roles: - * - It is the initial parent of all controls. When a control loses its parent, it also becomes that control's parent. - * - It handles WM_QUERYENDSESSION and console end session requests. - * - It handles WM_WININICHANGE and forwards the message to any child windows that request it. - * - It handles executing functions queued to run by uiQueueMain(). - */ - -#define utilWindowClass L"libui_utilWindowClass" - -HWND utilWindow; - -static LRESULT CALLBACK utilWindowWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - void (*qf)(void *); - LRESULT lResult; - - if (handleParentMessages(hwnd, uMsg, wParam, lParam, &lResult) != FALSE) - return lResult; - - switch (uMsg) - { - case WM_QUERYENDSESSION: - /* TODO block handler */ - if (shouldQuit()) - { - uiQuit(); - return TRUE; - } - return FALSE; - case WM_WININICHANGE: - issueWM_WININICHANGE(wParam, lParam); - return 0; - case msgQueued: - qf = (void (*)(void *)) wParam; - (*qf)((void *) lParam); - return 0; - } - return DefWindowProcW(hwnd, uMsg, wParam, lParam); -} - -const char *initUtilWindow(HICON hDefaultIcon, HCURSOR hDefaultCursor) -{ - WNDCLASSW wc; - - ZeroMemory(&wc, sizeof (WNDCLASSW)); - wc.lpszClassName = utilWindowClass; - wc.lpfnWndProc = utilWindowWndProc; - wc.hInstance = hInstance; - wc.hIcon = hDefaultIcon; - wc.hCursor = hDefaultCursor; - wc.hbrBackground = (HBRUSH) (COLOR_BTNFACE + 1); - if (RegisterClass(&wc) == 0) - { - RARCH_ERR("Cannot register class.\n"); - /* see init.cpp for an explanation of the =s */ - return "=registering utility window class"; - } - - utilWindow = CreateWindowExW(0, - utilWindowClass, L"libui utility window", - WS_OVERLAPPEDWINDOW, - 0, 0, 100, 100, - NULL, NULL, hInstance, NULL); - if (utilWindow == NULL) - { - RARCH_ERR("Cannot create window.\n"); - return "=creating utility window"; - } - /* and just to be safe */ - EnableWindow(utilWindow, FALSE); - - return NULL; -} - -void uninitUtilWindow(void) -{ - if (DestroyWindow(utilWindow) == 0) - logLastError(L"error destroying utility window"); - if (UnregisterClass(utilWindowClass, hInstance) == 0) - logLastError(L"error unregistering utility window class"); -} diff --git a/deps/libui/win32/winextra.h b/deps/libui/win32/winextra.h deleted file mode 100644 index 6d0bb3ee7d..0000000000 --- a/deps/libui/win32/winextra.h +++ /dev/null @@ -1,150 +0,0 @@ -/* This file contains some Vista SDK stuff that is missing from the current - mingw-w64 headers */ - -#ifndef WINEXTRA_H -#define WINEXTRA_H - -/* winuser.h */ - -#if (_WIN32_WINNT >= 0x0600) - WINUSERAPI WINBOOL WINAPI SetProcessDPIAware(VOID); - WINUSERAPI WINBOOL WINAPI IsProcessDPIAware(VOID); -#endif - -/* commctrl.h */ - -#ifndef NOTASKDIALOG -#if (NTDDI_VERSION >= NTDDI_VISTA) -#include -#define TD_WARNING_ICON MAKEINTRESOURCEW(-1) -#define TD_ERROR_ICON MAKEINTRESOURCEW(-2) -#define TD_INFORMATION_ICON MAKEINTRESOURCEW(-3) -#define TD_SHIELD_ICON MAKEINTRESOURCEW(-4) - - typedef HRESULT (CALLBACK *PFTASKDIALOGCALLBACK)(HWND hwnd,UINT uNotification,WPARAM wParam,LPARAM lParam,LONG_PTR dwRefData); - - enum _TASKDIALOG_FLAGS { - TDF_ENABLE_HYPERLINKS = 0x0001, - TDF_USE_HICON_MAIN = 0x0002, - TDF_USE_HICON_FOOTER = 0x0004, - TDF_ALLOW_DIALOG_CANCELLATION = 0x0008, - TDF_USE_COMMAND_LINKS = 0x0010, - TDF_USE_COMMAND_LINKS_NO_ICON = 0x0020, - TDF_EXPAND_FOOTER_AREA = 0x0040, - TDF_EXPANDED_BY_DEFAULT = 0x0080, - TDF_VERIFICATION_FLAG_CHECKED = 0x0100, - TDF_SHOW_PROGRESS_BAR = 0x0200, - TDF_SHOW_MARQUEE_PROGRESS_BAR = 0x0400, - TDF_CALLBACK_TIMER = 0x0800, - TDF_POSITION_RELATIVE_TO_WINDOW = 0x1000, - TDF_RTL_LAYOUT = 0x2000, - TDF_NO_DEFAULT_RADIO_BUTTON = 0x4000, - TDF_CAN_BE_MINIMIZED = 0x8000, - TDIF_SIZE_TO_CONTENT = 0x1000000, - TDF_SIZE_TO_CONTENT = 0x1000000 - }; - typedef int TASKDIALOG_FLAGS; - - enum _TASKDIALOG_COMMON_BUTTON_FLAGS { - TDCBF_OK_BUTTON = 0x01, - TDCBF_YES_BUTTON = 0x02, - TDCBF_NO_BUTTON = 0x04, - TDCBF_CANCEL_BUTTON = 0x08, - TDCBF_RETRY_BUTTON = 0x10, - TDCBF_CLOSE_BUTTON = 0x20 - }; - typedef int TASKDIALOG_COMMON_BUTTON_FLAGS; - - typedef enum _TASKDIALOG_NOTIFICATIONS { - TDN_CREATED = 0, - TDN_NAVIGATED = 1, - TDN_BUTTON_CLICKED = 2, - TDN_HYPERLINK_CLICKED = 3, - TDN_TIMER = 4, - TDN_DESTROYED = 5, - TDN_RADIO_BUTTON_CLICKED = 6, - TDN_DIALOG_CONSTRUCTED = 7, - TDN_VERIFICATION_CLICKED = 8, - TDN_HELP = 9, - TDN_EXPANDO_BUTTON_CLICKED = 10 - } TASKDIALOG_NOTIFICATIONS; - - typedef enum _TASKDIALOG_MESSAGES { - TDM_NAVIGATE_PAGE = WM_USER + 101, - TDM_CLICK_BUTTON = WM_USER + 102, - TDM_SET_MARQUEE_PROGRESS_BAR = WM_USER + 103, - TDM_SET_PROGRESS_BAR_STATE = WM_USER + 104, - TDM_SET_PROGRESS_BAR_RANGE = WM_USER + 105, - TDM_SET_PROGRESS_BAR_POS = WM_USER + 106, - TDM_SET_PROGRESS_BAR_MARQUEE = WM_USER + 107, - TDM_SET_ELEMENT_TEXT = WM_USER + 108, - TDM_CLICK_RADIO_BUTTON = WM_USER + 110, - TDM_ENABLE_BUTTON = WM_USER + 111, - TDM_ENABLE_RADIO_BUTTON = WM_USER + 112, - TDM_CLICK_VERIFICATION = WM_USER + 113, - TDM_UPDATE_ELEMENT_TEXT = WM_USER + 114, - TDM_SET_BUTTON_ELEVATION_REQUIRED_STATE = WM_USER + 115, - TDM_UPDATE_ICON = WM_USER + 116 - } TASKDIALOG_MESSAGES; - - typedef enum _TASKDIALOG_ELEMENTS { - TDE_CONTENT, - TDE_EXPANDED_INFORMATION, - TDE_FOOTER, - TDE_MAIN_INSTRUCTION - } TASKDIALOG_ELEMENTS; - - typedef enum _TASKDIALOG_ICON_ELEMENTS { - TDIE_ICON_MAIN, - TDIE_ICON_FOOTER - } TASKDIALOG_ICON_ELEMENTS; - - typedef struct _TASKDIALOG_BUTTON { - int nButtonID; - PCWSTR pszButtonText; - } TASKDIALOG_BUTTON; - - typedef struct _TASKDIALOGCONFIG { - UINT cbSize; - HWND hwndParent; - HINSTANCE hInstance; - TASKDIALOG_FLAGS dwFlags; - TASKDIALOG_COMMON_BUTTON_FLAGS dwCommonButtons; - PCWSTR pszWindowTitle; - __C89_NAMELESS union { - HICON hMainIcon; - PCWSTR pszMainIcon; - } DUMMYUNIONNAME; - PCWSTR pszMainInstruction; - PCWSTR pszContent; - UINT cButtons; - const TASKDIALOG_BUTTON *pButtons; - int nDefaultButton; - UINT cRadioButtons; - const TASKDIALOG_BUTTON *pRadioButtons; - int nDefaultRadioButton; - PCWSTR pszVerificationText; - PCWSTR pszExpandedInformation; - PCWSTR pszExpandedControlText; - PCWSTR pszCollapsedControlText; - __C89_NAMELESS union { - HICON hFooterIcon; - PCWSTR pszFooterIcon; - } DUMMYUNIONNAME2; - PCWSTR pszFooter; - PFTASKDIALOGCALLBACK pfCallback; - LONG_PTR lpCallbackData; - UINT cxWidth; - } TASKDIALOGCONFIG; - - WINCOMMCTRLAPI HRESULT WINAPI TaskDialog(HWND hwndParent,HINSTANCE hInstance,PCWSTR pszWindowTitle,PCWSTR pszMainInstruction,PCWSTR pszContent,TASKDIALOG_COMMON_BUTTON_FLAGS dwCommonButtons,PCWSTR pszIcon,int *pnButton); - WINCOMMCTRLAPI HRESULT WINAPI TaskDialogIndirect(const TASKDIALOGCONFIG *pTaskConfig,int *pnButton,int *pnRadioButton,BOOL *pfVerificationFlagChecked); -#include -#endif -#endif - -/* dwmapi.h */ - -HRESULT WINAPI DwmFlush(VOID); - -#endif diff --git a/deps/libui/windows/CMakeLists.txt b/deps/libui/windows/CMakeLists.txt new file mode 100644 index 0000000000..4695eb4f6e --- /dev/null +++ b/deps/libui/windows/CMakeLists.txt @@ -0,0 +1,91 @@ +# 3 june 2016 + +list(APPEND _LIBUI_SOURCES + windows/alloc.cpp + windows/area.cpp + windows/areadraw.cpp + windows/areaevents.cpp + windows/areascroll.cpp + windows/areautil.cpp + windows/box.cpp + windows/button.cpp + windows/checkbox.cpp + windows/colorbutton.cpp + windows/colordialog.cpp + windows/combobox.cpp + windows/container.cpp + windows/control.cpp + windows/d2dscratch.cpp + windows/datetimepicker.cpp + windows/debug.cpp + windows/draw.cpp + windows/drawmatrix.cpp + windows/drawpath.cpp + windows/drawtext.cpp + windows/dwrite.cpp + windows/editablecombo.cpp + windows/entry.cpp + windows/events.cpp + windows/fontbutton.cpp + windows/fontdialog.cpp + windows/form.cpp + windows/graphemes.cpp + windows/grid.cpp + windows/group.cpp + windows/init.cpp + windows/label.cpp + windows/main.cpp + windows/menu.cpp + windows/multilineentry.cpp + windows/parent.cpp + windows/progressbar.cpp + windows/radiobuttons.cpp + windows/separator.cpp + windows/sizing.cpp + windows/slider.cpp + windows/spinbox.cpp + windows/stddialogs.cpp + windows/tab.cpp + windows/tabpage.cpp + windows/text.cpp + windows/utf16.cpp + windows/utilwin.cpp + windows/window.cpp + windows/winpublic.cpp + windows/winutil.cpp + windows/resources.rc +) +set(_LIBUI_SOURCES ${_LIBUI_SOURCES} PARENT_SCOPE) + +list(APPEND _LIBUI_INCLUDEDIRS + windows +) +set(_LIBUI_INCLUDEDIRS _LIBUI_INCLUDEDIRS PARENT_SCOPE) + +# Windows won't link resources in static libraries; we need to provide the libui.res file in this case. +set(_LIBUINAME libui PARENT_SCOPE) +if(NOT BUILD_SHARED_LIBS) + set(_LIBUI_STATIC_RES ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}/libui.res PARENT_SCOPE) +endif() +macro(_handle_static) + # TODO this full path feels hacky + add_custom_command( + TARGET libui POST_BUILD + COMMAND + ${CMAKE_COMMAND} -E copy $/CMakeFiles/libui.dir/windows/resources.rc.* ${_LIBUI_STATIC_RES} + COMMENT "Copying libui.res") +endmacro() + +# notice that usp10 comes before gdi32 +# TODO prune this list +set(_LIBUI_LIBS + user32 kernel32 usp10 gdi32 comctl32 uxtheme msimg32 comdlg32 d2d1 dwrite ole32 oleaut32 oleacc uuid +PARENT_SCOPE) + +if(NOT MSVC) + if(BUILD_SHARED_LIBS) + message(FATAL_ERROR + "Sorry, but libui for Windows can currently only be built as a static library with MinGW. You will need to either build as a static library or switch to MSVC." + ) + endif() +endif() diff --git a/deps/libui/win32/_uipriv_migrate.hpp b/deps/libui/windows/_uipriv_migrate.hpp similarity index 100% rename from deps/libui/win32/_uipriv_migrate.hpp rename to deps/libui/windows/_uipriv_migrate.hpp diff --git a/deps/libui/win32/alloc.cpp b/deps/libui/windows/alloc.cpp similarity index 100% rename from deps/libui/win32/alloc.cpp rename to deps/libui/windows/alloc.cpp diff --git a/deps/libui/win32/area.cpp b/deps/libui/windows/area.cpp similarity index 100% rename from deps/libui/win32/area.cpp rename to deps/libui/windows/area.cpp diff --git a/deps/libui/win32/area.hpp b/deps/libui/windows/area.hpp similarity index 100% rename from deps/libui/win32/area.hpp rename to deps/libui/windows/area.hpp diff --git a/deps/libui/win32/areadraw.cpp b/deps/libui/windows/areadraw.cpp similarity index 100% rename from deps/libui/win32/areadraw.cpp rename to deps/libui/windows/areadraw.cpp diff --git a/deps/libui/win32/areaevents.cpp b/deps/libui/windows/areaevents.cpp similarity index 100% rename from deps/libui/win32/areaevents.cpp rename to deps/libui/windows/areaevents.cpp diff --git a/deps/libui/win32/areascroll.cpp b/deps/libui/windows/areascroll.cpp similarity index 99% rename from deps/libui/win32/areascroll.cpp rename to deps/libui/windows/areascroll.cpp index 1797063a9d..f18d0ad874 100644 --- a/deps/libui/win32/areascroll.cpp +++ b/deps/libui/windows/areascroll.cpp @@ -100,10 +100,11 @@ static void scroll(uiArea *a, int which, struct scrollParams *p, WPARAM wParam, static void wheelscroll(uiArea *a, int which, struct scrollParams *p, WPARAM wParam, LPARAM lParam) { + int delta; int lines; UINT scrollAmount; - int delta = GET_WHEEL_DELTA_WPARAM(wParam); + delta = GET_WHEEL_DELTA_WPARAM(wParam); if (SystemParametersInfoW(p->wheelSPIAction, 0, &scrollAmount, 0) == 0) // TODO use scrollAmount == 3 (for both v and h) instead? logLastError(L"error getting area wheel scroll amount"); diff --git a/deps/libui/win32/areautil.cpp b/deps/libui/windows/areautil.cpp similarity index 100% rename from deps/libui/win32/areautil.cpp rename to deps/libui/windows/areautil.cpp diff --git a/deps/libui/win32/box.cpp b/deps/libui/windows/box.cpp similarity index 100% rename from deps/libui/win32/box.cpp rename to deps/libui/windows/box.cpp diff --git a/deps/libui/win32/button.cpp b/deps/libui/windows/button.cpp similarity index 100% rename from deps/libui/win32/button.cpp rename to deps/libui/windows/button.cpp diff --git a/deps/libui/win32/checkbox.cpp b/deps/libui/windows/checkbox.cpp similarity index 100% rename from deps/libui/win32/checkbox.cpp rename to deps/libui/windows/checkbox.cpp diff --git a/deps/libui/win32/colorbutton.cpp b/deps/libui/windows/colorbutton.cpp similarity index 100% rename from deps/libui/win32/colorbutton.cpp rename to deps/libui/windows/colorbutton.cpp diff --git a/deps/libui/win32/colordialog.cpp b/deps/libui/windows/colordialog.cpp similarity index 100% rename from deps/libui/win32/colordialog.cpp rename to deps/libui/windows/colordialog.cpp diff --git a/deps/libui/win32/combobox.cpp b/deps/libui/windows/combobox.cpp similarity index 100% rename from deps/libui/win32/combobox.cpp rename to deps/libui/windows/combobox.cpp diff --git a/deps/libui/win32/compilerver.hpp b/deps/libui/windows/compilerver.hpp similarity index 100% rename from deps/libui/win32/compilerver.hpp rename to deps/libui/windows/compilerver.hpp diff --git a/deps/libui/win32/container.cpp b/deps/libui/windows/container.cpp similarity index 100% rename from deps/libui/win32/container.cpp rename to deps/libui/windows/container.cpp diff --git a/deps/libui/win32/control.cpp b/deps/libui/windows/control.cpp similarity index 100% rename from deps/libui/win32/control.cpp rename to deps/libui/windows/control.cpp diff --git a/deps/libui/win32/d2dscratch.cpp b/deps/libui/windows/d2dscratch.cpp similarity index 100% rename from deps/libui/win32/d2dscratch.cpp rename to deps/libui/windows/d2dscratch.cpp diff --git a/deps/libui/windows/datetimepicker.cpp b/deps/libui/windows/datetimepicker.cpp new file mode 100644 index 0000000000..e105c2fdb7 --- /dev/null +++ b/deps/libui/windows/datetimepicker.cpp @@ -0,0 +1,191 @@ +// 22 may 2015 +#include "uipriv_windows.hpp" + +struct uiDateTimePicker { + uiWindowsControl c; + HWND hwnd; +}; + +// utility functions + +#define GLI(what, buf, n) GetLocaleInfoEx(LOCALE_NAME_USER_DEFAULT, what, buf, n) + +// The real date/time picker does a manual replacement of "yy" with "yyyy" for DTS_SHORTDATECENTURYFORMAT. +// Because we're also duplicating its functionality (see below), we have to do it too. +static WCHAR *expandYear(WCHAR *dts, int n) +{ + WCHAR *out; + WCHAR *p, *q; + int ny = 0; + + // allocate more than we need to be safe + out = (WCHAR *) uiAlloc((n * 3) * sizeof (WCHAR), "WCHAR[]"); + q = out; + for (p = dts; *p != L'\0'; p++) { + // first, if the current character is a y, increment the number of consecutive ys + // otherwise, stop counting, and if there were only two, add two more to make four + if (*p != L'y') { + if (ny == 2) { + *q++ = L'y'; + *q++ = L'y'; + } + ny = 0; + } else + ny++; + // next, handle quoted blocks + // we do this AFTER the above so yy'abc' becomes yyyy'abc' and not yy'abc'yy + // this handles the case of 'a''b' elegantly as well + if (*p == L'\'') { + // copy the opening quote + *q++ = *p; + // copy the contents + for (;;) { + p++; + if (*p == L'\'') + break; + if (*p == L'\0') + implbug("unterminated quote in system-provided locale date string in expandYear()"); + *q++ = *p; + } + // and fall through to copy the closing quote + } + // copy the current character + *q++ = *p; + } + // handle trailing yy + if (ny == 2) { + *q++ = L'y'; + *q++ = L'y'; + } + *q++ = L'\0'; + return out; +} + +// Windows has no combined date/time prebuilt constant; we have to build the format string ourselves +// TODO use a default format if one fails +static void setDateTimeFormat(HWND hwnd) +{ + WCHAR *unexpandedDate, *date; + WCHAR *time; + WCHAR *datetime; + int ndate, ntime; + + ndate = GLI(LOCALE_SSHORTDATE, NULL, 0); + if (ndate == 0) + logLastError(L"error getting date string length"); + date = (WCHAR *) uiAlloc(ndate * sizeof (WCHAR), "WCHAR[]"); + if (GLI(LOCALE_SSHORTDATE, date, ndate) == 0) + logLastError(L"error geting date string"); + unexpandedDate = date; // so we can free it + date = expandYear(unexpandedDate, ndate); + uiFree(unexpandedDate); + + ntime = GLI(LOCALE_STIMEFORMAT, NULL, 0); + if (ndate == 0) + logLastError(L"error getting time string length"); + time = (WCHAR *) uiAlloc(ntime * sizeof (WCHAR), "WCHAR[]"); + if (GLI(LOCALE_STIMEFORMAT, time, ntime) == 0) + logLastError(L"error geting time string"); + + datetime = strf(L"%s %s", date, time); + if (SendMessageW(hwnd, DTM_SETFORMAT, 0, (LPARAM) datetime) == 0) + logLastError(L"error applying format string to date/time picker"); + + uiFree(datetime); + uiFree(time); + uiFree(date); +} + +// control implementation + +static void uiDateTimePickerDestroy(uiControl *c) +{ + uiDateTimePicker *d = uiDateTimePicker(c); + + uiWindowsUnregisterReceiveWM_WININICHANGE(d->hwnd); + uiWindowsEnsureDestroyWindow(d->hwnd); + uiFreeControl(uiControl(d)); +} + +uiWindowsControlAllDefaultsExceptDestroy(uiDateTimePicker) + +// the height returned from DTM_GETIDEALSIZE is unreliable; see http://stackoverflow.com/questions/30626549/what-is-the-proper-use-of-dtm-getidealsize-treating-the-returned-size-as-pixels +// from http://msdn.microsoft.com/en-us/library/windows/desktop/dn742486.aspx#sizingandspacing +#define entryHeight 14 + +static void uiDateTimePickerMinimumSize(uiWindowsControl *c, int *width, int *height) +{ + uiDateTimePicker *d = uiDateTimePicker(c); + SIZE s; + uiWindowsSizing sizing; + int y; + + s.cx = 0; + s.cy = 0; + SendMessageW(d->hwnd, DTM_GETIDEALSIZE, 0, (LPARAM) (&s)); + *width = s.cx; + + y = entryHeight; + uiWindowsGetSizing(d->hwnd, &sizing); + uiWindowsSizingDlgUnitsToPixels(&sizing, NULL, &y); + *height = y; +} + +static uiDateTimePicker *finishNewDateTimePicker(DWORD style) +{ + uiDateTimePicker *d; + + uiWindowsNewControl(uiDateTimePicker, d); + + d->hwnd = uiWindowsEnsureCreateControlHWND(WS_EX_CLIENTEDGE, + DATETIMEPICK_CLASSW, L"", + style | WS_TABSTOP, + hInstance, NULL, + TRUE); + + // automatically update date/time format when user changes locale settings + // for the standard styles, this is in the date-time picker itself + // for our date/time mode, we do it in a subclass assigned in uiNewDateTimePicker() + uiWindowsRegisterReceiveWM_WININICHANGE(d->hwnd); + + return d; +} + +static LRESULT CALLBACK datetimepickerSubProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData) +{ + switch (uMsg) { + case WM_WININICHANGE: + // we can optimize this by only doing it when the real date/time picker does it + // unfortunately, I don't know when that is :/ + // hopefully this won't hurt + setDateTimeFormat(hwnd); + return 0; + case WM_NCDESTROY: + if (RemoveWindowSubclass(hwnd, datetimepickerSubProc, uIdSubclass) == FALSE) + logLastError(L"error removing date-time picker locale change handling subclass"); + break; + } + return DefSubclassProc(hwnd, uMsg, wParam, lParam); +} + +uiDateTimePicker *uiNewDateTimePicker(void) +{ + uiDateTimePicker *d; + + d = finishNewDateTimePicker(0); + setDateTimeFormat(d->hwnd); + if (SetWindowSubclass(d->hwnd, datetimepickerSubProc, 0, (DWORD_PTR) d) == FALSE) + logLastError(L"error subclassing date-time-picker to assist in locale change handling"); + // TODO set a suitable default in this case + return d; +} + +uiDateTimePicker *uiNewDatePicker(void) +{ + return finishNewDateTimePicker(DTS_SHORTDATECENTURYFORMAT); +} + +uiDateTimePicker *uiNewTimePicker(void) +{ + return finishNewDateTimePicker(DTS_TIMEFORMAT); +} diff --git a/deps/libui/win32/debug.cpp b/deps/libui/windows/debug.cpp similarity index 100% rename from deps/libui/win32/debug.cpp rename to deps/libui/windows/debug.cpp diff --git a/deps/libui/win32/draw.cpp b/deps/libui/windows/draw.cpp similarity index 100% rename from deps/libui/win32/draw.cpp rename to deps/libui/windows/draw.cpp diff --git a/deps/libui/win32/draw.hpp b/deps/libui/windows/draw.hpp similarity index 100% rename from deps/libui/win32/draw.hpp rename to deps/libui/windows/draw.hpp diff --git a/deps/libui/win32/drawmatrix.cpp b/deps/libui/windows/drawmatrix.cpp similarity index 100% rename from deps/libui/win32/drawmatrix.cpp rename to deps/libui/windows/drawmatrix.cpp diff --git a/deps/libui/win32/drawpath.cpp b/deps/libui/windows/drawpath.cpp similarity index 100% rename from deps/libui/win32/drawpath.cpp rename to deps/libui/windows/drawpath.cpp diff --git a/deps/libui/win32/drawtext.cpp b/deps/libui/windows/drawtext.cpp similarity index 100% rename from deps/libui/win32/drawtext.cpp rename to deps/libui/windows/drawtext.cpp diff --git a/deps/libui/win32/dwrite.cpp b/deps/libui/windows/dwrite.cpp similarity index 100% rename from deps/libui/win32/dwrite.cpp rename to deps/libui/windows/dwrite.cpp diff --git a/deps/libui/win32/editablecombo.cpp b/deps/libui/windows/editablecombo.cpp similarity index 100% rename from deps/libui/win32/editablecombo.cpp rename to deps/libui/windows/editablecombo.cpp diff --git a/deps/libui/win32/entry.cpp b/deps/libui/windows/entry.cpp similarity index 100% rename from deps/libui/win32/entry.cpp rename to deps/libui/windows/entry.cpp diff --git a/deps/libui/win32/events.cpp b/deps/libui/windows/events.cpp similarity index 100% rename from deps/libui/win32/events.cpp rename to deps/libui/windows/events.cpp diff --git a/deps/libui/win32/fontbutton.cpp b/deps/libui/windows/fontbutton.cpp similarity index 100% rename from deps/libui/win32/fontbutton.cpp rename to deps/libui/windows/fontbutton.cpp diff --git a/deps/libui/win32/fontdialog.cpp b/deps/libui/windows/fontdialog.cpp similarity index 100% rename from deps/libui/win32/fontdialog.cpp rename to deps/libui/windows/fontdialog.cpp diff --git a/deps/libui/win32/form.cpp b/deps/libui/windows/form.cpp similarity index 100% rename from deps/libui/win32/form.cpp rename to deps/libui/windows/form.cpp diff --git a/deps/libui/win32/graphemes.cpp b/deps/libui/windows/graphemes.cpp similarity index 100% rename from deps/libui/win32/graphemes.cpp rename to deps/libui/windows/graphemes.cpp diff --git a/deps/libui/win32/grid.cpp b/deps/libui/windows/grid.cpp similarity index 100% rename from deps/libui/win32/grid.cpp rename to deps/libui/windows/grid.cpp diff --git a/deps/libui/win32/group.cpp b/deps/libui/windows/group.cpp similarity index 100% rename from deps/libui/win32/group.cpp rename to deps/libui/windows/group.cpp diff --git a/deps/libui/win32/init.cpp b/deps/libui/windows/init.cpp similarity index 80% rename from deps/libui/win32/init.cpp rename to deps/libui/windows/init.cpp index a8a7ce05c0..228741653c 100644 --- a/deps/libui/win32/init.cpp +++ b/deps/libui/windows/init.cpp @@ -1,6 +1,5 @@ // 6 april 2015 #include "uipriv_windows.hpp" -#include "../../verbosity.h" HINSTANCE hInstance; int nCmdShow; @@ -75,107 +74,61 @@ const char *uiInit(uiInitOptions *o) hDefaultIcon = LoadIconW(NULL, IDI_APPLICATION); if (hDefaultIcon == NULL) - { - RARCH_ERR("error loading default icon for window classes\n"); return ieLastErr("loading default icon for window classes"); - } hDefaultCursor = LoadCursorW(NULL, IDC_ARROW); if (hDefaultCursor == NULL) - { - RARCH_ERR("error loading default cursor for window classes\n"); return ieLastErr("loading default cursor for window classes"); - } - RARCH_LOG("Initializing initUtilWindow.\n"); ce = initUtilWindow(hDefaultIcon, hDefaultCursor); if (ce != NULL) - { - RARCH_ERR("Failed initializing util window.\n"); return initerr(ce, L"GetLastError() ==", GetLastError()); - } if (registerWindowClass(hDefaultIcon, hDefaultCursor) == 0) - { - RARCH_ERR("failed registering uiWindow window class.\n"); return ieLastErr("registering uiWindow window class"); - } ZeroMemory(&ncm, sizeof (NONCLIENTMETRICSW)); ncm.cbSize = sizeof (NONCLIENTMETRICSW); if (SystemParametersInfoW(SPI_GETNONCLIENTMETRICS, sizeof (NONCLIENTMETRICSW), &ncm, sizeof (NONCLIENTMETRICSW)) == 0) - { - RARCH_ERR("Error getting default fonts.\n"); return ieLastErr("getting default fonts"); - } hMessageFont = CreateFontIndirectW(&(ncm.lfMessageFont)); if (hMessageFont == NULL) - { - RARCH_ERR("loading default messagebox font; this is the default UI font\n"); return ieLastErr("loading default messagebox font; this is the default UI font"); - } if (initContainer(hDefaultIcon, hDefaultCursor) == 0) - { - RARCH_ERR("initializing uiWindowsMakeContainer() window class\n"); return ieLastErr("initializing uiWindowsMakeContainer() window class"); - } hollowBrush = (HBRUSH) GetStockObject(HOLLOW_BRUSH); if (hollowBrush == NULL) - { - RARCH_ERR("getting hollow brush\n"); return ieLastErr("getting hollow brush"); - } ZeroMemory(&icc, sizeof (INITCOMMONCONTROLSEX)); icc.dwSize = sizeof (INITCOMMONCONTROLSEX); icc.dwICC = wantedICCClasses; if (InitCommonControlsEx(&icc) == 0) - { - RARCH_ERR("initializing Common Controls\n"); return ieLastErr("initializing Common Controls"); - } hr = CoInitialize(NULL); if (hr != S_OK && hr != S_FALSE) - { - RARCH_ERR("initializing COM\n"); return ieHRESULT("initializing COM", hr); - } // LONGTERM initialize COM security // LONGTERM (windows vista) turn off COM exception handling hr = initDraw(); if (hr != S_OK) - { - RARCH_ERR("initializing Direct2D\n"); return ieHRESULT("initializing Direct2D", hr); - } hr = initDrawText(); if (hr != S_OK) - { - RARCH_ERR("initializing DirectWrite\n"); return ieHRESULT("initializing DirectWrite", hr); - } if (registerAreaClass(hDefaultIcon, hDefaultCursor) == 0) - { - RARCH_ERR("registering uiArea window class\n"); return ieLastErr("registering uiArea window class"); - } if (registerMessageFilter() == 0) - { - RARCH_ERR("registering libui message filter\n"); return ieLastErr("registering libui message filter"); - } if (registerD2DScratchClass(hDefaultIcon, hDefaultCursor) == 0) - { - RARCH_ERR("initializing D2D scratch window class\n"); return ieLastErr("initializing D2D scratch window class"); - } return NULL; } @@ -205,3 +158,10 @@ void uiFreeInitError(const char *err) if (*(err - 1) == '-') uiFree((void *) (err - 1)); } + +BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) +{ + if (fdwReason == DLL_PROCESS_ATTACH) + hInstance = hinstDLL; + return TRUE; +} diff --git a/deps/libui/win32/label.cpp b/deps/libui/windows/label.cpp similarity index 100% rename from deps/libui/win32/label.cpp rename to deps/libui/windows/label.cpp diff --git a/deps/libui/win32/libui.manifest b/deps/libui/windows/libui.manifest similarity index 100% rename from deps/libui/win32/libui.manifest rename to deps/libui/windows/libui.manifest diff --git a/deps/libui/win32/main.cpp b/deps/libui/windows/main.cpp similarity index 100% rename from deps/libui/win32/main.cpp rename to deps/libui/windows/main.cpp diff --git a/deps/libui/win32/menu.cpp b/deps/libui/windows/menu.cpp similarity index 100% rename from deps/libui/win32/menu.cpp rename to deps/libui/windows/menu.cpp diff --git a/deps/libui/win32/multilineentry.cpp b/deps/libui/windows/multilineentry.cpp similarity index 100% rename from deps/libui/win32/multilineentry.cpp rename to deps/libui/windows/multilineentry.cpp diff --git a/deps/libui/win32/notes b/deps/libui/windows/notes similarity index 100% rename from deps/libui/win32/notes rename to deps/libui/windows/notes diff --git a/deps/libui/win32/parent.cpp b/deps/libui/windows/parent.cpp similarity index 52% rename from deps/libui/win32/parent.cpp rename to deps/libui/windows/parent.cpp index 6de8cda341..bde6fb94e4 100644 --- a/deps/libui/win32/parent.cpp +++ b/deps/libui/windows/parent.cpp @@ -1,26 +1,26 @@ -/* 26 april 2015 */ +// 26 april 2015 #include "uipriv_windows.hpp" -/* This contains code used by all uiControls that contain other controls. - * It also contains the code to draw the background of a container.c container, as that is a variant of the WM_CTLCOLORxxx handler code. */ +// This contains code used by all uiControls that contain other controls. +// It also contains the code to draw the background of a container.c container, as that is a variant of the WM_CTLCOLORxxx handler code. static HBRUSH parentBrush = NULL; static HWND parentWithBackground(HWND hwnd) { - int cls; - HWND parent = hwnd; + HWND parent; + int cls; - for (;;) - { - parent = parentOf(parent); - /* skip groupboxes; they're (supposed to be) transparent - * skip uiContainers; they don't draw anything */ - cls = windowClassOf(parent, L"button", containerClass, NULL); - if (cls != 0 && cls != 1) - break; - } - return parent; + parent = hwnd; + for (;;) { + parent = parentOf(parent); + // skip groupboxes; they're (supposed to be) transparent + // skip uiContainers; they don't draw anything + cls = windowClassOf(parent, L"button", containerClass, NULL); + if (cls != 0 && cls != 1) + break; + } + return parent; } struct parentDraw { @@ -49,7 +49,7 @@ static HRESULT parentDraw(HDC dc, HWND parent, struct parentDraw *pd) static void endParentDraw(struct parentDraw *pd) { - /* continue in case of any error */ + // continue in case of any error if (pd->prevbitmap != NULL) if (((HBITMAP) SelectObject(pd->cdc, pd->prevbitmap)) != pd->bitmap) logLastError(L"error selecting previous bitmap back into compatible DC"); @@ -61,7 +61,7 @@ static void endParentDraw(struct parentDraw *pd) logLastError(L"error deleting compatible DC"); } -/* see http://www.codeproject.com/Articles/5978/Correctly-drawn-themed-dialogs-in-WinXP */ +// see http://www.codeproject.com/Articles/5978/Correctly-drawn-themed-dialogs-in-WinXP static HBRUSH getControlBackgroundBrush(HWND hwnd, HDC dc) { HWND parent; @@ -83,11 +83,10 @@ static HBRUSH getControlBackgroundBrush(HWND hwnd, HDC dc) } endParentDraw(&pd); - /* now figure out where the control is relative to the parent - * so we can align the brush properly - * if anything fails, give up and return the brush as-is */ + // now figure out where the control is relative to the parent so we can align the brush properly + // if anything fails, give up and return the brush as-is uiWindowsEnsureGetWindowRect(hwnd, &hwndScreenRect); - /* this will be in screen coordinates; convert to parent coordinates */ + // this will be in screen coordinates; convert to parent coordinates mapWindowRect(NULL, parent, &hwndScreenRect); if (SetBrushOrgEx(dc, -hwndScreenRect.left, -hwndScreenRect.top, NULL) == 0) logLastError(L"error setting brush origin"); @@ -97,18 +96,19 @@ static HBRUSH getControlBackgroundBrush(HWND hwnd, HDC dc) void paintContainerBackground(HWND hwnd, HDC dc, RECT *paintRect) { + HWND parent; RECT paintRectParent; struct parentDraw pd; - HWND parent = parentWithBackground(hwnd); - HRESULT hr = parentDraw(dc, parent, &pd); + HRESULT hr; - if (hr != S_OK) /* we couldn't get it; draw nothing */ + parent = parentWithBackground(hwnd); + hr = parentDraw(dc, parent, &pd); + if (hr != S_OK) // we couldn't get it; draw nothing return; paintRectParent = *paintRect; mapWindowRect(hwnd, parent, &paintRectParent); - if (BitBlt(dc, paintRect->left, paintRect->top, - paintRect->right - paintRect->left, paintRect->bottom - paintRect->top, + if (BitBlt(dc, paintRect->left, paintRect->top, paintRect->right - paintRect->left, paintRect->bottom - paintRect->top, pd.cdc, paintRectParent.left, paintRectParent.top, SRCCOPY) == 0) logLastError(L"error drawing parent background over uiContainer"); @@ -116,31 +116,29 @@ void paintContainerBackground(HWND hwnd, HDC dc, RECT *paintRect) endParentDraw(&pd); } -/* TODO make this public if we want custom containers - * why have this to begin with? http://blogs.msdn.com/b/oldnewthing/archive/2010/03/16/9979112.aspx */ +// TODO make this public if we want custom containers +// why have this to begin with? http://blogs.msdn.com/b/oldnewthing/archive/2010/03/16/9979112.aspx BOOL handleParentMessages(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *lResult) { - switch (uMsg) - { - case WM_COMMAND: - return runWM_COMMAND(wParam, lParam, lResult); - case WM_NOTIFY: - return runWM_NOTIFY(wParam, lParam, lResult); - case WM_HSCROLL: - return runWM_HSCROLL(wParam, lParam, lResult); - case WM_CTLCOLORSTATIC: - case WM_CTLCOLORBTN: - if (parentBrush != NULL) - if (DeleteObject(parentBrush) == 0) - logLastError(L"error deleting old background brush()"); /* but continue anyway; we will leak a brush but whatever */ - if (SetBkMode((HDC) wParam, TRANSPARENT) == 0) - logLastError(L"error setting transparent background mode to controls"); /* but continue anyway; text will be wrong */ - parentBrush = getControlBackgroundBrush((HWND) lParam, (HDC) wParam); - if (parentBrush == NULL) /* failed; just do default behavior */ - return FALSE; - *lResult = (LRESULT) parentBrush; - return TRUE; - } - - return FALSE; + switch (uMsg) { + case WM_COMMAND: + return runWM_COMMAND(wParam, lParam, lResult); + case WM_NOTIFY: + return runWM_NOTIFY(wParam, lParam, lResult); + case WM_HSCROLL: + return runWM_HSCROLL(wParam, lParam, lResult); + case WM_CTLCOLORSTATIC: + case WM_CTLCOLORBTN: + if (parentBrush != NULL) + if (DeleteObject(parentBrush) == 0) + logLastError(L"error deleting old background brush()"); // but continue anyway; we will leak a brush but whatever + if (SetBkMode((HDC) wParam, TRANSPARENT) == 0) + logLastError(L"error setting transparent background mode to controls"); // but continue anyway; text will be wrong + parentBrush = getControlBackgroundBrush((HWND) lParam, (HDC) wParam); + if (parentBrush == NULL) // failed; just do default behavior + return FALSE; + *lResult = (LRESULT) parentBrush; + return TRUE; + } + return FALSE; } diff --git a/deps/libui/win32/progressbar.cpp b/deps/libui/windows/progressbar.cpp similarity index 100% rename from deps/libui/win32/progressbar.cpp rename to deps/libui/windows/progressbar.cpp diff --git a/deps/libui/win32/radiobuttons.cpp b/deps/libui/windows/radiobuttons.cpp similarity index 100% rename from deps/libui/win32/radiobuttons.cpp rename to deps/libui/windows/radiobuttons.cpp diff --git a/deps/libui/win32/resources.hpp b/deps/libui/windows/resources.hpp similarity index 100% rename from deps/libui/win32/resources.hpp rename to deps/libui/windows/resources.hpp diff --git a/deps/libui/win32/resources.rc b/deps/libui/windows/resources.rc similarity index 100% rename from deps/libui/win32/resources.rc rename to deps/libui/windows/resources.rc diff --git a/deps/libui/win32/separator.cpp b/deps/libui/windows/separator.cpp similarity index 100% rename from deps/libui/win32/separator.cpp rename to deps/libui/windows/separator.cpp diff --git a/deps/libui/win32/sizing.cpp b/deps/libui/windows/sizing.cpp similarity index 100% rename from deps/libui/win32/sizing.cpp rename to deps/libui/windows/sizing.cpp diff --git a/deps/libui/win32/slider.cpp b/deps/libui/windows/slider.cpp similarity index 96% rename from deps/libui/win32/slider.cpp rename to deps/libui/windows/slider.cpp index b388ebc635..5c671dda09 100644 --- a/deps/libui/win32/slider.cpp +++ b/deps/libui/windows/slider.cpp @@ -1,10 +1,6 @@ // 20 may 2015 #include "uipriv_windows.hpp" -#ifndef TBS_TRANSPARENTBKGND -#define TBS_TRANSPARENTBKGND 0x1000 -#endif - struct uiSlider { uiWindowsControl c; HWND hwnd; diff --git a/deps/libui/win32/spinbox.cpp b/deps/libui/windows/spinbox.cpp similarity index 100% rename from deps/libui/win32/spinbox.cpp rename to deps/libui/windows/spinbox.cpp diff --git a/deps/libui/win32/stddialogs.cpp b/deps/libui/windows/stddialogs.cpp similarity index 69% rename from deps/libui/win32/stddialogs.cpp rename to deps/libui/windows/stddialogs.cpp index 07678542c0..89d26bacd7 100644 --- a/deps/libui/win32/stddialogs.cpp +++ b/deps/libui/windows/stddialogs.cpp @@ -1,26 +1,18 @@ -/* 22 may 2015 */ -#include +// 22 may 2015 #include "uipriv_windows.hpp" -#ifndef _MSC_VER -#include "winextra.h" -#endif -static dylib_t comctl_dll_handle = NULL; /* Handle to Comctl32 */ +// TODO document all this is what we want +// TODO do the same for font and color buttons -/* - * TODO document all this is what we want - * TODO do the same for font and color buttons +// notes: +// - FOS_SUPPORTSTREAMABLEITEMS doesn't seem to be supported on windows vista, or at least not with the flags we use +// - even with FOS_NOVALIDATE the dialogs will reject invalid filenames (at least on Vista, anyway) +// - lack of FOS_NOREADONLYRETURN doesn't seem to matter on Windows 7 - * notes: - * - FOS_SUPPORTSTREAMABLEITEMS doesn't seem to be supported on windows vista, or at least not with the flags we use - * - even with FOS_NOVALIDATE the dialogs will reject invalid filenames (at least on Vista, anyway) - * - lack of FOS_NOREADONLYRETURN doesn't seem to matter on Windows 7 - - * TODO - * - http://blogs.msdn.com/b/wpfsdk/archive/2006/10/26/uncommon-dialogs--font-chooser-and-color-picker-dialogs.aspx - * - when a dialog is active, tab navigation in other windows stops working - * - when adding uiOpenFolder(), use IFileDialog as well - https://msdn.microsoft.com/en-us/library/windows/desktop/bb762115%28v=vs.85%29.aspx - */ +// TODO +// - http://blogs.msdn.com/b/wpfsdk/archive/2006/10/26/uncommon-dialogs--font-chooser-and-color-picker-dialogs.aspx +// - when a dialog is active, tab navigation in other windows stops working +// - when adding uiOpenFolder(), use IFileDialog as well - https://msdn.microsoft.com/en-us/library/windows/desktop/bb762115%28v=vs.85%29.aspx #define windowHWND(w) ((HWND) uiControlHandle(uiControl(w))) @@ -109,28 +101,19 @@ char *uiSaveFile(uiWindow *parent) } // TODO switch to TaskDialogIndirect()? -typedef HRESULT (WINAPI *TaskDialogProc)(HWND hwndParent,HINSTANCE hInstance,PCWSTR pszWindowTitle,PCWSTR pszMainInstruction,PCWSTR pszContent,TASKDIALOG_COMMON_BUTTON_FLAGS dwCommonButtons,PCWSTR pszIcon,int *pnButton); -static TaskDialogProc task_dialog_proc; -static void msgbox(HWND parent, const char *title, const char *description, - TASKDIALOG_COMMON_BUTTON_FLAGS buttons, PCWSTR icon) +static void msgbox(HWND parent, const char *title, const char *description, TASKDIALOG_COMMON_BUTTON_FLAGS buttons, PCWSTR icon) { - HRESULT hr = E_FAIL; - WCHAR *wtitle = toUTF16(title); - WCHAR *wdescription = toUTF16(description); + WCHAR *wtitle, *wdescription; + HRESULT hr; - comctl_dll_handle = dylib_load("comctl32.lib"); - - task_dialog_proc = (TaskDialogProc)GetProcAddress((HINSTANCE)comctl_dll_handle, "TaskDialog"); - - if (task_dialog_proc) - hr = task_dialog_proc(parent, NULL, NULL, wtitle, wdescription, buttons, icon, NULL); + wtitle = toUTF16(title); + wdescription = toUTF16(description); + hr = TaskDialog(parent, NULL, NULL, wtitle, wdescription, buttons, icon, NULL); if (hr != S_OK) logHRESULT(L"error showing task dialog", hr); - dylib_close(comctl_dll_handle); - uiFree(wdescription); uiFree(wtitle); } diff --git a/deps/libui/win32/tab.cpp b/deps/libui/windows/tab.cpp similarity index 74% rename from deps/libui/win32/tab.cpp rename to deps/libui/windows/tab.cpp index 505b504926..365f5a1fa9 100644 --- a/deps/libui/win32/tab.cpp +++ b/deps/libui/windows/tab.cpp @@ -1,18 +1,18 @@ -/* 16 may 2015 */ +// 16 may 2015 #include "uipriv_windows.hpp" -/* You don't add controls directly to a tab control on Windows; instead you make them siblings and swap between them on a TCN_SELCHANGING/TCN_SELCHANGE notification pair. - * In addition, you use dialogs because they can be textured properly; other controls cannot. (Things will look wrong if the tab background in the current theme is fancy if you just use the tab background by itself; see http://stackoverflow.com/questions/30087540/why-are-my-programss-tab-controls-rendering-their-background-in-a-blocky-way-b.) */ +// You don't add controls directly to a tab control on Windows; instead you make them siblings and swap between them on a TCN_SELCHANGING/TCN_SELCHANGE notification pair. +// In addition, you use dialogs because they can be textured properly; other controls cannot. (Things will look wrong if the tab background in the current theme is fancy if you just use the tab background by itself; see http://stackoverflow.com/questions/30087540/why-are-my-programss-tab-controls-rendering-their-background-in-a-blocky-way-b.) struct uiTab { uiWindowsControl c; - HWND hwnd; /* of the outer container */ - HWND tabHWND; /* of the tab control itself */ + HWND hwnd; // of the outer container + HWND tabHWND; // of the tab control itself std::vector *pages; HWND parent; }; -/* utility functions */ +// utility functions static LRESULT curpage(uiTab *t) { @@ -26,14 +26,11 @@ static struct tabPage *tabPage(uiTab *t, int i) static void tabPageRect(uiTab *t, RECT *r) { - /* this rect needs to be in parent window coordinates, but TCM_ADJUSTRECT - * wants a window rect, which is screen coordinates - * because we have each page as a sibling of the tab, use the tab's - * own rect as the input rect */ + // this rect needs to be in parent window coordinates, but TCM_ADJUSTRECT wants a window rect, which is screen coordinates + // because we have each page as a sibling of the tab, use the tab's own rect as the input rect uiWindowsEnsureGetWindowRect(t->tabHWND, r); SendMessageW(t->tabHWND, TCM_ADJUSTRECT, (WPARAM) FALSE, (LPARAM) r); - - /* and get it in terms of the container instead of the screen */ + // and get it in terms of the container instead of the screen mapWindowRect(NULL, t->hwnd, r); } @@ -42,11 +39,11 @@ static void tabRelayout(uiTab *t) struct tabPage *page; RECT r; - /* first move the tab control itself */ + // first move the tab control itself uiWindowsEnsureGetClientRect(t->hwnd, &r); uiWindowsEnsureMoveWindowDuringResize(t->tabHWND, r.left, r.top, r.right - r.left, r.bottom - r.top); - /* then the current page */ + // then the current page if (t->pages->size() == 0) return; page = tabPage(t, curpage(t)); @@ -56,22 +53,21 @@ static void tabRelayout(uiTab *t) static void showHidePage(uiTab *t, LRESULT which, int hide) { - struct tabPage *page = NULL; + struct tabPage *page; if (which == (LRESULT) (-1)) return; page = tabPage(t, which); if (hide) ShowWindow(page->hwnd, SW_HIDE); - else - { - ShowWindow(page->hwnd, SW_SHOW); - /* we only resize the current page, so we have to resize it; before we can do that, we need to make sure we are of the right size */ - uiWindowsControlMinimumSizeChanged(uiWindowsControl(t)); - } + else { + ShowWindow(page->hwnd, SW_SHOW); + // we only resize the current page, so we have to resize it; before we can do that, we need to make sure we are of the right size + uiWindowsControlMinimumSizeChanged(uiWindowsControl(t)); + } } -/* control implementation */ +// control implementation static BOOL onWM_NOTIFY(uiControl *c, HWND hwnd, NMHDR *nm, LRESULT *lResult) { @@ -133,23 +129,22 @@ uiWindowsControlDefaultSetParentHWND(uiTab) static void uiTabMinimumSize(uiWindowsControl *c, int *width, int *height) { + uiTab *t = uiTab(c); + int pagewid, pageht; + struct tabPage *page; RECT r; - struct tabPage *page = NULL; - uiTab *t = uiTab(c); - /* only consider the current page */ - int pagewid = 0; - int pageht = 0; - - if (t->pages->size() != 0) - { + // only consider the current page + pagewid = 0; + pageht = 0; + if (t->pages->size() != 0) { page = tabPage(t, curpage(t)); tabPageMinimumSize(page, &pagewid, &pageht); } - r.left = 0; - r.top = 0; - r.right = pagewid; + r.left = 0; + r.top = 0; + r.right = pagewid; r.bottom = pageht; // this also includes the tabs themselves SendMessageW(t->tabHWND, TCM_ADJUSTRECT, (WPARAM) TRUE, (LPARAM) (&r)); @@ -159,14 +154,13 @@ static void uiTabMinimumSize(uiWindowsControl *c, int *width, int *height) static void uiTabMinimumSizeChanged(uiWindowsControl *c) { - uiTab *t = uiTab(c); + uiTab *t = uiTab(c); - if (uiWindowsControlTooSmall(uiWindowsControl(t))) - { - uiWindowsControlContinueMinimumSizeChanged(uiWindowsControl(t)); - return; - } - tabRelayout(t); + if (uiWindowsControlTooSmall(uiWindowsControl(t))) { + uiWindowsControlContinueMinimumSizeChanged(uiWindowsControl(t)); + return; + } + tabRelayout(t); } uiWindowsControlDefaultLayoutRect(uiTab) @@ -174,16 +168,16 @@ uiWindowsControlDefaultAssignControlIDZOrder(uiTab) static void uiTabChildVisibilityChanged(uiWindowsControl *c) { - /* TODO eliminate the redundancy */ + // TODO eliminate the redundancy uiWindowsControlMinimumSizeChanged(c); } static void tabArrangePages(uiTab *t) { LONG_PTR controlID = 100; - HWND insertAfter = NULL; + HWND insertAfter = NULL; - /* TODO is this first or last? */ + // TODO is this first or last? uiWindowsEnsureAssignControlIDZOrder(t->tabHWND, &controlID, &insertAfter); for (struct tabPage *&page : *(t->pages)) uiWindowsEnsureAssignControlIDZOrder(page->hwnd, &controlID, &insertAfter); @@ -197,11 +191,12 @@ void uiTabAppend(uiTab *t, const char *name, uiControl *child) void uiTabInsertAt(uiTab *t, const char *name, int n, uiControl *child) { struct tabPage *page; - LRESULT show; + LRESULT hide, show; TCITEMW item; WCHAR *wname; - /* see below */ - LRESULT hide = curpage(t); + + // see below + hide = curpage(t); if (child != NULL) uiControlSetParent(child, uiControl(t)); @@ -219,12 +214,9 @@ void uiTabInsertAt(uiTab *t, const char *name, int n, uiControl *child) logLastError(L"error adding tab to uiTab"); uiFree(wname); - /* we need to do this because adding the first tab - * doesn't send a TCN_SELCHANGE; it just shows the page */ + // we need to do this because adding the first tab doesn't send a TCN_SELCHANGE; it just shows the page show = curpage(t); - - if (show != hide) - { + if (show != hide) { showHidePage(t, hide, 1); showHidePage(t, show, 0); } @@ -234,12 +226,12 @@ void uiTabDelete(uiTab *t, int n) { struct tabPage *page; - /* first delete the tab from the tab control - * if this is the current tab, no tab will be selected, which is good */ + // first delete the tab from the tab control + // if this is the current tab, no tab will be selected, which is good if (SendMessageW(t->tabHWND, TCM_DELETEITEM, (WPARAM) n, 0) == FALSE) logLastError(L"error deleting uiTab tab"); - /* now delete the page itself */ + // now delete the page itself page = tabPage(t, n); if (page->child != NULL) uiControlSetParent(page->child, NULL); @@ -259,13 +251,11 @@ int uiTabMargined(uiTab *t, int n) void uiTabSetMargined(uiTab *t, int n, int margined) { - struct tabPage *page = tabPage(t, n); + struct tabPage *page; + page = tabPage(t, n); page->margined = margined; - - /* even if the page doesn't have a child it might still - * have a new minimum size with margins; this is the - * easiest way to verify it */ + // even if the page doesn't have a child it might still have a new minimum size with margins; this is the easiest way to verify it uiWindowsControlMinimumSizeChanged(uiWindowsControl(t)); } diff --git a/deps/libui/win32/tabpage.cpp b/deps/libui/windows/tabpage.cpp similarity index 100% rename from deps/libui/win32/tabpage.cpp rename to deps/libui/windows/tabpage.cpp diff --git a/deps/libui/windows/text.cpp b/deps/libui/windows/text.cpp new file mode 100644 index 0000000000..af79fb8078 --- /dev/null +++ b/deps/libui/windows/text.cpp @@ -0,0 +1,107 @@ +// 9 april 2015 +#include "uipriv_windows.hpp" + +WCHAR *windowTextAndLen(HWND hwnd, LRESULT *len) +{ + LRESULT n; + WCHAR *text; + + n = SendMessageW(hwnd, WM_GETTEXTLENGTH, 0, 0); + if (len != NULL) + *len = n; + // WM_GETTEXTLENGTH does not include the null terminator + text = (WCHAR *) uiAlloc((n + 1) * sizeof (WCHAR), "WCHAR[]"); + // note the comparison: the size includes the null terminator, but the return does not + if (GetWindowTextW(hwnd, text, n + 1) != n) { + logLastError(L"error getting window text"); + // on error, return an empty string to be safe + *text = L'\0'; + if (len != NULL) + *len = 0; + } + return text; +} + +WCHAR *windowText(HWND hwnd) +{ + return windowTextAndLen(hwnd, NULL); +} + +void setWindowText(HWND hwnd, WCHAR *wtext) +{ + if (SetWindowTextW(hwnd, wtext) == 0) + logLastError(L"error setting window text"); +} + +void uiFreeText(char *text) +{ + uiFree(text); +} + +int uiWindowsWindowTextWidth(HWND hwnd) +{ + LRESULT len; + WCHAR *text; + HDC dc; + HFONT prevfont; + SIZE size; + + size.cx = 0; + size.cy = 0; + + text = windowTextAndLen(hwnd, &len); + if (len == 0) // no text; nothing to do + goto noTextOrError; + + // now we can do the calculations + dc = GetDC(hwnd); + if (dc == NULL) { + logLastError(L"error getting DC"); + // on any error, assume no text + goto noTextOrError; + } + prevfont = (HFONT) SelectObject(dc, hMessageFont); + if (prevfont == NULL) { + logLastError(L"error loading control font into device context"); + ReleaseDC(hwnd, dc); + goto noTextOrError; + } + if (GetTextExtentPoint32W(dc, text, len, &size) == 0) { + logLastError(L"error getting text extent point"); + // continue anyway, assuming size is 0 + size.cx = 0; + size.cy = 0; + } + // continue on errors; we got what we want + if (SelectObject(dc, prevfont) != hMessageFont) + logLastError(L"error restoring previous font into device context"); + if (ReleaseDC(hwnd, dc) == 0) + logLastError(L"error releasing DC"); + + uiFree(text); + return size.cx; + +noTextOrError: + uiFree(text); + return 0; +} + +char *uiWindowsWindowText(HWND hwnd) +{ + WCHAR *wtext; + char *text; + + wtext = windowText(hwnd); + text = toUTF8(wtext); + uiFree(wtext); + return text; +} + +void uiWindowsSetWindowText(HWND hwnd, const char *text) +{ + WCHAR *wtext; + + wtext = toUTF16(text); + setWindowText(hwnd, wtext); + uiFree(wtext); +} diff --git a/deps/libui/win32/uipriv_windows.hpp b/deps/libui/windows/uipriv_windows.hpp similarity index 97% rename from deps/libui/win32/uipriv_windows.hpp rename to deps/libui/windows/uipriv_windows.hpp index 8235dd529f..6ffe09f1ad 100644 --- a/deps/libui/win32/uipriv_windows.hpp +++ b/deps/libui/windows/uipriv_windows.hpp @@ -1,4 +1,4 @@ -/* 21 april 2016 */ +// 21 april 2016 #include "winapi.hpp" #include "../ui.h" #include "../ui_windows.h" @@ -6,15 +6,15 @@ #include "resources.hpp" #include "compilerver.hpp" -/* ui internal window messages */ +// ui internal window messages enum { - /* redirected WM_COMMAND and WM_NOTIFY */ + // redirected WM_COMMAND and WM_NOTIFY msgCOMMAND = WM_APP + 0x40, // start offset just to be safe msgNOTIFY, msgHSCROLL, msgQueued, msgD2DScratchPaint, - msgD2DScratchLButtonDown + msgD2DScratchLButtonDown, }; // alloc.cpp diff --git a/deps/libui/win32/utf16.cpp b/deps/libui/windows/utf16.cpp similarity index 61% rename from deps/libui/win32/utf16.cpp rename to deps/libui/windows/utf16.cpp index 1ae7e13489..98954d0ada 100644 --- a/deps/libui/win32/utf16.cpp +++ b/deps/libui/windows/utf16.cpp @@ -1,7 +1,7 @@ -/* 21 april 2016 */ +// 21 april 2016 #include "uipriv_windows.hpp" -/* see http://stackoverflow.com/a/29556509/3408572 */ +// see http://stackoverflow.com/a/29556509/3408572 #define MBTWC(str, wstr, bufsiz) MultiByteToWideChar(CP_UTF8, 0, str, -1, wstr, bufsiz) @@ -18,10 +18,9 @@ WCHAR *toUTF16(const char *str) return emptyUTF16(); } wstr = (WCHAR *) uiAlloc(n * sizeof (WCHAR), "WCHAR[]"); - if (MBTWC(str, wstr, n) != n) - { + if (MBTWC(str, wstr, n) != n) { logLastError(L"error converting from UTF-8 to UTF-16"); - /* and return an empty string */ + // and return an empty string *wstr = L'\0'; } return wstr; @@ -34,7 +33,7 @@ char *toUTF8(const WCHAR *wstr) char *str; int n; - if (*wstr == L'\0') /* empty string */ + if (*wstr == L'\0') // empty string return emptyUTF8(); n = WCTMB(wstr, NULL, 0); if (n == 0) { @@ -42,20 +41,21 @@ char *toUTF8(const WCHAR *wstr) return emptyUTF8(); } str = (char *) uiAlloc(n * sizeof (char), "char[]"); - if (WCTMB(wstr, str, n) != n) - { - logLastError(L"error converting from UTF-16 to UTF-8"); - /* and return an empty string */ - *str = '\0'; - } + if (WCTMB(wstr, str, n) != n) { + logLastError(L"error converting from UTF-16 to UTF-8"); + // and return an empty string + *str = '\0'; + } return str; } WCHAR *utf16dup(const WCHAR *orig) { - size_t len = wcslen(orig); - WCHAR *out = (WCHAR *) uiAlloc((len + 1) * sizeof (WCHAR), "WCHAR[]"); + WCHAR *out; + size_t len; + len = wcslen(orig); + out = (WCHAR *) uiAlloc((len + 1) * sizeof (WCHAR), "WCHAR[]"); wcscpy_s(out, len + 1, orig); return out; } @@ -83,27 +83,27 @@ WCHAR *vstrf(const WCHAR *format, va_list ap) va_copy(ap2, ap); n = _vscwprintf(format, ap2); va_end(ap2); - n++; /* terminating L'\0' */ + n++; // terminating L'\0' buf = (WCHAR *) uiAlloc(n * sizeof (WCHAR), "WCHAR[]"); - /* includes terminating L'\0' according - * to example in https://msdn.microsoft.com/en-us/library/xa1a1a6z.aspx */ + // includes terminating L'\0' according to example in https://msdn.microsoft.com/en-us/library/xa1a1a6z.aspx vswprintf_s(buf, n, format, ap); return buf; } -/* Let's shove these utility routines here too. - * Prerequisite: lfonly is UTF-8. */ +// Let's shove these utility routines here too. +// Prerequisite: lfonly is UTF-8. char *LFtoCRLF(const char *lfonly) { - size_t i; - size_t len = strlen(lfonly); - char *crlf = (char *) uiAlloc((len * 2 + 1) * sizeof (char), "char[]"); - char *out = crlf; + char *crlf; + size_t i, len; + char *out; - for (i = 0; i < len; i++) - { + len = strlen(lfonly); + crlf = (char *) uiAlloc((len * 2 + 1) * sizeof (char), "char[]"); + out = crlf; + for (i = 0; i < len; i++) { if (*lfonly == '\n') *crlf++ = '\r'; *crlf++ = *lfonly++; @@ -112,43 +112,42 @@ char *LFtoCRLF(const char *lfonly) return out; } -/* Prerequisite: s is UTF-8. */ +// Prerequisite: s is UTF-8. void CRLFtoLF(char *s) { char *t = s; - for (; *s != '\0'; s++) - { - /* be sure to preserve \rs that are genuinely there */ + for (; *s != '\0'; s++) { + // be sure to preserve \rs that are genuinely there if (*s == '\r' && *(s + 1) == '\n') continue; *t++ = *s; } *t = '\0'; - /* pad out the rest of t, just to be safe */ + // pad out the rest of t, just to be safe while (t != s) *t++ = '\0'; } -/* std::to_string() always uses %f; we want %g - * fortunately std::iostream seems to use %g by default so */ +// std::to_string() always uses %f; we want %g +// fortunately std::iostream seems to use %g by default so WCHAR *ftoutf16(double d) { std::wostringstream ss; std::wstring s; ss << d; - s = ss.str(); /* to be safe */ + s = ss.str(); // to be safe return utf16dup(s.c_str()); } -/* to complement the above */ +// to complement the above WCHAR *itoutf16(int i) { std::wostringstream ss; std::wstring s; ss << i; - s = ss.str(); /* to be safe */ + s = ss.str(); // to be safe return utf16dup(s.c_str()); } diff --git a/deps/libui/windows/utilwin.cpp b/deps/libui/windows/utilwin.cpp new file mode 100644 index 0000000000..414ae83aba --- /dev/null +++ b/deps/libui/windows/utilwin.cpp @@ -0,0 +1,76 @@ +// 14 may 2015 +#include "uipriv_windows.hpp" + +// The utility window is a special window that performs certain tasks internal to libui. +// It is not a message-only window, and it is always hidden and disabled. +// Its roles: +// - It is the initial parent of all controls. When a control loses its parent, it also becomes that control's parent. +// - It handles WM_QUERYENDSESSION and console end session requests. +// - It handles WM_WININICHANGE and forwards the message to any child windows that request it. +// - It handles executing functions queued to run by uiQueueMain(). + +#define utilWindowClass L"libui_utilWindowClass" + +HWND utilWindow; + +static LRESULT CALLBACK utilWindowWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + void (*qf)(void *); + LRESULT lResult; + + if (handleParentMessages(hwnd, uMsg, wParam, lParam, &lResult) != FALSE) + return lResult; + switch (uMsg) { + case WM_QUERYENDSESSION: + // TODO block handler + if (shouldQuit()) { + uiQuit(); + return TRUE; + } + return FALSE; + case WM_WININICHANGE: + issueWM_WININICHANGE(wParam, lParam); + return 0; + case msgQueued: + qf = (void (*)(void *)) wParam; + (*qf)((void *) lParam); + return 0; + } + return DefWindowProcW(hwnd, uMsg, wParam, lParam); +} + +const char *initUtilWindow(HICON hDefaultIcon, HCURSOR hDefaultCursor) +{ + WNDCLASSW wc; + + ZeroMemory(&wc, sizeof (WNDCLASSW)); + wc.lpszClassName = utilWindowClass; + wc.lpfnWndProc = utilWindowWndProc; + wc.hInstance = hInstance; + wc.hIcon = hDefaultIcon; + wc.hCursor = hDefaultCursor; + wc.hbrBackground = (HBRUSH) (COLOR_BTNFACE + 1); + if (RegisterClass(&wc) == 0) + // see init.cpp for an explanation of the =s + return "=registering utility window class"; + + utilWindow = CreateWindowExW(0, + utilWindowClass, L"libui utility window", + WS_OVERLAPPEDWINDOW, + 0, 0, 100, 100, + NULL, NULL, hInstance, NULL); + if (utilWindow == NULL) + return "=creating utility window"; + // and just to be safe + EnableWindow(utilWindow, FALSE); + + return NULL; +} + +void uninitUtilWindow(void) +{ + if (DestroyWindow(utilWindow) == 0) + logLastError(L"error destroying utility window"); + if (UnregisterClass(utilWindowClass, hInstance) == 0) + logLastError(L"error unregistering utility window class"); +} diff --git a/deps/libui/win32/winapi.hpp b/deps/libui/windows/winapi.hpp similarity index 100% rename from deps/libui/win32/winapi.hpp rename to deps/libui/windows/winapi.hpp diff --git a/deps/libui/win32/window.cpp b/deps/libui/windows/window.cpp similarity index 100% rename from deps/libui/win32/window.cpp rename to deps/libui/windows/window.cpp diff --git a/deps/libui/win32/winpublic.cpp b/deps/libui/windows/winpublic.cpp similarity index 63% rename from deps/libui/win32/winpublic.cpp rename to deps/libui/windows/winpublic.cpp index 1ef77f18f5..397a3b54c9 100644 --- a/deps/libui/win32/winpublic.cpp +++ b/deps/libui/windows/winpublic.cpp @@ -1,4 +1,4 @@ -/* 6 april 2015 */ +// 6 april 2015 #include "uipriv_windows.hpp" void uiWindowsEnsureDestroyWindow(HWND hwnd) @@ -35,30 +35,27 @@ void uiWindowsEnsureMoveWindowDuringResize(HWND hwnd, int x, int y, int width, i logLastError(L"error moving window"); } -/* do these function even error out in any case - * other than invalid parameters?! I thought all windows had rects */ +// do these function even error out in any case other than invalid parameters?! I thought all windows had rects void uiWindowsEnsureGetClientRect(HWND hwnd, RECT *r) { - if (GetClientRect(hwnd, r) == 0) - { - logLastError(L"error getting window client rect"); - /* zero out the rect on error just to be safe */ - r->left = 0; - r->top = 0; - r->right = 0; - r->bottom = 0; - } + if (GetClientRect(hwnd, r) == 0) { + logLastError(L"error getting window client rect"); + // zero out the rect on error just to be safe + r->left = 0; + r->top = 0; + r->right = 0; + r->bottom = 0; + } } void uiWindowsEnsureGetWindowRect(HWND hwnd, RECT *r) { - if (GetWindowRect(hwnd, r) == 0) - { - logLastError(L"error getting window rect"); - /* zero out the rect on error just to be safe */ - r->left = 0; - r->top = 0; - r->right = 0; - r->bottom = 0; - } + if (GetWindowRect(hwnd, r) == 0) { + logLastError(L"error getting window rect"); + // zero out the rect on error just to be safe + r->left = 0; + r->top = 0; + r->right = 0; + r->bottom = 0; + } } diff --git a/deps/libui/win32/winutil.cpp b/deps/libui/windows/winutil.cpp similarity index 100% rename from deps/libui/win32/winutil.cpp rename to deps/libui/windows/winutil.cpp diff --git a/dist-scripts/dist-cores.sh b/dist-scripts/dist-cores.sh index e2eb5d7096..285ef68570 100755 --- a/dist-scripts/dist-cores.sh +++ b/dist-scripts/dist-cores.sh @@ -1,6 +1,6 @@ #!/bin/sh -RARCH_VERSION=1.6.4 +RARCH_VERSION=1.6.5 PLATFORM=$1 SALAMANDER=no MAKEFILE_GRIFFIN=no diff --git a/frontend/drivers/platform_win32.c b/frontend/drivers/platform_win32.c index 2aa65eb10b..02ae1dd7d3 100644 --- a/frontend/drivers/platform_win32.c +++ b/frontend/drivers/platform_win32.c @@ -66,6 +66,7 @@ static void gfx_dwm_shutdown(void) static bool gfx_init_dwm(void) { + HRESULT (WINAPI *mmcss)(BOOL); static bool inited = false; if (inited) @@ -89,7 +90,7 @@ static bool gfx_init_dwm(void) DragAcceptFiles_func = (VOID (WINAPI*)(HWND, BOOL))dylib_proc(shell32lib, "DragAcceptFiles"); - HRESULT (WINAPI *mmcss)(BOOL) = + mmcss = (HRESULT (WINAPI*)(BOOL))dylib_proc(dwmlib, "DwmEnableMMCSS"); if (mmcss) { @@ -104,6 +105,7 @@ static bool gfx_init_dwm(void) static void gfx_set_dwm(void) { HRESULT ret; + HRESULT (WINAPI *composition_enable)(UINT); settings_t *settings = config_get_ptr(); if (!gfx_init_dwm()) @@ -112,7 +114,7 @@ static void gfx_set_dwm(void) if (settings->bools.video_disable_composition == dwm_composition_disabled) return; - HRESULT (WINAPI *composition_enable)(UINT) = + composition_enable = (HRESULT (WINAPI*)(UINT))dylib_proc(dwmlib, "DwmEnableComposition"); if (!composition_enable) { diff --git a/gfx/common/vulkan_common.c b/gfx/common/vulkan_common.c index b8f6c32fac..e2c64f2ffc 100644 --- a/gfx/common/vulkan_common.c +++ b/gfx/common/vulkan_common.c @@ -772,9 +772,12 @@ static void vulkan_check_dynamic_state( if (vk->tracker.dirty & VULKAN_DIRTY_DYNAMIC_BIT) { - const VkRect2D sci = { - { vk->vp.x, vk->vp.y }, - { vk->vp.width, vk->vp.height }}; + VkRect2D sci; + + sci.offset.x = vk->vp.x; + sci.offset.y = vk->vp.y; + sci.extent.width = vk->vp.width; + sci.extent.height = vk->vp.height; vkCmdSetViewport(vk->cmd, 0, 1, &vk->vk_vp); vkCmdSetScissor (vk->cmd, 0, 1, &sci); @@ -1144,8 +1147,15 @@ struct vk_buffer_chain vulkan_buffer_chain_init( VkDeviceSize alignment, VkBufferUsageFlags usage) { - struct vk_buffer_chain chain = { - block_size, alignment, 0, usage, NULL, NULL }; + struct vk_buffer_chain chain; + + chain.block_size = block_size; + chain.alignment = alignment; + chain.offset = 0; + chain.usage = usage; + chain.head = NULL; + chain.current = NULL; + return chain; } @@ -1487,12 +1497,13 @@ static bool vulkan_context_init_device(gfx_ctx_vulkan_data_t *vk) for (i = 0; i < queue_count; i++) { + VkQueueFlags required; VkBool32 supported = VK_FALSE; vkGetPhysicalDeviceSurfaceSupportKHR( vk->context.gpu, i, vk->vk_surface, &supported); - VkQueueFlags required = VK_QUEUE_GRAPHICS_BIT | VK_QUEUE_COMPUTE_BIT; + required = VK_QUEUE_GRAPHICS_BIT | VK_QUEUE_COMPUTE_BIT; if (supported && ((queue_properties[i].queueFlags & required) == required)) { vk->context.graphics_queue_index = i; @@ -1573,6 +1584,7 @@ bool vulkan_context_init(gfx_ctx_vulkan_data_t *vk, { unsigned i; VkResult res; + PFN_vkGetInstanceProcAddr GetInstanceProcAddr; VkInstanceCreateInfo info = { VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO }; VkApplicationInfo app = { VK_STRUCTURE_TYPE_APPLICATION_INFO }; @@ -1647,7 +1659,7 @@ bool vulkan_context_init(gfx_ctx_vulkan_data_t *vk, RARCH_LOG("Vulkan dynamic library loaded.\n"); - PFN_vkGetInstanceProcAddr GetInstanceProcAddr = + GetInstanceProcAddr = (PFN_vkGetInstanceProcAddr)dylib_proc(vulkan_library, "vkGetInstanceProcAddr"); if (!GetInstanceProcAddr) @@ -2018,10 +2030,11 @@ bool vulkan_surface_create(gfx_ctx_vulkan_data_t *vk, case VULKAN_WSI_WIN32: #ifdef _WIN32 { + VkWin32SurfaceCreateInfoKHR surf_info; PFN_vkCreateWin32SurfaceKHR create; + if (!VULKAN_SYMBOL_WRAPPER_LOAD_INSTANCE_SYMBOL(vk->context.instance, "vkCreateWin32SurfaceKHR", create)) return false; - VkWin32SurfaceCreateInfoKHR surf_info; memset(&surf_info, 0, sizeof(surf_info)); diff --git a/gfx/common/win32_common.c b/gfx/common/win32_common.c index cfeb717de2..cdb1249668 100644 --- a/gfx/common/win32_common.c +++ b/gfx/common/win32_common.c @@ -205,9 +205,12 @@ static BOOL CALLBACK win32_monitor_enum_proc(HMONITOR hMonitor, void win32_monitor_from_window(void) { #ifndef _XBOX + ui_window_t *window = NULL; + win32_monitor_last = MonitorFromWindow(main_window.hwnd, MONITOR_DEFAULTTONEAREST); - const ui_window_t *window = ui_companion_driver_get_window_ptr(); + + window = (ui_window_t*)ui_companion_driver_get_window_ptr(); if (window) window->destroy(&main_window); diff --git a/gfx/drivers/vulkan.c b/gfx/drivers/vulkan.c index 65732b7a95..01e4196e86 100644 --- a/gfx/drivers/vulkan.c +++ b/gfx/drivers/vulkan.c @@ -1194,12 +1194,12 @@ error: static void vulkan_update_filter_chain(vk_t *vk) { - const struct vulkan_filter_chain_swapchain_info info = { - vk->vk_vp, - vk->context->swapchain_format, - vk->render_pass, - vk->context->num_swapchain_images, - }; + struct vulkan_filter_chain_swapchain_info info; + + info.viewport = vk->vk_vp; + info.format = vk->context->swapchain_format; + info.render_pass = vk->render_pass; + info.num_indices = vk->context->num_swapchain_images; if (!vulkan_filter_chain_update_swapchain_info((vulkan_filter_chain_t*)vk->filter_chain, &info)) RARCH_ERR("Failed to update filter chain info. This will probably lead to a crash ...\n"); @@ -1346,9 +1346,10 @@ static void vulkan_set_video_mode(void *data, unsigned width, unsigned height, bool fullscreen) { - (void)data; gfx_ctx_mode_t mode; + (void)data; + mode.width = width; mode.height = height; mode.fullscreen = fullscreen; diff --git a/gfx/drivers_context/gdi_ctx.c b/gfx/drivers_context/gdi_ctx.c index 3773a6d1c8..9721530311 100644 --- a/gfx/drivers_context/gdi_ctx.c +++ b/gfx/drivers_context/gdi_ctx.c @@ -19,7 +19,7 @@ /* necessary for mingw32 multimon defines: */ #ifndef _WIN32_WINNT -#define _WIN32_WINNT 0x0500 //_WIN32_WINNT_WIN2K +#define _WIN32_WINNT 0x0500 /*_WIN32_WINNT_WIN2K */ #endif #include @@ -104,9 +104,10 @@ static void gfx_ctx_gdi_update_window_title(void *data, void *data2) static void gfx_ctx_gdi_get_video_size(void *data, unsigned *width, unsigned *height) { - (void)data; HWND window = win32_get_window(); + (void)data; + if (!window) { RECT mon_rect; @@ -219,9 +220,10 @@ static void gfx_ctx_gdi_input_driver(void *data, const char *joypad_name, const input_driver_t **input, void **input_data) { - (void)data; settings_t *settings = config_get_ptr(); + (void)data; + #if _WIN32_WINNT >= 0x0501 /* winraw only available since XP */ if (string_is_equal_fast(settings->arrays.input_driver, "raw", 4)) diff --git a/gfx/drivers_context/khr_display_ctx.c b/gfx/drivers_context/khr_display_ctx.c index fd69cb1620..745d770055 100644 --- a/gfx/drivers_context/khr_display_ctx.c +++ b/gfx/drivers_context/khr_display_ctx.c @@ -113,6 +113,7 @@ static bool gfx_ctx_khr_display_set_video_mode(void *data, unsigned width, unsigned height, bool fullscreen) { + struct vulkan_display_surface_info info; khr_display_ctx_data_t *khr = (khr_display_ctx_data_t*)data; if (!fullscreen) @@ -121,7 +122,9 @@ static bool gfx_ctx_khr_display_set_video_mode(void *data, height = 0; } - struct vulkan_display_surface_info info = { width, height }; + info.width = width; + info.height = height; + if (!vulkan_surface_create(&khr->vk, VULKAN_WSI_DISPLAY, &info, NULL, 0, 0, khr->swap_interval)) { diff --git a/gfx/drivers_context/wgl_ctx.c b/gfx/drivers_context/wgl_ctx.c index 5e19fbfa67..0766516cb5 100644 --- a/gfx/drivers_context/wgl_ctx.c +++ b/gfx/drivers_context/wgl_ctx.c @@ -435,9 +435,10 @@ static void gfx_ctx_wgl_update_title(void *data, void *data2) static void gfx_ctx_wgl_get_video_size(void *data, unsigned *width, unsigned *height) { - (void)data; HWND window = win32_get_window(); + (void)data; + if (!window) { RECT mon_rect; diff --git a/gfx/drivers_font/vulkan_raster_font.c b/gfx/drivers_font/vulkan_raster_font.c index c1036d217d..871c5f6e4c 100644 --- a/gfx/drivers_font/vulkan_raster_font.c +++ b/gfx/drivers_font/vulkan_raster_font.c @@ -271,15 +271,15 @@ static void vulkan_raster_font_render_message( static void vulkan_raster_font_flush(vulkan_raster_t *font) { - const struct vk_draw_triangles call = { - font->vk->pipelines.font, - &font->texture_optimal, - font->vk->samplers.mipmap_linear, - &font->vk->mvp, - sizeof(font->vk->mvp), - &font->range, - font->vertices, - }; + struct vk_draw_triangles call; + + call.pipeline = font->vk->pipelines.font; + call.texture = &font->texture_optimal; + call.sampler = font->vk->samplers.mipmap_linear; + call.uniform = &font->vk->mvp; + call.uniform_size = sizeof(font->vk->mvp); + call.vbo = &font->range; + call.vertices = font->vertices; if(font->needs_update) { diff --git a/gfx/include/vulkan/vk_platform.h b/gfx/include/vulkan/vk_platform.h index 5d0fc766ec..3771c169e1 100644 --- a/gfx/include/vulkan/vk_platform.h +++ b/gfx/include/vulkan/vk_platform.h @@ -1,6 +1,7 @@ -// -// File: vk_platform.h -// +/* + * File: vk_platform.h + */ + /* ** Copyright (c) 2014-2015 The Khronos Group Inc. ** @@ -24,7 +25,7 @@ #ifdef __cplusplus extern "C" { -#endif // __cplusplus +#endif /* __cplusplus */ /* *************************************************************************************************** @@ -47,22 +48,22 @@ extern "C" * Function pointer type: typedef void (VKAPI_PTR *PFN_vkCommand)(void); */ #if defined(_WIN32) - // On Windows, Vulkan commands use the stdcall convention + /* On Windows, Vulkan commands use the stdcall convention */ #define VKAPI_ATTR #define VKAPI_CALL __stdcall #define VKAPI_PTR VKAPI_CALL #elif defined(__ANDROID__) && defined(__ARM_EABI__) && !defined(__ARM_ARCH_7A__) - // Android does not support Vulkan in native code using the "armeabi" ABI. + /* Android does not support Vulkan in native code using the "armeabi" ABI. */ #error "Vulkan requires the 'armeabi-v7a' or 'armeabi-v7a-hard' ABI on 32-bit ARM CPUs" #elif defined(__ANDROID__) && defined(__ARM_ARCH_7A__) - // On Android/ARMv7a, Vulkan functions use the armeabi-v7a-hard calling - // convention, even if the application's native code is compiled with the - // armeabi-v7a calling convention. + /* On Android/ARMv7a, Vulkan functions use the armeabi-v7a-hard calling + * convention, even if the application's native code is compiled with the + * armeabi-v7a calling convention. */ #define VKAPI_ATTR __attribute__((pcs("aapcs-vfp"))) #define VKAPI_CALL #define VKAPI_PTR VKAPI_ATTR #else - // On other platforms, use the default calling convention + /* On other platforms, use the default calling convention */ #define VKAPI_ATTR #define VKAPI_CALL #define VKAPI_PTR @@ -83,15 +84,15 @@ extern "C" #else #include #endif -#endif // !defined(VK_NO_STDINT_H) +#endif /* !defined(VK_NO_STDINT_H) */ #ifdef __cplusplus -} // extern "C" -#endif // __cplusplus +} /* extern "C" */ +#endif /* __cplusplus */ -// Platform-specific headers required by platform window system extensions. -// These are enabled prior to #including "vulkan.h". The same enable then -// controls inclusion of the extension interfaces in vulkan.h. +/* Platform-specific headers required by platform window system extensions. + * These are enabled prior to #including "vulkan.h". The same enable then + * controls inclusion of the extension interfaces in vulkan.h. */ #ifdef VK_USE_PLATFORM_ANDROID_KHR #include diff --git a/gfx/include/vulkan/vk_sdk_platform.h b/gfx/include/vulkan/vk_sdk_platform.h index ef9a000fb2..29653774ff 100644 --- a/gfx/include/vulkan/vk_sdk_platform.h +++ b/gfx/include/vulkan/vk_sdk_platform.h @@ -1,6 +1,7 @@ -// -// File: vk_sdk_platform.h -// +/* + * File: vk_sdk_platform.h + */ + /* * Copyright (c) 2015-2016 The Khronos Group Inc. * Copyright (c) 2015-2016 Valve Corporation @@ -27,20 +28,20 @@ #ifndef __cplusplus #undef inline #define inline __inline -#endif // __cplusplus +#endif /* __cplusplus */ #if (defined(_MSC_VER) && _MSC_VER < 1900 /*vs2015*/) -// C99: -// Microsoft didn't implement C99 in Visual Studio; but started adding it with -// VS2013. However, VS2013 still didn't have snprintf(). The following is a -// work-around (Note: The _CRT_SECURE_NO_WARNINGS macro must be set in the -// "CMakeLists.txt" file). -// NOTE: This is fixed in Visual Studio 2015. +/* C99: + * Microsoft didn't implement C99 in Visual Studio; but started adding it with + * VS2013. However, VS2013 still didn't have snprintf(). The following is a + * work-around (Note: The _CRT_SECURE_NO_WARNINGS macro must be set in the + * "CMakeLists.txt" file). + * NOTE: This is fixed in Visual Studio 2015. */ #define snprintf _snprintf #endif #define strdup _strdup -#endif // _WIN32 +#endif /* _WIN32 */ -#endif // VK_SDK_PLATFORM_H +#endif /* VK_SDK_PLATFORM_H */ diff --git a/gfx/include/vulkan/vulkan.h b/gfx/include/vulkan/vulkan.h index 9b91e62973..121738c08f 100644 --- a/gfx/include/vulkan/vulkan.h +++ b/gfx/include/vulkan/vulkan.h @@ -33,16 +33,18 @@ extern "C" { #define VK_MAKE_VERSION(major, minor, patch) \ (((major) << 22) | ((minor) << 12) | (patch)) -// DEPRECATED: This define has been removed. Specific version defines (e.g. VK_API_VERSION_1_0), or the VK_MAKE_VERSION macro, should be used instead. -//#define VK_API_VERSION VK_MAKE_VERSION(1, 0, 0) +/* DEPRECATED: This define has been removed. Specific version defines (e.g. VK_API_VERSION_1_0), or the VK_MAKE_VERSION macro, should be used instead. */ +#if 0 +#define VK_API_VERSION VK_MAKE_VERSION(1, 0, 0) +#endif -// Vulkan 1.0 version number +/* Vulkan 1.0 version number */ #define VK_API_VERSION_1_0 VK_MAKE_VERSION(1, 0, 0) #define VK_VERSION_MAJOR(version) ((uint32_t)(version) >> 22) #define VK_VERSION_MINOR(version) (((uint32_t)(version) >> 12) & 0x3ff) #define VK_VERSION_PATCH(version) ((uint32_t)(version) & 0xfff) -// Version of this file +/* Version of this file */ #define VK_HEADER_VERSION 17 diff --git a/gfx/include/vulkan/vulkan_intel.h b/gfx/include/vulkan/vulkan_intel.h index 1f77128961..15b5a02ad0 100644 --- a/gfx/include/vulkan/vulkan_intel.h +++ b/gfx/include/vulkan/vulkan_intel.h @@ -29,16 +29,16 @@ #ifdef __cplusplus extern "C" { -#endif // __cplusplus +#endif /* __cplusplus */ #define VK_STRUCTURE_TYPE_DMA_BUF_IMAGE_CREATE_INFO_INTEL 1024 typedef struct VkDmaBufImageCreateInfo_ { - VkStructureType sType; // Must be VK_STRUCTURE_TYPE_DMA_BUF_IMAGE_CREATE_INFO_INTEL - const void* pNext; // Pointer to next structure. + VkStructureType sType; /* Must be VK_STRUCTURE_TYPE_DMA_BUF_IMAGE_CREATE_INFO_INTEL */ + const void* pNext; /* Pointer to next structure. */ int fd; VkFormat format; - VkExtent3D extent; // Depth must be 1 + VkExtent3D extent; /* Depth must be 1 */ uint32_t strideInBytes; } VkDmaBufImageCreateInfo; @@ -56,7 +56,7 @@ VKAPI_ATTR VkResult VKAPI_CALL vkCreateDmaBufImageINTEL( #endif #ifdef __cplusplus -} // extern "C" -#endif // __cplusplus +} /* extern "C" */ +#endif /* __cplusplus */ -#endif // __VULKAN_INTEL_H__ +#endif /* __VULKAN_INTEL_H__ */ diff --git a/gfx/video_driver.c b/gfx/video_driver.c index 02125f91e1..bc6941349e 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -1431,7 +1431,6 @@ void video_driver_menu_settings(void **list_data, void *list_info_data, void *group_data, void *subgroup_data, const char *parent_group) { #ifdef HAVE_MENU - bool has_video_output = false; rarch_setting_t **list = (rarch_setting_t**)list_data; rarch_setting_info_t *list_info = (rarch_setting_info_t*)list_info_data; rarch_setting_group_info_t *group_info = (rarch_setting_group_info_t*)group_data; @@ -1444,26 +1443,15 @@ void video_driver_menu_settings(void **list_data, void *list_info_data, (void)subgroup_info; (void)global; - has_video_output = video_driver_poke->get_video_output_next || - current_video_context.get_video_output_next; - if (has_video_output) - has_video_output = video_driver_poke->get_video_output_prev || - current_video_context.get_video_output_prev; - if (has_video_output) - has_video_output = video_driver_poke->get_video_output_size || - current_video_context.get_video_output_size; - - if (has_video_output) - { - CONFIG_ACTION( - list, list_info, - MENU_ENUM_LABEL_SCREEN_RESOLUTION, - MENU_ENUM_LABEL_VALUE_SCREEN_RESOLUTION, - group_info, - subgroup_info, - parent_group); - } - +#if defined(GEKKO) || defined(__CELLOS_LV2__) + CONFIG_ACTION( + list, list_info, + MENU_ENUM_LABEL_SCREEN_RESOLUTION, + MENU_ENUM_LABEL_VALUE_SCREEN_RESOLUTION, + group_info, + subgroup_info, + parent_group); +#endif #if defined(__CELLOS_LV2__) CONFIG_BOOL( list, list_info, diff --git a/input/drivers/dinput.c b/input/drivers/dinput.c index 4314ce04f5..b1b34051c8 100644 --- a/input/drivers/dinput.c +++ b/input/drivers/dinput.c @@ -222,6 +222,8 @@ static void dinput_poll(void *data) if (di->mouse) { DIMOUSESTATE2 mouse_state; + POINT point = {0}; + memset(&mouse_state, 0, sizeof(mouse_state)); if (FAILED(IDirectInputDevice8_GetDeviceState( @@ -237,8 +239,8 @@ static void dinput_poll(void *data) di->mouse_rel_y = mouse_state.lY; - if (!mouse_state.rgbButtons[0]) - unset_doubleclick_on_titlebar(); + if (!mouse_state.rgbButtons[0]) + unset_doubleclick_on_titlebar(); if (doubleclick_on_titlebar_pressed()) di->mouse_l = 0; else @@ -248,7 +250,6 @@ static void dinput_poll(void *data) /* No simple way to get absolute coordinates * for RETRO_DEVICE_POINTER. Just use Win32 APIs. */ - POINT point = {0}; GetCursorPos(&point); ScreenToClient((HWND)video_driver_window_get(), &point); di->mouse_x = point.x; diff --git a/input/drivers_joypad/xinput_joypad.c b/input/drivers_joypad/xinput_joypad.c index 3c77f48547..eacba9e370 100644 --- a/input/drivers_joypad/xinput_joypad.c +++ b/input/drivers_joypad/xinput_joypad.c @@ -375,11 +375,11 @@ static bool xinput_joypad_button(unsigned port_num, uint16_t joykey) static int16_t xinput_joypad_axis (unsigned port_num, uint32_t joyaxis) { int xuser; - int16_t val = 0; - int axis = -1; - - bool is_neg = false; - bool is_pos = false; + int16_t val = 0; + int axis = -1; + bool is_neg = false; + bool is_pos = false; + XINPUT_GAMEPAD* pad = NULL; if (joyaxis == AXIS_NONE) return 0; @@ -404,7 +404,7 @@ static int16_t xinput_joypad_axis (unsigned port_num, uint32_t joyaxis) is_pos = true; } - XINPUT_GAMEPAD* pad = &(g_xinput_states[xuser].xstate.Gamepad); + pad = &(g_xinput_states[xuser].xstate.Gamepad); switch (axis) { diff --git a/input/input_autodetect_builtin.c b/input/input_autodetect_builtin.c index f49c4dc5cc..5931bb2c76 100644 --- a/input/input_autodetect_builtin.c +++ b/input/input_autodetect_builtin.c @@ -19,6 +19,8 @@ #include "../config.h" #endif +#include + #include "../tasks/tasks_internal.h" #include "input_config.h" @@ -498,6 +500,7 @@ const char* const input_builtin_autoconfs[] = #if defined(_WIN32) && defined(_XBOX) DECL_AUTOCONF_DEVICE("XInput Controller", "xdk", XINPUT_DEFAULT_BINDS), #elif defined(_WIN32) +#if !defined(__STDC_C89__) && !defined(__STDC_C89_AMENDMENT_1__) DECL_AUTOCONF_DEVICE("XInput Controller (User 1)", "xinput", XINPUT_DEFAULT_BINDS), DECL_AUTOCONF_DEVICE("XInput Controller (User 2)", "xinput", XINPUT_DEFAULT_BINDS), DECL_AUTOCONF_DEVICE("XInput Controller (User 3)", "xinput", XINPUT_DEFAULT_BINDS), @@ -507,6 +510,7 @@ const char* const input_builtin_autoconfs[] = DECL_AUTOCONF_DEVICE("XBOX One Controller (User 3)", "xinput", XINPUT_DEFAULT_BINDS), DECL_AUTOCONF_DEVICE("XBOX One Controller (User 4)", "xinput", XINPUT_DEFAULT_BINDS), #endif +#endif #ifdef HAVE_SDL2 DECL_AUTOCONF_DEVICE("Standard Gamepad", "sdl2", SDL2_DEFAULT_BINDS), #endif diff --git a/intl/msg_hash_eo.h b/intl/msg_hash_eo.h index c4bcda8c2c..d3919f0825 100644 --- a/intl/msg_hash_eo.h +++ b/intl/msg_hash_eo.h @@ -863,7 +863,7 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_MENU_LINEAR_FILTER, MSG_HASH(MENU_ENUM_LABEL_VALUE_MENU_HORIZONTAL_ANIMATION, "Horizontal Animation") MSG_HASH(MENU_ENUM_LABEL_VALUE_MENU_SETTINGS, - "Menu") + "Appearance") MSG_HASH(MENU_ENUM_LABEL_VALUE_MENU_WALLPAPER, "Background") MSG_HASH(MENU_ENUM_LABEL_VALUE_MENU_WALLPAPER_OPACITY, diff --git a/intl/msg_hash_fr.h b/intl/msg_hash_fr.h index edf2d39225..8775cab098 100644 --- a/intl/msg_hash_fr.h +++ b/intl/msg_hash_fr.h @@ -950,7 +950,7 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_MENU_FILE_BROWSER_SETTINGS, MSG_HASH(MENU_ENUM_LABEL_VALUE_MENU_LINEAR_FILTER, "Filtre linéaire pour le menu") MSG_HASH(MENU_ENUM_LABEL_VALUE_MENU_SETTINGS, - "Menu") + "Appearance") MSG_HASH(MENU_ENUM_LABEL_VALUE_MENU_WALLPAPER, "Fond d'écran") MSG_HASH(MENU_ENUM_LABEL_VALUE_MENU_WALLPAPER_OPACITY, diff --git a/intl/msg_hash_it.h b/intl/msg_hash_it.h index 8417b5701c..f23da90c3b 100644 --- a/intl/msg_hash_it.h +++ b/intl/msg_hash_it.h @@ -703,9 +703,9 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_OVERLAY_HIDE_IN_MENU, MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_POLL_TYPE_BEHAVIOR, "Tipo di ritardo") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_POLL_TYPE_BEHAVIOR_EARLY, - "Presto") + "Anticipato") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_POLL_TYPE_BEHAVIOR_LATE, - "Tardi") + "Ritardato") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_POLL_TYPE_BEHAVIOR_NORMAL, "Normale") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_PREFER_FRONT_TOUCH, @@ -827,7 +827,7 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_MENU_FILE_BROWSER_SETTINGS, /* TODO/FIXME - updat MSG_HASH(MENU_ENUM_LABEL_VALUE_MENU_LINEAR_FILTER, "Filtro lineare del menù") MSG_HASH(MENU_ENUM_LABEL_VALUE_MENU_SETTINGS, - "Menù") + "Appearance") MSG_HASH(MENU_ENUM_LABEL_VALUE_MENU_WALLPAPER, "Menù sfondi") MSG_HASH(MENU_ENUM_LABEL_VALUE_MENU_WALLPAPER_OPACITY, @@ -865,7 +865,7 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_ENABLE_CLIENT, MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_ENABLE_HOST, "Avvia host netplay") MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_DISABLE_HOST, - "Stop netplay host") + "Ferma host netplay") MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_IP_ADDRESS, "Indirizzo Server") MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_LAN_SCAN_SETTINGS, @@ -2104,11 +2104,11 @@ MSG_HASH( ) MSG_HASH( MENU_ENUM_SUBLABEL_INPUT_POLL_TYPE_BEHAVIOR, - "Influisce come il polling degli input che viene fatto all'interno di RetroArch. L'impostazione 'Early' o 'Late' può causare una minore latenza, a seconda della configurazione." + "Influisce come il polling degli input che viene fatto all'interno di RetroArch. L'impostazione 'Anticipato' o 'Ritardato' può causare una minore latenza, a seconda della configurazione." ) MSG_HASH( MENU_ENUM_SUBLABEL_INPUT_ALL_USERS_CONTROL_MENU, - "Allows any user to control the menu. If disabled, only User 1 can control the menu." + "Consente a qualsiasi utente di controllare il menu. Se disattivato, solo l'utente 1 può controllare il menu." ) MSG_HASH( MENU_ENUM_SUBLABEL_AUDIO_VOLUME, @@ -2242,7 +2242,7 @@ MSG_HASH(MENU_ENUM_SUBLABEL_HISTORY_LIST_ENABLE, MSG_HASH(MENU_ENUM_SUBLABEL_CONTENT_HISTORY_SIZE, "Limit the number of entries in recent playlist for games, images, music, and videos.") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_UNIFIED_MENU_CONTROLS, - "Unified Menu Controls") + "Controlli del menu unificati") MSG_HASH(MENU_ENUM_SUBLABEL_INPUT_UNIFIED_MENU_CONTROLS, "Utilizzare gli stessi controlli sia per il menu che per il gioco. Si applica alla tastiera.") MSG_HASH(MENU_ENUM_SUBLABEL_VIDEO_FONT_ENABLE, @@ -2399,3 +2399,13 @@ MSG_HASH(MENU_ENUM_SUBLABEL_NAVIGATION_BROWSER_FILTER_SUPPORTED_EXTENSIONS_ENABL "Filtra i file visualizzati nel filebrowser con estensioni supportate.") MSG_HASH(MENU_ENUM_LABEL_VALUE_FILTER_BY_CURRENT_CORE, "Filtra per core corrente") +MSG_HASH(MENU_ENUM_SUBLABEL_NETPLAY_DISCONNECT, + "Disconnette da una connessione Netplay attiva.") +MSG_HASH(MENU_ENUM_SUBLABEL_INPUT_META_REWIND, + "Gestisce le impostazioni di riavvolgimento.") +MSG_HASH(MENU_ENUM_SUBLABEL_REWIND_ENABLE, + "Attiva il riavvolgimento.Richiederà maggiori prestazioni durante il gioco.") +MSG_HASH(MENU_ENUM_SUBLABEL_REWIND_GRANULARITY, + "Quando si riavvolge un numero definito di fotogrammi, è possibile riavvolgere più fotogrammi alla volta, aumentando la velocità di riavvolgimento.") + MSG_HASH(MENU_ENUM_SUBLABEL_FASTFORWARD_RATIO, + "La velocità massima in cui il contenuto verrà eseguito quando si utilizza l'avanzamento veloce (ad esempio, 5,0x per 60 fps = 300 fps). Se impostato a 0.0x, il rapporto dell'avanzamneto veloce è illimitato (nessun cap FPS)." ) diff --git a/intl/msg_hash_nl.h b/intl/msg_hash_nl.h index c6de568cab..9a55eda969 100644 --- a/intl/msg_hash_nl.h +++ b/intl/msg_hash_nl.h @@ -861,7 +861,7 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_MENU_FILE_BROWSER_SETTINGS, MSG_HASH(MENU_ENUM_LABEL_VALUE_MENU_LINEAR_FILTER, "Menu Linear Filter") MSG_HASH(MENU_ENUM_LABEL_VALUE_MENU_SETTINGS, - "Menu") + "Appearance") MSG_HASH(MENU_ENUM_LABEL_VALUE_MENU_WALLPAPER, "Achtergrond") MSG_HASH(MENU_ENUM_LABEL_VALUE_MENU_WALLPAPER_OPACITY, diff --git a/intl/msg_hash_pt_br.h b/intl/msg_hash_pt_br.h index 7a2b5636f7..44f22e0c2a 100644 --- a/intl/msg_hash_pt_br.h +++ b/intl/msg_hash_pt_br.h @@ -1061,7 +1061,7 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_MENU_LINEAR_FILTER, "Filtro Linear de Menu" ) MSG_HASH(MENU_ENUM_LABEL_VALUE_MENU_SETTINGS, - "Menu" + "Appearance" ) MSG_HASH(MENU_ENUM_LABEL_VALUE_MENU_WALLPAPER, "Plano de Fundo" diff --git a/intl/msg_hash_pt_pt.h b/intl/msg_hash_pt_pt.h index 7d37530f5f..154b80c9cc 100644 --- a/intl/msg_hash_pt_pt.h +++ b/intl/msg_hash_pt_pt.h @@ -936,7 +936,7 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_MENU_FILE_BROWSER_SETTINGS, MSG_HASH(MENU_ENUM_LABEL_VALUE_MENU_LINEAR_FILTER, "Filtro de menu Linear") MSG_HASH(MENU_ENUM_LABEL_VALUE_MENU_SETTINGS, - "Menu") + "Appearance") MSG_HASH(MENU_ENUM_LABEL_VALUE_MENU_WALLPAPER, "Fundo") MSG_HASH(MENU_ENUM_LABEL_VALUE_MENU_WALLPAPER_OPACITY, diff --git a/intl/msg_hash_us.h b/intl/msg_hash_us.h index 5e7adb4487..7025fae444 100644 --- a/intl/msg_hash_us.h +++ b/intl/msg_hash_us.h @@ -962,7 +962,7 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_MENU_LINEAR_FILTER, MSG_HASH(MENU_ENUM_LABEL_VALUE_MENU_HORIZONTAL_ANIMATION, "Horizontal Animation") MSG_HASH(MENU_ENUM_LABEL_VALUE_MENU_SETTINGS, - "Menu") + "Appearance") MSG_HASH(MENU_ENUM_LABEL_VALUE_MENU_WALLPAPER, "Background") MSG_HASH(MENU_ENUM_LABEL_VALUE_MENU_WALLPAPER_OPACITY, diff --git a/intl/msg_hash_vn.h b/intl/msg_hash_vn.h index 9d253653e7..1459a99f45 100644 --- a/intl/msg_hash_vn.h +++ b/intl/msg_hash_vn.h @@ -948,7 +948,7 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_MENU_FILE_BROWSER_SETTINGS, MSG_HASH(MENU_ENUM_LABEL_VALUE_MENU_LINEAR_FILTER, "Menu Linear Filter") MSG_HASH(MENU_ENUM_LABEL_VALUE_MENU_SETTINGS, - "Menu") + "Appearance") MSG_HASH(MENU_ENUM_LABEL_VALUE_MENU_WALLPAPER, "Background") MSG_HASH(MENU_ENUM_LABEL_VALUE_MENU_WALLPAPER_OPACITY, diff --git a/libretro-common/rthreads/rthreads.c b/libretro-common/rthreads/rthreads.c index a059bc2f04..5f1f98c724 100644 --- a/libretro-common/rthreads/rthreads.c +++ b/libretro-common/rthreads/rthreads.c @@ -530,12 +530,14 @@ static bool _scond_wait_win32(scond_t *cond, slock_t *lock, DWORD dwMilliseconds { #if _WIN32_WINNT >= 0x0500 LARGE_INTEGER now; + LONGLONG elapsed; + QueryPerformanceCounter(&now); - LONGLONG elapsed = now.QuadPart - tsBegin.QuadPart; + elapsed = now.QuadPart - tsBegin.QuadPart; elapsed *= 1000; elapsed /= performanceCounterFrequency.QuadPart; #else - DWORD now = timeGetTime(); + DWORD now = timeGetTime(); DWORD elapsed = now - tsBegin; #endif diff --git a/menu/cbs/menu_cbs_left.c b/menu/cbs/menu_cbs_left.c index ef585ae524..99ca4fa1dd 100644 --- a/menu/cbs/menu_cbs_left.c +++ b/menu/cbs/menu_cbs_left.c @@ -388,7 +388,6 @@ static int bind_left_generic(unsigned type, const char *label, static int menu_cbs_init_bind_left_compare_label(menu_file_list_cbs_t *cbs, const char *label, uint32_t label_hash, const char *menu_label) { - unsigned i; if (cbs->setting) { @@ -402,21 +401,25 @@ static int menu_cbs_init_bind_left_compare_label(menu_file_list_cbs_t *cbs, } } - for (i = 0; i < MAX_USERS; i++) + if (strstr(label, "input_player") && strstr(label, "_joypad_index")) { - uint32_t label_setting_hash; - char label_setting[128]; - - label_setting[0] = '\0'; + unsigned i; + for (i = 0; i < MAX_USERS; i++) + { + uint32_t label_setting_hash; + char label_setting[128]; - snprintf(label_setting, sizeof(label_setting), "input_player%d_joypad_index", i + 1); - label_setting_hash = msg_hash_calculate(label_setting); + label_setting[0] = '\0'; - if (label_hash != label_setting_hash) - continue; + snprintf(label_setting, sizeof(label_setting), "input_player%d_joypad_index", i + 1); + label_setting_hash = msg_hash_calculate(label_setting); - BIND_ACTION_LEFT(cbs, bind_left_generic); - return 0; + if (label_hash != label_setting_hash) + continue; + + BIND_ACTION_LEFT(cbs, bind_left_generic); + return 0; + } } if (string_is_equal(menu_label, msg_hash_to_str(MENU_ENUM_LABEL_PLAYLISTS_TAB))) diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index 2518825b65..b3602f5174 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -915,7 +915,7 @@ static bool menu_content_find_first_core(menu_content_ctx_defer_info_t *def_info size_t default_info_length = def_info->len; if (!string_is_empty(default_info_path)) - fill_pathname_join(def_info->s, + fill_pathname_join(def_info->s, default_info_dir, default_info_path, default_info_length); @@ -936,7 +936,7 @@ static bool menu_content_find_first_core(menu_content_ctx_defer_info_t *def_info def_info->s, &info, &supported); - /* We started the menu with 'Load Content', we are + /* We started the menu with 'Load Content', we are * going to use the current core to load this. */ if (load_content_with_current_core) { @@ -1069,7 +1069,8 @@ static int action_ok_file_load_with_detect_core(const char *path, type = 0; label = NULL; - return file_load_with_detect_core_wrapper(MSG_UNKNOWN, + return file_load_with_detect_core_wrapper( + MSG_UNKNOWN, MSG_UNKNOWN, idx, entry_idx, path, label, type, false); } @@ -1265,33 +1266,24 @@ error: return menu_cbs_exit(); } -static int action_ok_set_path_videofilter(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - return generic_action_ok(path, label, type, idx, entry_idx, - ACTION_OK_SET_PATH_VIDEO_FILTER, MSG_UNKNOWN); +#define default_action_ok_set(funcname, _id, _flush) \ +static int (funcname)(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) \ +{ \ + return generic_action_ok(path, label, type, idx, entry_idx, _id, _flush); \ } -static int action_ok_set_path_audiofilter(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - return generic_action_ok(path, label, type, idx, entry_idx, - ACTION_OK_SET_PATH_AUDIO_FILTER, MSG_UNKNOWN); -} - -static int action_ok_set_path_overlay(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - return generic_action_ok(path, label, type, idx, entry_idx, - ACTION_OK_SET_PATH_OVERLAY, MSG_UNKNOWN); -} - -static int action_ok_set_path(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - return generic_action_ok(path, label, type, idx, entry_idx, - ACTION_OK_SET_PATH, MSG_UNKNOWN); -} +default_action_ok_set(action_ok_set_path_audiofilter, ACTION_OK_SET_PATH_VIDEO_FILTER, MSG_UNKNOWN) +default_action_ok_set(action_ok_set_path_videofilter, ACTION_OK_SET_PATH_AUDIO_FILTER, MSG_UNKNOWN) +default_action_ok_set(action_ok_set_path_overlay, ACTION_OK_SET_PATH_OVERLAY, MSG_UNKNOWN) +default_action_ok_set(action_ok_set_path, ACTION_OK_SET_PATH, MSG_UNKNOWN) +default_action_ok_set(action_ok_load_core, ACTION_OK_LOAD_CORE, MSG_UNKNOWN) +default_action_ok_set(action_ok_config_load, ACTION_OK_LOAD_CONFIG_FILE, MSG_UNKNOWN) +default_action_ok_set(action_ok_disk_image_append, ACTION_OK_APPEND_DISK_IMAGE, MSG_UNKNOWN) +default_action_ok_set(action_ok_cheat_file_load, ACTION_OK_LOAD_CHEAT_FILE, MENU_ENUM_LABEL_CORE_CHEAT_OPTIONS) +default_action_ok_set(action_ok_record_configfile_load, ACTION_OK_LOAD_RECORD_CONFIGFILE, MENU_ENUM_LABEL_RECORDING_SETTINGS) +default_action_ok_set(action_ok_remap_file_load, ACTION_OK_LOAD_REMAPPING_FILE, MENU_ENUM_LABEL_CORE_INPUT_REMAPPING_OPTIONS ) +default_action_ok_set(action_ok_shader_preset_load, ACTION_OK_LOAD_PRESET , MENU_ENUM_LABEL_SHADER_OPTIONS) +default_action_ok_set(action_ok_shader_pass_load, ACTION_OK_LOAD_SHADER_PASS, MENU_ENUM_LABEL_SHADER_OPTIONS) static int action_ok_file_load(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) @@ -1404,11 +1396,11 @@ static int action_ok_playlist_entry_collection(const char *path, playlist_get_index(playlist, selection_ptr, &entry_path, &entry_label, &core_path, &core_name, NULL, NULL); - /* If the currently loaded core's name is equal + /* If the currently loaded core's name is equal * to the core name from the playlist entry, * then we directly load this game with the current core. */ - if (system && + if (system && string_is_equal(system->library_name, core_name)) { if (playlist_initialized) @@ -1633,7 +1625,7 @@ static int action_ok_playlist_entry_start_content(const char *path, new_core_path[0] = new_display_name[0] = '\0'; - found_associated_core = + found_associated_core = menu_content_playlist_find_associated_core( path_base, new_core_path, sizeof(new_core_path)); @@ -1738,7 +1730,7 @@ static int action_ok_audio_add_to_mixer_and_collection(const char *path, fill_pathname_join(combined_path, menu->scratch2_buf, menu->scratch_buf, sizeof(combined_path)); - playlist_push(g_defaults.music_history, + playlist_push(g_defaults.music_history, combined_path, NULL, "builtin", @@ -1781,65 +1773,6 @@ static int action_ok_menu_wallpaper_load(const char *path, ACTION_OK_LOAD_WALLPAPER, MSG_UNKNOWN); } -static int action_ok_load_core(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - return generic_action_ok(path, label, type, idx, entry_idx, - ACTION_OK_LOAD_CORE, MSG_UNKNOWN); -} - -static int action_ok_config_load(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - return generic_action_ok(path, label, type, idx, entry_idx, - ACTION_OK_LOAD_CONFIG_FILE, MSG_UNKNOWN); -} - -static int action_ok_disk_image_append(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - return generic_action_ok(path, label, type, idx, entry_idx, - ACTION_OK_APPEND_DISK_IMAGE, MSG_UNKNOWN); -} - -static int action_ok_cheat_file_load(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - return generic_action_ok(path, label, type, idx, entry_idx, - ACTION_OK_LOAD_CHEAT_FILE, - MENU_ENUM_LABEL_CORE_CHEAT_OPTIONS); -} - -static int action_ok_record_configfile_load(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - return generic_action_ok(path, label, type, idx, entry_idx, - ACTION_OK_LOAD_RECORD_CONFIGFILE, - MENU_ENUM_LABEL_RECORDING_SETTINGS); -} - -static int action_ok_remap_file_load(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - return generic_action_ok(path, label, type, idx, entry_idx, - ACTION_OK_LOAD_REMAPPING_FILE, - MENU_ENUM_LABEL_CORE_INPUT_REMAPPING_OPTIONS); -} - -static int action_ok_shader_preset_load(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - return generic_action_ok(path, label, type, idx, entry_idx, - ACTION_OK_LOAD_PRESET, MENU_ENUM_LABEL_SHADER_OPTIONS); -} - -static int action_ok_shader_pass_load(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - return generic_action_ok(path, label, type, idx, entry_idx, - ACTION_OK_LOAD_SHADER_PASS, MENU_ENUM_LABEL_SHADER_OPTIONS); -} - int generic_action_ok_help(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx, enum msg_hash_enums id, enum menu_dialog_type id2) @@ -2456,8 +2389,6 @@ static int action_ok_file_load_detect_core(const char *path, return 0; } - - static int generic_action_ok_command(enum event_command cmd) { if (!command_event(cmd, NULL)) @@ -2607,7 +2538,7 @@ static int generic_action_ok_network(const char *path, default: break; } - + menu_entries_ctl(MENU_ENTRIES_CTL_SET_REFRESH, &refresh); command_event(CMD_EVENT_NETWORK_INIT, NULL); @@ -3034,12 +2965,6 @@ static int action_ok_update_autoconfig_profiles(const char *path, MENU_ENUM_LABEL_CB_UPDATE_AUTOCONFIG_PROFILES); } -static int action_ok_disk_cycle_tray_status(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - return generic_action_ok_command(CMD_EVENT_DISK_EJECT_TOGGLE); -} - /* creates folder and core options stub file for subsequent runs */ static int action_ok_option_create(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) @@ -3078,66 +3003,49 @@ static int action_ok_option_create(const char *path, return 0; } - -static int action_ok_close_content(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - return generic_action_ok_command(CMD_EVENT_UNLOAD_CORE); +#define default_action_ok_cmd_func(func_name, cmd) \ +int (func_name)(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) \ +{ \ + return generic_action_ok_command(cmd); \ } -static int action_ok_quit(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - return generic_action_ok_command(CMD_EVENT_QUIT); -} - -static int action_ok_save_new_config(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - return generic_action_ok_command(CMD_EVENT_MENU_SAVE_CONFIG); -} - -static int action_ok_resume_content(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - return generic_action_ok_command(CMD_EVENT_RESUME); -} - -static int action_ok_add_to_favorites(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - return generic_action_ok_command(CMD_EVENT_ADD_TO_FAVORITES); -} - -static int action_ok_restart_content(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - return generic_action_ok_command(CMD_EVENT_RESET); -} - -static int action_ok_screenshot(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - return generic_action_ok_command(CMD_EVENT_TAKE_SCREENSHOT); -} +default_action_ok_cmd_func(action_ok_close_content, CMD_EVENT_UNLOAD_CORE) +default_action_ok_cmd_func(action_ok_quit, CMD_EVENT_QUIT) +default_action_ok_cmd_func(action_ok_save_new_config, CMD_EVENT_MENU_SAVE_CONFIG) +default_action_ok_cmd_func(action_ok_resume_content, CMD_EVENT_RESUME) +default_action_ok_cmd_func(action_ok_restart_content, CMD_EVENT_RESET) +default_action_ok_cmd_func(action_ok_screenshot, CMD_EVENT_TAKE_SCREENSHOT) +default_action_ok_cmd_func(action_ok_disk_cycle_tray_status, CMD_EVENT_DISK_EJECT_TOGGLE ) +default_action_ok_cmd_func(action_ok_shader_apply_changes, CMD_EVENT_SHADERS_APPLY_CHANGES ) +default_action_ok_cmd_func(action_ok_add_to_favorites, CMD_EVENT_ADD_TO_FAVORITES) static int action_ok_delete_entry(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) { size_t new_selection_ptr; - playlist_t *playlist = NULL; - char *conf_path = playlist_get_conf_path(playlist); - char *def_conf_path = playlist_get_conf_path(g_defaults.content_history); - char *def_conf_music_path= playlist_get_conf_path(g_defaults.music_history); + playlist_t *playlist = NULL; + char *conf_path = NULL; + char *def_conf_path = NULL; + char *def_conf_music_path = NULL; #ifdef HAVE_FFMPEG - char *def_conf_video_path= playlist_get_conf_path(g_defaults.video_history); + char *def_conf_video_path = NULL; #endif #ifdef HAVE_IMAGEVIEWER - char *def_conf_img_path = playlist_get_conf_path(g_defaults.image_history); + char *def_conf_img_path = NULL; #endif menu_driver_ctl(RARCH_MENU_CTL_PLAYLIST_GET, &playlist); + conf_path = playlist_get_conf_path(playlist); + def_conf_path = playlist_get_conf_path(g_defaults.content_history); + def_conf_music_path = playlist_get_conf_path(g_defaults.music_history); +#ifdef HAVE_FFMPEG + def_conf_video_path = playlist_get_conf_path(g_defaults.video_history); +#endif +#ifdef HAVE_IMAGEVIEWER + def_conf_img_path = playlist_get_conf_path(g_defaults.image_history); +#endif + if (string_is_equal(conf_path, def_conf_path)) playlist = g_defaults.content_history; else if (string_is_equal(conf_path, def_conf_music_path)) @@ -3160,12 +3068,6 @@ static int action_ok_delete_entry(const char *path, return 0; } -static int action_ok_shader_apply_changes(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - return generic_action_ok_command(CMD_EVENT_SHADERS_APPLY_CHANGES); -} - static int action_ok_rdb_entry_submenu(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) { @@ -3237,13 +3139,69 @@ end: extern size_t hack_shader_pass; #endif -static int action_ok_browse_url_start(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - return generic_action_ok_displaylist_push(path, NULL, label, type, idx, - entry_idx, ACTION_OK_DL_BROWSE_URL_START); +#define default_action_ok_func(func_name, lbl) \ +int (func_name)(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) \ +{ \ + return generic_action_ok_displaylist_push(path, NULL, label, type, idx, entry_idx, lbl); \ } +default_action_ok_func(action_ok_browse_url_start, ACTION_OK_DL_BROWSE_URL_START) +default_action_ok_func(action_ok_shader_parameters, ACTION_OK_DL_SHADER_PARAMETERS) +default_action_ok_func(action_ok_parent_directory_push, ACTION_OK_DL_PARENT_DIRECTORY_PUSH) +default_action_ok_func(action_ok_directory_push, ACTION_OK_DL_DIRECTORY_PUSH) +default_action_ok_func(action_ok_configurations_list, ACTION_OK_DL_CONFIGURATIONS_LIST) +default_action_ok_func(action_ok_saving_list, ACTION_OK_DL_SAVING_SETTINGS_LIST) +default_action_ok_func(action_ok_network_list, ACTION_OK_DL_NETWORK_SETTINGS_LIST) +default_action_ok_func(action_ok_database_manager_list, ACTION_OK_DL_DATABASE_MANAGER_LIST) +default_action_ok_func(action_ok_wifi_list, ACTION_OK_DL_WIFI_SETTINGS_LIST) +default_action_ok_func(action_ok_cursor_manager_list, ACTION_OK_DL_CURSOR_MANAGER_LIST) +default_action_ok_func(action_ok_compressed_archive_push, ACTION_OK_DL_COMPRESSED_ARCHIVE_PUSH) +default_action_ok_func(action_ok_compressed_archive_push_detect_core, ACTION_OK_DL_COMPRESSED_ARCHIVE_PUSH_DETECT_CORE) +default_action_ok_func(action_ok_logging_list, ACTION_OK_DL_LOGGING_SETTINGS_LIST) +default_action_ok_func(action_ok_frame_throttle_list, ACTION_OK_DL_FRAME_THROTTLE_SETTINGS_LIST) +default_action_ok_func(action_ok_rewind_list, ACTION_OK_DL_REWIND_SETTINGS_LIST) +default_action_ok_func(action_ok_onscreen_display_list, ACTION_OK_DL_ONSCREEN_DISPLAY_SETTINGS_LIST) +default_action_ok_func(action_ok_onscreen_notifications_list, ACTION_OK_DL_ONSCREEN_NOTIFICATIONS_SETTINGS_LIST) +default_action_ok_func(action_ok_onscreen_overlay_list, ACTION_OK_DL_ONSCREEN_OVERLAY_SETTINGS_LIST) +default_action_ok_func(action_ok_menu_list, ACTION_OK_DL_MENU_SETTINGS_LIST) +default_action_ok_func(action_ok_menu_views_list, ACTION_OK_DL_MENU_VIEWS_SETTINGS_LIST) +default_action_ok_func(action_ok_user_interface_list, ACTION_OK_DL_USER_INTERFACE_SETTINGS_LIST) +default_action_ok_func(action_ok_menu_file_browser_list, ACTION_OK_DL_MENU_FILE_BROWSER_SETTINGS_LIST) +default_action_ok_func(action_ok_retro_achievements_list, ACTION_OK_DL_RETRO_ACHIEVEMENTS_SETTINGS_LIST) +default_action_ok_func(action_ok_updater_list, ACTION_OK_DL_UPDATER_SETTINGS_LIST) +default_action_ok_func(action_ok_lakka_services, ACTION_OK_DL_LAKKA_SERVICES_LIST) +default_action_ok_func(action_ok_user_list, ACTION_OK_DL_USER_SETTINGS_LIST) +default_action_ok_func(action_ok_netplay_sublist, ACTION_OK_DL_NETPLAY) +default_action_ok_func(action_ok_directory_list, ACTION_OK_DL_DIRECTORY_SETTINGS_LIST) +default_action_ok_func(action_ok_privacy_list, ACTION_OK_DL_PRIVACY_SETTINGS_LIST) +default_action_ok_func(action_ok_rdb_entry, ACTION_OK_DL_RDB_ENTRY) +default_action_ok_func(action_ok_browse_url_list, ACTION_OK_DL_BROWSE_URL_LIST) +default_action_ok_func(action_ok_core_list, ACTION_OK_DL_CORE_LIST) +default_action_ok_func(action_ok_cheat_file, ACTION_OK_DL_CHEAT_FILE) +default_action_ok_func(action_ok_playlist_collection, ACTION_OK_DL_PLAYLIST_COLLECTION) +default_action_ok_func(action_ok_disk_image_append_list, ACTION_OK_DL_DISK_IMAGE_APPEND_LIST) +default_action_ok_func(action_ok_record_configfile, ACTION_OK_DL_RECORD_CONFIGFILE) +default_action_ok_func(action_ok_remap_file, ACTION_OK_DL_REMAP_FILE) +default_action_ok_func(action_ok_shader_preset, ACTION_OK_DL_SHADER_PRESET) +default_action_ok_func(action_ok_push_generic_list, ACTION_OK_DL_GENERIC) +default_action_ok_func(action_ok_audio_dsp_plugin, ACTION_OK_DL_AUDIO_DSP_PLUGIN) +default_action_ok_func(action_ok_rpl_entry, ACTION_OK_DL_RPL_ENTRY) +default_action_ok_func(action_ok_open_archive_detect_core, ACTION_OK_DL_OPEN_ARCHIVE_DETECT_CORE) +default_action_ok_func(action_ok_file_load_music, ACTION_OK_DL_MUSIC) +default_action_ok_func(action_ok_push_accounts_list, ACTION_OK_DL_ACCOUNTS_LIST) +default_action_ok_func(action_ok_push_driver_settings_list, ACTION_OK_DL_DRIVER_SETTINGS_LIST) +default_action_ok_func(action_ok_push_video_settings_list, ACTION_OK_DL_VIDEO_SETTINGS_LIST) +default_action_ok_func(action_ok_push_configuration_settings_list, ACTION_OK_DL_CONFIGURATION_SETTINGS_LIST) +default_action_ok_func(action_ok_push_core_settings_list, ACTION_OK_DL_CORE_SETTINGS_LIST) +default_action_ok_func(action_ok_push_audio_settings_list, ACTION_OK_DL_AUDIO_SETTINGS_LIST) +default_action_ok_func(action_ok_push_input_settings_list, ACTION_OK_DL_INPUT_SETTINGS_LIST) +default_action_ok_func(action_ok_push_recording_settings_list, ACTION_OK_DL_RECORDING_SETTINGS_LIST) +default_action_ok_func(action_ok_push_playlist_settings_list, ACTION_OK_DL_PLAYLIST_SETTINGS_LIST) +default_action_ok_func(action_ok_push_input_hotkey_binds_list, ACTION_OK_DL_INPUT_HOTKEY_BINDS_LIST) +default_action_ok_func(action_ok_push_user_binds_list, ACTION_OK_DL_USER_BINDS_LIST) +default_action_ok_func(action_ok_push_accounts_cheevos_list, ACTION_OK_DL_ACCOUNTS_CHEEVOS_LIST) +default_action_ok_func(action_ok_open_archive, ACTION_OK_DL_OPEN_ARCHIVE) + static int action_ok_shader_pass(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) { @@ -3252,172 +3210,6 @@ static int action_ok_shader_pass(const char *path, entry_idx, ACTION_OK_DL_SHADER_PASS); } -static int action_ok_shader_parameters(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - return generic_action_ok_displaylist_push(path, NULL, label, type, idx, - entry_idx, ACTION_OK_DL_SHADER_PARAMETERS); -} - -int action_ok_parent_directory_push(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - return generic_action_ok_displaylist_push(path, NULL, label, type, idx, - entry_idx, ACTION_OK_DL_PARENT_DIRECTORY_PUSH); -} - -int action_ok_directory_push(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - return generic_action_ok_displaylist_push(path, NULL, - label, type, idx, - entry_idx, ACTION_OK_DL_DIRECTORY_PUSH); -} - -static int action_ok_database_manager_list(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - return generic_action_ok_displaylist_push(path, NULL, - label, type, idx, - entry_idx, ACTION_OK_DL_DATABASE_MANAGER_LIST); -} - -static int action_ok_cursor_manager_list(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - return generic_action_ok_displaylist_push(path, NULL, - label, type, idx, - entry_idx, ACTION_OK_DL_CURSOR_MANAGER_LIST); -} - -static int action_ok_compressed_archive_push(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - return generic_action_ok_displaylist_push(path, NULL, - label, type, idx, - entry_idx, ACTION_OK_DL_COMPRESSED_ARCHIVE_PUSH); -} - -static int action_ok_compressed_archive_push_detect_core(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - return generic_action_ok_displaylist_push(path, NULL, - label, type, idx, - entry_idx, ACTION_OK_DL_COMPRESSED_ARCHIVE_PUSH_DETECT_CORE); -} - -static int action_ok_configurations_list(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - return generic_action_ok_displaylist_push(path, NULL, label, type, idx, - entry_idx, ACTION_OK_DL_CONFIGURATIONS_LIST); -} - -static int action_ok_saving_list(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - return generic_action_ok_displaylist_push(path, NULL, label, type, idx, - entry_idx, ACTION_OK_DL_SAVING_SETTINGS_LIST); -} - -static int action_ok_logging_list(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - return generic_action_ok_displaylist_push(path, NULL, label, type, idx, - entry_idx, ACTION_OK_DL_LOGGING_SETTINGS_LIST); -} - -static int action_ok_frame_throttle_list(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - return generic_action_ok_displaylist_push(path, NULL, label, type, idx, - entry_idx, ACTION_OK_DL_FRAME_THROTTLE_SETTINGS_LIST); -} - -static int action_ok_rewind_list(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - return generic_action_ok_displaylist_push(path, NULL, label, type, idx, - entry_idx, ACTION_OK_DL_REWIND_SETTINGS_LIST); -} - -static int action_ok_onscreen_display_list(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - return generic_action_ok_displaylist_push(path, NULL, label, type, idx, - entry_idx, ACTION_OK_DL_ONSCREEN_DISPLAY_SETTINGS_LIST); -} - -static int action_ok_onscreen_notifications_list(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - return generic_action_ok_displaylist_push(path, NULL, label, type, idx, - entry_idx, ACTION_OK_DL_ONSCREEN_NOTIFICATIONS_SETTINGS_LIST); -} - -static int action_ok_onscreen_overlay_list(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - return generic_action_ok_displaylist_push(path, NULL, label, type, idx, - entry_idx, ACTION_OK_DL_ONSCREEN_OVERLAY_SETTINGS_LIST); -} - -static int action_ok_menu_list(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - return generic_action_ok_displaylist_push(path, NULL, label, type, idx, - entry_idx, ACTION_OK_DL_MENU_SETTINGS_LIST); -} - -static int action_ok_menu_views_list(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - return generic_action_ok_displaylist_push(path, NULL, label, type, idx, - entry_idx, ACTION_OK_DL_MENU_VIEWS_SETTINGS_LIST); -} - -static int action_ok_user_interface_list(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - return generic_action_ok_displaylist_push(path, NULL, label, type, idx, - entry_idx, ACTION_OK_DL_USER_INTERFACE_SETTINGS_LIST); -} - -static int action_ok_menu_file_browser_list(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - return generic_action_ok_displaylist_push(path, NULL, label, type, idx, - entry_idx, ACTION_OK_DL_MENU_FILE_BROWSER_SETTINGS_LIST); -} - -static int action_ok_retro_achievements_list(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - return generic_action_ok_displaylist_push(path, NULL, label, type, idx, - entry_idx, ACTION_OK_DL_RETRO_ACHIEVEMENTS_SETTINGS_LIST); -} - -static int action_ok_updater_list(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - return generic_action_ok_displaylist_push(path, NULL, label, type, idx, - entry_idx, ACTION_OK_DL_UPDATER_SETTINGS_LIST); -} - -static int action_ok_wifi_list(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - return generic_action_ok_displaylist_push(path, NULL, label, type, idx, - entry_idx, ACTION_OK_DL_WIFI_SETTINGS_LIST); -} - -static int action_ok_network_list(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - return generic_action_ok_displaylist_push(path, NULL, label, type, idx, - entry_idx, ACTION_OK_DL_NETWORK_SETTINGS_LIST); -} - static int action_ok_netplay_connect_room(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) { @@ -3447,7 +3239,7 @@ static int action_ok_netplay_connect_room(const char *path, netplay_room_list[idx - 3].port); } - RARCH_LOG("[lobby] connecting to: %s with game: %s/%08x\n", + RARCH_LOG("[lobby] connecting to: %s with game: %s/%08x\n", tmp_hostname, netplay_room_list[idx - 3].gamename, netplay_room_list[idx - 3].gamecrc); @@ -3463,48 +3255,6 @@ static int action_ok_netplay_connect_room(const char *path, return 0; } -static int action_ok_lakka_services(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - return generic_action_ok_displaylist_push(path, NULL, label, type, idx, - entry_idx, ACTION_OK_DL_LAKKA_SERVICES_LIST); -} - -static int action_ok_user_list(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - return generic_action_ok_displaylist_push(path, NULL, label, type, idx, - entry_idx, ACTION_OK_DL_USER_SETTINGS_LIST); -} - -static int action_ok_netplay_sublist(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - return generic_action_ok_displaylist_push(path, NULL, label, type, idx, - entry_idx, ACTION_OK_DL_NETPLAY); -} - -static int action_ok_directory_list(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - return generic_action_ok_displaylist_push(path, NULL, label, type, idx, - entry_idx, ACTION_OK_DL_DIRECTORY_SETTINGS_LIST); -} - -static int action_ok_privacy_list(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - return generic_action_ok_displaylist_push(path, NULL, label, type, idx, - entry_idx, ACTION_OK_DL_PRIVACY_SETTINGS_LIST); -} - -static int action_ok_rdb_entry(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - return generic_action_ok_displaylist_push(path, NULL, label, type, idx, - entry_idx, ACTION_OK_DL_RDB_ENTRY); -} - static int action_ok_wifi(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) { @@ -3542,21 +3292,10 @@ static int action_ok_netplay_lan_scan(const char *path, netplay_driver_ctl(RARCH_NETPLAY_CTL_ENABLE_CLIENT, NULL); /* Enable Netplay */ - if (!command_event(CMD_EVENT_NETPLAY_INIT_DIRECT, (void *) host)) - return -1; - - return generic_action_ok_command(CMD_EVENT_RESUME); - -#else - return -1; + if (command_event(CMD_EVENT_NETPLAY_INIT_DIRECT, (void *) host)) + return generic_action_ok_command(CMD_EVENT_RESUME); #endif -} - -static int action_ok_browse_url_list(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - return generic_action_ok_displaylist_push(path, NULL, label, type, idx, - entry_idx, ACTION_OK_DL_BROWSE_URL_LIST); + return -1; } static int action_ok_content_collection_list(const char *path, @@ -3567,48 +3306,6 @@ static int action_ok_content_collection_list(const char *path, entry_idx, ACTION_OK_DL_CONTENT_COLLECTION_LIST); } -static int action_ok_core_list(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - return generic_action_ok_displaylist_push(path, NULL, label, type, idx, - entry_idx, ACTION_OK_DL_CORE_LIST); -} - -static int action_ok_cheat_file(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - return generic_action_ok_displaylist_push(path, NULL, label, type, idx, - entry_idx, ACTION_OK_DL_CHEAT_FILE); -} - -static int action_ok_playlist_collection(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - return generic_action_ok_displaylist_push(path, NULL, label, type, idx, - entry_idx, ACTION_OK_DL_PLAYLIST_COLLECTION); -} - -static int action_ok_disk_image_append_list(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - return generic_action_ok_displaylist_push(path, NULL, label, type, idx, - entry_idx, ACTION_OK_DL_DISK_IMAGE_APPEND_LIST); -} - -static int action_ok_record_configfile(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - return generic_action_ok_displaylist_push(path, NULL, label, type, idx, - entry_idx, ACTION_OK_DL_RECORD_CONFIGFILE); -} - -static int action_ok_remap_file(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - return generic_action_ok_displaylist_push(path, NULL, label, type, idx, - entry_idx, ACTION_OK_DL_REMAP_FILE); -} - static int action_ok_push_content_list(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) { @@ -3619,8 +3316,6 @@ static int action_ok_push_content_list(const char *path, entry_idx, ACTION_OK_DL_CONTENT_LIST); } - - static int action_ok_push_scan_file(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) { @@ -3953,20 +3648,6 @@ static int action_ok_push_downloads_dir(const char *path, entry_idx, ACTION_OK_DL_CONTENT_LIST); } -static int action_ok_shader_preset(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - return generic_action_ok_displaylist_push(path, NULL, label, type, idx, - entry_idx, ACTION_OK_DL_SHADER_PRESET); -} - -int action_ok_push_generic_list(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - return generic_action_ok_displaylist_push(path, NULL, label, type, idx, - entry_idx, ACTION_OK_DL_GENERIC); -} - int action_ok_push_filebrowser_list_dir_select(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) { @@ -3993,20 +3674,6 @@ static int action_ok_push_default(const char *path, entry_idx, ACTION_OK_DL_PUSH_DEFAULT); } -static int action_ok_audio_dsp_plugin(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - return generic_action_ok_displaylist_push(path, NULL, label, type, idx, - entry_idx, ACTION_OK_DL_AUDIO_DSP_PLUGIN); -} - -static int action_ok_rpl_entry(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - return generic_action_ok_displaylist_push(path, NULL, label, type, idx, - entry_idx, ACTION_OK_DL_RPL_ENTRY); -} - static int action_ok_start_core(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) { @@ -4023,125 +3690,6 @@ static int action_ok_start_core(const char *path, return 0; } -static int action_ok_open_archive_detect_core(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - return generic_action_ok_displaylist_push(path, NULL, - label, type, idx, entry_idx, - ACTION_OK_DL_OPEN_ARCHIVE_DETECT_CORE); -} - -static int action_ok_file_load_music(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - return generic_action_ok_displaylist_push(path, NULL, - label, type, idx, entry_idx, - ACTION_OK_DL_MUSIC); -} - -static int action_ok_push_accounts_list(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - return generic_action_ok_displaylist_push(path, NULL, - label, type, idx, entry_idx, - ACTION_OK_DL_ACCOUNTS_LIST); -} - -static int action_ok_push_driver_settings_list(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - return generic_action_ok_displaylist_push(path, NULL, - label, type, idx, entry_idx, - ACTION_OK_DL_DRIVER_SETTINGS_LIST); -} - -static int action_ok_push_video_settings_list(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - return generic_action_ok_displaylist_push(path, NULL, - label, type, idx, entry_idx, - ACTION_OK_DL_VIDEO_SETTINGS_LIST); -} - -static int action_ok_push_configuration_settings_list(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - return generic_action_ok_displaylist_push(path, NULL, - label, type, idx, entry_idx, - ACTION_OK_DL_CONFIGURATION_SETTINGS_LIST); -} - -static int action_ok_push_core_settings_list(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - return generic_action_ok_displaylist_push(path, NULL, - label, type, idx, entry_idx, - ACTION_OK_DL_CORE_SETTINGS_LIST); -} - -static int action_ok_push_audio_settings_list(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - return generic_action_ok_displaylist_push(path, NULL, - label, type, idx, entry_idx, - ACTION_OK_DL_AUDIO_SETTINGS_LIST); -} - -static int action_ok_push_input_settings_list(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - return generic_action_ok_displaylist_push(path, NULL, - label, type, idx, entry_idx, - ACTION_OK_DL_INPUT_SETTINGS_LIST); -} - -static int action_ok_push_recording_settings_list(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - return generic_action_ok_displaylist_push(path, NULL, - label, type, idx, entry_idx, - ACTION_OK_DL_RECORDING_SETTINGS_LIST); -} - -static int action_ok_push_playlist_settings_list(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - return generic_action_ok_displaylist_push(path, NULL, - label, type, idx, entry_idx, - ACTION_OK_DL_PLAYLIST_SETTINGS_LIST); -} - -static int action_ok_push_input_hotkey_binds_list(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - return generic_action_ok_displaylist_push(path, NULL, - label, type, idx, entry_idx, - ACTION_OK_DL_INPUT_HOTKEY_BINDS_LIST); -} - -static int action_ok_push_user_binds_list(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - return generic_action_ok_displaylist_push(path, NULL, - label, type, idx, entry_idx, - ACTION_OK_DL_USER_BINDS_LIST); -} - -static int action_ok_push_accounts_cheevos_list(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - return generic_action_ok_displaylist_push(path, NULL, label, type, idx, entry_idx, - ACTION_OK_DL_ACCOUNTS_CHEEVOS_LIST); -} - -static int action_ok_open_archive(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - return generic_action_ok_displaylist_push(path, NULL, - label, type, idx, entry_idx, - ACTION_OK_DL_OPEN_ARCHIVE); -} - static int action_ok_load_archive(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) { @@ -4151,10 +3699,10 @@ static int action_ok_load_archive(const char *path, const char *menu_path = NULL; const char *content_path = NULL; - content_info.argc = 0; - content_info.argv = NULL; - content_info.args = NULL; - content_info.environ_get = NULL; + content_info.argc = 0; + content_info.argv = NULL; + content_info.args = NULL; + content_info.environ_get = NULL; if (!menu_driver_ctl(RARCH_MENU_CTL_DRIVER_DATA_GET, &menu)) return menu_cbs_exit(); @@ -4188,7 +3736,7 @@ static int action_ok_load_archive_detect_core(const char *path, const char *menu_path = NULL; const char *content_path = NULL; - new_core_path[0] = '\0'; + new_core_path[0] = '\0'; if (!menu_driver_ctl(RARCH_MENU_CTL_DRIVER_DATA_GET, &menu)) return menu_cbs_exit(); @@ -4232,12 +3780,10 @@ static int action_ok_load_archive_detect_core(const char *path, } return 0; case 0: - { - idx = menu_navigation_get_selection(); - return generic_action_ok_displaylist_push(path, NULL, - label, type, - idx, entry_idx, ACTION_OK_DL_DEFERRED_CORE_LIST); - } + idx = menu_navigation_get_selection(); + return generic_action_ok_displaylist_push(path, NULL, + label, type, + idx, entry_idx, ACTION_OK_DL_DEFERRED_CORE_LIST); default: break; } @@ -4349,15 +3895,10 @@ static int action_ok_netplay_enable_host(const char *path, } /* Enable Netplay itself */ - if (!command_event(CMD_EVENT_NETPLAY_INIT, NULL)) - return -1; - - return generic_action_ok_command(CMD_EVENT_RESUME); - -#else - return -1; - + if (command_event(CMD_EVENT_NETPLAY_INIT, NULL)) + return generic_action_ok_command(CMD_EVENT_RESUME); #endif + return -1; } #ifdef HAVE_NETWORKING @@ -4412,13 +3953,10 @@ static int action_ok_netplay_enable_client(const char *path, line.label = msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NETPLAY_IP_ADDRESS); line.label_setting = "no_setting"; line.cb = action_ok_netplay_enable_client_hostname_cb; - if (!menu_input_dialog_start(&line)) - return -1; - return 0; - -#else - return -1; + if (menu_input_dialog_start(&line)) + return 0; #endif + return -1; } static int action_ok_netplay_disconnect(const char *path, @@ -4430,7 +3968,7 @@ static int action_ok_netplay_disconnect(const char *path, netplay_driver_ctl(RARCH_NETPLAY_CTL_DISCONNECT, NULL); netplay_driver_ctl(RARCH_NETPLAY_CTL_DISABLE, NULL); - /* Re-enable rewind if it was enabled + /* Re-enable rewind if it was enabled TODO: Add a setting for these tweaks */ if (settings->bools.rewind_enable) command_event(CMD_EVENT_REWIND_INIT, NULL); @@ -4498,25 +4036,22 @@ static int menu_cbs_init_bind_ok_compare_label(menu_file_list_cbs_t *cbs, if (cbs->enum_idx != MSG_UNKNOWN) { - unsigned i; + const char *str = msg_hash_to_str(cbs->enum_idx); - for (i = 0; i < MAX_USERS; i++) + if (str && strstr(str, "input_binds_list")) { - unsigned first_char = 0; - const char *str = msg_hash_to_str(cbs->enum_idx); + unsigned i; - if (!str) - continue; - if (!strstr(str, "input_binds_list")) - continue; + for (i = 0; i < MAX_USERS; i++) + { + unsigned first_char = atoi(&str[0]); - first_char = atoi(&str[0]); + if (first_char != ((i+1))) + continue; - if (first_char != ((i+1))) - continue; - - BIND_ACTION_OK(cbs, action_ok_push_user_binds_list); - return 0; + BIND_ACTION_OK(cbs, action_ok_push_user_binds_list); + return 0; + } } } diff --git a/menu/cbs/menu_cbs_right.c b/menu/cbs/menu_cbs_right.c index 22e2b83c7c..3ad465dac9 100644 --- a/menu/cbs/menu_cbs_right.c +++ b/menu/cbs/menu_cbs_right.c @@ -489,7 +489,6 @@ static int menu_cbs_init_bind_right_compare_type(menu_file_list_cbs_t *cbs, static int menu_cbs_init_bind_right_compare_label(menu_file_list_cbs_t *cbs, const char *label, uint32_t label_hash, const char *menu_label) { - unsigned i; if (cbs->setting) { @@ -503,21 +502,25 @@ static int menu_cbs_init_bind_right_compare_label(menu_file_list_cbs_t *cbs, } } - for (i = 0; i < MAX_USERS; i++) + if (strstr(label, "input_player") && strstr(label, "_joypad_index")) { - uint32_t label_setting_hash; - char label_setting[128]; + unsigned i; + for (i = 0; i < MAX_USERS; i++) + { + uint32_t label_setting_hash; + char label_setting[128]; - label_setting[0] = '\0'; + label_setting[0] = '\0'; - snprintf(label_setting, sizeof(label_setting), "input_player%d_joypad_index", i + 1); - label_setting_hash = msg_hash_calculate(label_setting); + snprintf(label_setting, sizeof(label_setting), "input_player%d_joypad_index", i + 1); + label_setting_hash = msg_hash_calculate(label_setting); - if (label_hash != label_setting_hash) - continue; + if (label_hash != label_setting_hash) + continue; - BIND_ACTION_RIGHT(cbs, bind_right_generic); - return 0; + BIND_ACTION_RIGHT(cbs, bind_right_generic); + return 0; + } } if (string_is_equal(menu_label, msg_hash_to_str(MENU_ENUM_LABEL_PLAYLISTS_TAB))) diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 17239e8c0e..c284f71baa 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -73,6 +73,8 @@ #define XMB_DEBUG #endif +/* NOTE: If you change this you HAVE to update + * xmb_alloc_node() and xmb_copy_node() */ typedef struct { float alpha; @@ -412,6 +414,40 @@ const char* xmb_theme_ident(void) return "monochrome"; } +/* NOTE: This exists because calloc()ing xmb_node_t is expensive + * when you can have big lists like MAME and fba playlists */ +static xmb_node_t *xmb_alloc_node(void) +{ + xmb_node_t *node = (xmb_node_t*)malloc(sizeof(*node)); + + node->alpha = node->label_alpha = 0; + node->zoom = node->x = node->y = 0; + node->icon = node->content_icon = 0; + node->fullpath[0] = 0; + + return node; +} + +/* NOTE: This is faster than memcpy()ing xmb_node_t in most cases + * because most nodes have small (less than 200 bytes) fullpath */ +static xmb_node_t *xmb_copy_node(void *p) +{ + xmb_node_t *old_node = (xmb_node_t*)p; + xmb_node_t *new_node = (xmb_node_t*)malloc(sizeof(*new_node)); + + new_node->alpha = old_node->alpha; + new_node->label_alpha = old_node->label_alpha; + new_node->zoom = old_node->zoom; + new_node->x = old_node->x; + new_node->y = old_node->y; + new_node->icon = old_node->icon; + new_node->content_icon = old_node->content_icon; + + strlcpy(new_node->fullpath, old_node->fullpath, sizeof(old_node->fullpath)); + + return new_node; +} + static const char *xmb_thumbnails_ident(void) { settings_t *settings = config_get_ptr(); @@ -1359,7 +1395,7 @@ static void xmb_list_open_new(xmb_handle_t *xmb, static xmb_node_t *xmb_node_allocate_userdata(xmb_handle_t *xmb, unsigned i) { - xmb_node_t *node = (xmb_node_t*)calloc(1, sizeof(xmb_node_t)); + xmb_node_t *node = xmb_alloc_node(); if (!node) { @@ -2446,16 +2482,16 @@ static void xmb_render(void *data, bool is_idle) if (pointer_enable || mouse_enable) { - size_t selection = menu_navigation_get_selection(); + size_t selection = menu_navigation_get_selection(); + int16_t pointer_y = menu_input_pointer_state(MENU_POINTER_Y_AXIS); + int16_t mouse_y = menu_input_mouse_state(MENU_MOUSE_Y_AXIS) + + (xmb->cursor.size/2); for (i = 0; i < end; i++) { float item_y1 = xmb->margins.screen.top + xmb_item_y(xmb, (int)i, selection); float item_y2 = item_y1 + xmb->icon.size; - int16_t pointer_y = menu_input_pointer_state(MENU_POINTER_Y_AXIS); - int16_t mouse_y = menu_input_mouse_state(MENU_MOUSE_Y_AXIS) - + (xmb->cursor.size/2); if (pointer_enable) { @@ -3706,7 +3742,7 @@ static void xmb_list_insert(void *userdata, node = (xmb_node_t*)menu_entries_get_userdata_at_offset(list, i); if (!node) - node = (xmb_node_t*)calloc(1, sizeof(xmb_node_t)); + node = xmb_alloc_node(); if (!node) { @@ -3779,11 +3815,7 @@ static void xmb_list_deep_copy(const file_list_t *src, file_list_t *dst) void *src_adata = (void*)menu_entries_get_actiondata_at_offset(src, i); if (src_udata) - { - void *data = malloc(sizeof(xmb_node_t)); - memcpy(data, src_udata, sizeof(xmb_node_t)); - file_list_set_userdata(dst, i, data); - } + file_list_set_userdata(dst, i, xmb_copy_node(src_udata)); if (src_adata) { diff --git a/menu/drivers_display/menu_display_vulkan.c b/menu/drivers_display/menu_display_vulkan.c index 5b7577b088..e95353ef33 100644 --- a/menu/drivers_display/menu_display_vulkan.c +++ b/menu/drivers_display/menu_display_vulkan.c @@ -254,19 +254,20 @@ static void menu_display_vk_draw(void *data) default: { - const struct vk_draw_triangles call = { - vk->display.pipelines[ - to_display_pipeline(draw->prim_type, vk->display.blend)], - texture, - texture->mipmap ? - vk->samplers.mipmap_linear : - (texture->default_smooth ? vk->samplers.linear : vk->samplers.nearest), - draw->matrix_data - ? draw->matrix_data : menu_display_vk_get_default_mvp(), - sizeof(math_matrix_4x4), - &range, - draw->coords->vertices, - }; + struct vk_draw_triangles call; + + call.pipeline = vk->display.pipelines[ + to_display_pipeline(draw->prim_type, vk->display.blend)]; + call.texture = texture; + call.sampler = texture->mipmap ? + vk->samplers.mipmap_linear : + (texture->default_smooth ? vk->samplers.linear : vk->samplers.nearest); + call.uniform = draw->matrix_data + ? draw->matrix_data : menu_display_vk_get_default_mvp(); + call.uniform_size = sizeof(math_matrix_4x4); + call.vbo = ⦥ + call.vertices = draw->coords->vertices; + vulkan_draw_triangles(vk, &call); break; } diff --git a/menu/menu_animation.c b/menu/menu_animation.c index 8464a7876c..ce6cfa17dc 100644 --- a/menu/menu_animation.c +++ b/menu/menu_animation.c @@ -44,6 +44,7 @@ struct tween struct menu_animation { struct tween *list; + bool need_defrag; size_t capacity; size_t size; @@ -459,6 +460,8 @@ bool menu_animation_push(menu_animation_ctx_entry_t *entry) *target = t; + anim.need_defrag = true; + return true; } @@ -486,6 +489,7 @@ static void menu_animation_defrag() } anim.first_dead = anim.size; + anim.need_defrag = false; } bool menu_animation_update(float delta_time) @@ -511,6 +515,7 @@ bool menu_animation_update(float delta_time) { *tween->subject = tween->target_value; tween->alive = false; + anim.need_defrag = true; if (tween->cb) tween->cb(); @@ -520,12 +525,14 @@ bool menu_animation_update(float delta_time) active_tweens += 1; } - if (active_tweens) + if (anim.need_defrag) menu_animation_defrag(); - else + + if (!active_tweens) { anim.size = 0; anim.first_dead = 0; + anim.need_defrag = false; return false; } @@ -663,6 +670,8 @@ bool menu_animation_ctl(enum menu_animation_ctl_state state, void *data) if (i < anim.first_dead) anim.first_dead = i; + + anim.need_defrag = true; } } break; @@ -673,7 +682,7 @@ bool menu_animation_ctl(enum menu_animation_ctl_state state, void *data) (menu_animation_ctx_subject_t*)data; float **sub = (float**)subject->data; - for (i = 0; i < anim.size; ++i) + for (i = 0; i < anim.size && killed < subject->count; ++i) { if (!anim.list[i].alive) continue; @@ -690,6 +699,7 @@ bool menu_animation_ctl(enum menu_animation_ctl_state state, void *data) anim.first_dead = i; killed++; + anim.need_defrag = true; break; } } diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index e8b3094cd0..84500376c1 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -177,7 +177,9 @@ finish: state->path, sizeof(parent_dir)); strlcat(parent_dir, file_path_str(FILE_PATH_INDEX_DIRS_URL), sizeof(parent_dir)); - transf = (menu_file_transfer_t*)calloc(1, sizeof(*transf)); + transf = (menu_file_transfer_t*)malloc(sizeof(*transf)); + + transf->enum_idx = MSG_UNKNOWN; strlcpy(transf->path, parent_dir, sizeof(transf->path)); task_push_http_transfer(parent_dir, true, "index_dirs", cb_net_generic_subdir, transf); @@ -5145,6 +5147,9 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, void *data) menu_displaylist_parse_settings_enum(menu, info, MENU_ENUM_LABEL_CORE_ENABLE, PARSE_ONLY_BOOL, false); + menu_displaylist_parse_settings_enum(menu, info, + MENU_ENUM_LABEL_RGUI_SHOW_START_SCREEN, + PARSE_ONLY_BOOL, false); info->need_refresh = true; info->need_push = true; @@ -5161,24 +5166,12 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, void *data) menu_displaylist_parse_settings_enum(menu, info, MENU_ENUM_LABEL_MENU_WALLPAPER_OPACITY, PARSE_ONLY_FLOAT, false); - menu_displaylist_parse_settings_enum(menu, info, - MENU_ENUM_LABEL_PAUSE_LIBRETRO, - PARSE_ONLY_BOOL, false); - menu_displaylist_parse_settings_enum(menu, info, - MENU_ENUM_LABEL_MOUSE_ENABLE, - PARSE_ONLY_BOOL, false); - menu_displaylist_parse_settings_enum(menu, info, - MENU_ENUM_LABEL_POINTER_ENABLE, - PARSE_ONLY_BOOL, false); menu_displaylist_parse_settings_enum(menu, info, MENU_ENUM_LABEL_MENU_LINEAR_FILTER, PARSE_ONLY_BOOL, false); menu_displaylist_parse_settings_enum(menu, info, MENU_ENUM_LABEL_MENU_HORIZONTAL_ANIMATION, PARSE_ONLY_BOOL, false); - menu_displaylist_parse_settings_enum(menu, info, - MENU_ENUM_LABEL_NAVIGATION_WRAPAROUND, - PARSE_ONLY_BOOL, false); menu_displaylist_parse_settings_enum(menu, info, MENU_ENUM_LABEL_ENTRY_NORMAL_COLOR, PARSE_ONLY_HEX, false); @@ -5224,9 +5217,6 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, void *data) menu_displaylist_parse_settings_enum(menu, info, MENU_ENUM_LABEL_MATERIALUI_MENU_FOOTER_OPACITY, PARSE_ONLY_FLOAT, false); - menu_displaylist_parse_settings_enum(menu, info, - MENU_ENUM_LABEL_RGUI_SHOW_START_SCREEN, - PARSE_ONLY_BOOL, false); menu_displaylist_parse_settings_enum(menu, info, MENU_ENUM_LABEL_THUMBNAILS, PARSE_ONLY_UINT, false); @@ -5244,6 +5234,18 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, void *data) menu_displaylist_parse_settings_enum(menu, info, MENU_ENUM_LABEL_SHOW_ADVANCED_SETTINGS, PARSE_ONLY_BOOL, false); + menu_displaylist_parse_settings_enum(menu, info, + MENU_ENUM_LABEL_NAVIGATION_WRAPAROUND, + PARSE_ONLY_BOOL, false); + menu_displaylist_parse_settings_enum(menu, info, + MENU_ENUM_LABEL_PAUSE_LIBRETRO, + PARSE_ONLY_BOOL, false); + menu_displaylist_parse_settings_enum(menu, info, + MENU_ENUM_LABEL_MOUSE_ENABLE, + PARSE_ONLY_BOOL, false); + menu_displaylist_parse_settings_enum(menu, info, + MENU_ENUM_LABEL_POINTER_ENABLE, + PARSE_ONLY_BOOL, false); menu_displaylist_parse_settings_enum(menu, info, MENU_ENUM_LABEL_THREADED_DATA_RUNLOOP_ENABLE, PARSE_ONLY_BOOL, false); diff --git a/menu/menu_entries.c b/menu/menu_entries.c index 84755f68a3..5f5b3f6a56 100644 --- a/menu/menu_entries.c +++ b/menu/menu_entries.c @@ -448,7 +448,11 @@ void menu_entries_append_enum(file_list_t *list, const char *path, file_list_set_actiondata(list, idx, cbs); cbs->enum_idx = enum_idx; - cbs->setting = menu_setting_find_enum(enum_idx); + + if (enum_idx != MENU_ENUM_LABEL_PLAYLIST_ENTRY + && enum_idx != MENU_ENUM_LABEL_PLAYLIST_COLLECTION_ENTRY) { + cbs->setting = menu_setting_find_enum(enum_idx); + } menu_cbs_init(list, cbs, path, label, type, idx); } diff --git a/menu/menu_setting.c b/menu/menu_setting.c index fe0d2db3ed..8294d3dfe2 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -7160,17 +7160,19 @@ static rarch_setting_t *menu_setting_new(void) { rarch_setting_t* list = NULL; rarch_setting_info_t *list_info = (rarch_setting_info_t*) - calloc(1, sizeof(*list_info)); + malloc(sizeof(*list_info)); if (!list_info) return NULL; + list_info->index = 0; list_info->size = 32; - list = menu_setting_new_internal(list_info); + list = menu_setting_new_internal(list_info); menu_settings_info_list_free(list_info); - list_info = NULL; + + list_info = NULL; return list; } diff --git a/pkg/android/phoenix/AndroidManifest.xml b/pkg/android/phoenix/AndroidManifest.xml index e5a1495129..f223ac789e 100644 --- a/pkg/android/phoenix/AndroidManifest.xml +++ b/pkg/android/phoenix/AndroidManifest.xml @@ -1,7 +1,7 @@ diff --git a/pkg/wii/meta.xml b/pkg/wii/meta.xml index 018f8b1fc4..814c0f059a 100644 --- a/pkg/wii/meta.xml +++ b/pkg/wii/meta.xml @@ -2,7 +2,7 @@ RetroArch Libretro - 1.6.4 + 1.6.5 2012-2017 The cross-platform entertainment system A port of RetroArch to the GameCube/Wii. diff --git a/pkg/wiiu/meta.xml b/pkg/wiiu/meta.xml index 3838b59b2b..39c72952e2 100644 --- a/pkg/wiiu/meta.xml +++ b/pkg/wiiu/meta.xml @@ -2,8 +2,8 @@ Retroarch Libretro - 1.64 - 20170108073000 + 1.65 + 20170108133000 RetroArch diff --git a/retroarch.c b/retroarch.c index 95212ace7f..273876455f 100644 --- a/retroarch.c +++ b/retroarch.c @@ -2424,10 +2424,10 @@ static enum runloop_state runloop_check_state( current_input, RARCH_GRAB_MOUSE_TOGGLE); if (pressed && !old_pressed) -#if 1 - command_event(CMD_EVENT_GRAB_MOUSE_TOGGLE, NULL); -#else +#if HAVE_LIBUI command_event(CMD_EVENT_LIBUI_TEST, NULL); +#else + command_event(CMD_EVENT_GRAB_MOUSE_TOGGLE, NULL); #endif old_pressed = pressed; diff --git a/ui/drivers/ui_win32.c b/ui/drivers/ui_win32.c index 116c7844e6..5b2a411390 100644 --- a/ui/drivers/ui_win32.c +++ b/ui/drivers/ui_win32.c @@ -101,7 +101,7 @@ typedef struct HWND label_title; HWND label_val; } trackbar; - }; + } elems; } shader_param_ctrl_t; typedef struct @@ -128,7 +128,7 @@ static bool shader_dlg_refresh_trackbar_label(int index, snprintf(val_buffer, sizeof(val_buffer), "%.2f", shader_info->data->parameters[index].current); - SendMessage(g_shader_dlg.controls[index].trackbar.label_val, + SendMessage(g_shader_dlg.controls[index].elems.trackbar.label_val, WM_SETTEXT, 0, (LPARAM)val_buffer); return true; @@ -155,7 +155,7 @@ static void shader_dlg_params_refresh(void) bool checked = shader_info.data ? (shader_info.data->parameters[i].current == shader_info.data->parameters[i].maximum) : false; - SendMessage(control->checkbox.hwnd, BM_SETCHECK, checked, 0); + SendMessage(control->elems.checkbox.hwnd, BM_SETCHECK, checked, 0); } break; case SHADER_PARAM_CTRL_TRACKBAR: @@ -167,14 +167,14 @@ static void shader_dlg_params_refresh(void) if (shader_info.data) { - SendMessage(control->trackbar.hwnd, + SendMessage(control->elems.trackbar.hwnd, TBM_SETRANGEMIN, (WPARAM)TRUE, (LPARAM)0); - SendMessage(control->trackbar.hwnd, + SendMessage(control->elems.trackbar.hwnd, TBM_SETRANGEMAX, (WPARAM)TRUE, (LPARAM)((shader_info.data->parameters[i].maximum - shader_info.data->parameters[i].minimum) / shader_info.data->parameters[i].step)); - SendMessage(control->trackbar.hwnd, TBM_SETPOS, (WPARAM)TRUE, + SendMessage(control->elems.trackbar.hwnd, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)((shader_info.data->parameters[i].current - shader_info.data->parameters[i].minimum) / shader_info.data->parameters[i].step)); @@ -207,13 +207,13 @@ static void shader_dlg_params_clear(void) { const ui_window_t *window = ui_companion_driver_get_window_ptr(); if (window) - window->destroy(&control->checkbox); + window->destroy(&control->elems.checkbox); } break; case SHADER_PARAM_CTRL_TRACKBAR: - DestroyWindow(control->trackbar.label_title); - DestroyWindow(control->trackbar.label_val); - DestroyWindow(control->trackbar.hwnd); + DestroyWindow(control->elems.trackbar.label_title); + DestroyWindow(control->elems.trackbar.label_val); + DestroyWindow(control->elems.trackbar.hwnd); break; } @@ -260,12 +260,12 @@ void shader_dlg_params_reload(void) } control->type = SHADER_PARAM_CTRL_CHECKBOX; - control->checkbox.hwnd = CreateWindowEx(0, "BUTTON", + control->elems.checkbox.hwnd = CreateWindowEx(0, "BUTTON", shader_info.data->parameters[i].desc, WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX, pos_x, pos_y, SHADER_DLG_CTRL_WIDTH, SHADER_DLG_CHECKBOX_HEIGHT, g_shader_dlg.window.hwnd, (HMENU)(size_t)i, NULL, NULL); - SendMessage(control->checkbox.hwnd, WM_SETFONT, (WPARAM)hFont, MAKELPARAM(TRUE, 0)); + SendMessage(control->elems.checkbox.hwnd, WM_SETFONT, (WPARAM)hFont, MAKELPARAM(TRUE, 0)); pos_y += SHADER_DLG_CHECKBOX_HEIGHT + SHADER_DLG_CTRL_MARGIN; } else @@ -277,29 +277,29 @@ void shader_dlg_params_reload(void) pos_x += SHADER_DLG_WIDTH; } - control->type = SHADER_PARAM_CTRL_TRACKBAR; - control->trackbar.label_title = CreateWindowEx(0, "STATIC", + control->type = SHADER_PARAM_CTRL_TRACKBAR; + control->elems.trackbar.label_title = CreateWindowEx(0, "STATIC", shader_info.data->parameters[i].desc, WS_CHILD | WS_VISIBLE | SS_LEFT, pos_x, pos_y, SHADER_DLG_CTRL_WIDTH, SHADER_DLG_LABEL_HEIGHT, g_shader_dlg.window.hwnd, (HMENU)(size_t)i, NULL, NULL); - SendMessage(control->trackbar.label_title, WM_SETFONT, (WPARAM)hFont, MAKELPARAM(TRUE, 0)); + SendMessage(control->elems.trackbar.label_title, WM_SETFONT, (WPARAM)hFont, MAKELPARAM(TRUE, 0)); pos_y += SHADER_DLG_LABEL_HEIGHT; - control->trackbar.hwnd = CreateWindowEx(0, (LPCSTR)TRACKBAR_CLASS, "", + control->elems.trackbar.hwnd = CreateWindowEx(0, (LPCSTR)TRACKBAR_CLASS, "", WS_CHILD | WS_VISIBLE | TBS_HORZ | TBS_NOTICKS, pos_x + SHADER_DLG_TRACKBAR_LABEL_WIDTH, pos_y, SHADER_DLG_TRACKBAR_WIDTH, SHADER_DLG_TRACKBAR_HEIGHT, g_shader_dlg.window.hwnd, (HMENU)(size_t)i, NULL, NULL); - control->trackbar.label_val = CreateWindowEx(0, "STATIC", "", + control->elems.trackbar.label_val = CreateWindowEx(0, "STATIC", "", WS_CHILD | WS_VISIBLE | SS_LEFT, pos_x, pos_y, SHADER_DLG_TRACKBAR_LABEL_WIDTH, SHADER_DLG_LABEL_HEIGHT, g_shader_dlg.window.hwnd, (HMENU)(size_t)i, NULL, NULL); - SendMessage(control->trackbar.label_val, WM_SETFONT, (WPARAM)hFont, MAKELPARAM(TRUE, 0)); + SendMessage(control->elems.trackbar.label_val, WM_SETFONT, (WPARAM)hFont, MAKELPARAM(TRUE, 0)); - SendMessage(control->trackbar.hwnd, TBM_SETBUDDY, (WPARAM)TRUE, - (LPARAM)control->trackbar.label_val); + SendMessage(control->elems.trackbar.hwnd, TBM_SETBUDDY, (WPARAM)TRUE, + (LPARAM)control->elems.trackbar.label_val); pos_y += SHADER_DLG_TRACKBAR_HEIGHT + SHADER_DLG_CTRL_MARGIN; @@ -402,7 +402,7 @@ static LRESULT CALLBACK ShaderDlgWndProc(HWND hwnd, UINT message, video_shader_ctx_t shader_info; video_shader_driver_get_current_shader(&shader_info); - if (SendMessage(g_shader_dlg.controls[i].checkbox.hwnd, + if (SendMessage(g_shader_dlg.controls[i].elems.checkbox.hwnd, BM_GETCHECK, 0, 0) == BST_CHECKED) shader_info.data->parameters[i].current = shader_info.data->parameters[i].maximum; @@ -424,7 +424,7 @@ static LRESULT CALLBACK ShaderDlgWndProc(HWND hwnd, UINT message, if (g_shader_dlg.controls[i].type != SHADER_PARAM_CTRL_TRACKBAR) break; - pos = (int)SendMessage(g_shader_dlg.controls[i].trackbar.hwnd, TBM_GETPOS, 0, 0); + pos = (int)SendMessage(g_shader_dlg.controls[i].elems.trackbar.hwnd, TBM_GETPOS, 0, 0); { diff --git a/ui/drivers/win32/ui_win32_browser_window.c b/ui/drivers/win32/ui_win32_browser_window.c index 93dcaa8a55..61c05e6907 100644 --- a/ui/drivers/win32/ui_win32_browser_window.c +++ b/ui/drivers/win32/ui_win32_browser_window.c @@ -25,17 +25,33 @@ static bool ui_browser_window_win32_core(ui_browser_window_state_t *state, bool save) { - OPENFILENAME ofn = {}; + OPENFILENAME ofn; - ofn.lStructSize = sizeof(OPENFILENAME); - ofn.hwndOwner = (HWND)state->window; - ofn.lpstrFilter = state->filters; /* actually const */ - ofn.lpstrFile = state->path; - ofn.lpstrTitle = state->title; - ofn.lpstrInitialDir = state->startdir; - ofn.lpstrDefExt = ""; - ofn.nMaxFile = PATH_MAX; - ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_NOCHANGEDIR; + ofn.lStructSize = sizeof(OPENFILENAME); + ofn.hwndOwner = (HWND)state->window; + ofn.hInstance = NULL; + ofn.lpstrFilter = state->filters; /* actually const */ + ofn.lpstrCustomFilter = NULL; + ofn.nMaxCustFilter = 0; + ofn.nFilterIndex = 0; + ofn.lpstrFile = state->path; + ofn.nMaxFile = PATH_MAX; + ofn.lpstrFileTitle = NULL; + ofn.nMaxFileTitle = 0; + ofn.lpstrInitialDir = state->startdir; + ofn.lpstrTitle = state->title; + ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_NOCHANGEDIR; + ofn.nFileOffset = 0; + ofn.nFileExtension = 0; + ofn.lpstrDefExt = ""; + ofn.lCustData = 0; + ofn.lpfnHook = NULL; + ofn.lpTemplateName = NULL; +#if (_WIN32_WINNT >= 0x0500) + ofn.pvReserved = NULL; + ofn.dwReserved = 0; + ofn.FlagsEx = 0; +#endif if (!save && !GetOpenFileName(&ofn)) return false; diff --git a/version.h b/version.h index d55f77f791..2beaab26a2 100644 --- a/version.h +++ b/version.h @@ -18,7 +18,7 @@ #define RARCH_VERSION_H__ #ifndef PACKAGE_VERSION -#define PACKAGE_VERSION "1.6.4" +#define PACKAGE_VERSION "1.6.5" #endif #endif