comparison android/dw.cpp @ 2626:401a3b9f21ba

Massive continuation of code style standardization. Only tested on Mac and iOS, may require follow up commits to get things building again as I test on various platforms.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Sun, 01 Aug 2021 12:17:07 +0000
parents dcd71b04cc46
children e9f4f0d2e5da
comparison
equal deleted inserted replaced
2625:2e804b4db81e 2626:401a3b9f21ba
197 197
198 /* Launch the new thread to execute dwmain() */ 198 /* Launch the new thread to execute dwmain() */
199 dw_thread_new((void *) _dw_main_launch, arg, 0); 199 dw_thread_new((void *) _dw_main_launch, arg, 0);
200 } 200 }
201 201
202 typedef struct _sighandler 202 typedef struct _dwsighandler
203 { 203 {
204 struct _sighandler *next; 204 struct _dwsighandler *next;
205 ULONG message; 205 ULONG message;
206 HWND window; 206 HWND window;
207 int id; 207 int id;
208 void *signalfunction; 208 void *signalfunction;
209 void *discfunction; 209 void *discfunction;
210 void *data; 210 void *data;
211 211
212 } SignalHandler; 212 } DWSignalHandler;
213 213
214 static SignalHandler *DWRoot = nullptr; 214 static DWSignalHandler *DWRoot = nullptr;
215 215
216 SignalHandler *_dw_get_handler(HWND window, int messageid) 216 DWSignalHandler *_dw_get_handler(HWND window, int messageid)
217 { 217 {
218 SignalHandler *tmp = DWRoot; 218 DWSignalHandler *tmp = DWRoot;
219 JNIEnv *env; 219 JNIEnv *env;
220 220
221 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key))) { 221 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key))) {
222 /* Find any callbacks for this function */ 222 /* Find any callbacks for this function */
223 while (tmp) { 223 while (tmp) {
264 264
265 #define _DW_EVENT_PARAM_SIZE 10 265 #define _DW_EVENT_PARAM_SIZE 10
266 266
267 int _dw_event_handler2(void **params) 267 int _dw_event_handler2(void **params)
268 { 268 {
269 SignalHandler *handler = (SignalHandler *)params[9]; 269 DWSignalHandler *handler = (DWSignalHandler *)params[9];
270 int message = DW_POINTER_TO_INT(params[8]); 270 int message = DW_POINTER_TO_INT(params[8]);
271 int retval = -1; 271 int retval = -1;
272 272
273 if(handler) 273 if(handler)
274 { 274 {
459 #endif 459 #endif
460 return retval; 460 return retval;
461 } 461 }
462 462
463 int _dw_event_handler(jobject object, void **params) { 463 int _dw_event_handler(jobject object, void **params) {
464 SignalHandler *handler = _dw_get_handler(object, DW_POINTER_TO_INT(params[8])); 464 DWSignalHandler *handler = _dw_get_handler(object, DW_POINTER_TO_INT(params[8]));
465 465
466 if (handler) 466 if (handler)
467 { 467 {
468 params[9] = (void *)handler; 468 params[9] = (void *)handler;
469 469
659 659
660 /* This function adds a signal handler callback into the linked list. 660 /* This function adds a signal handler callback into the linked list.
661 */ 661 */
662 void _dw_new_signal(ULONG message, HWND window, int msgid, void *signalfunction, void *discfunc, void *data) 662 void _dw_new_signal(ULONG message, HWND window, int msgid, void *signalfunction, void *discfunc, void *data)
663 { 663 {
664 SignalHandler *newsig = (SignalHandler *)malloc(sizeof(SignalHandler)); 664 DWSignalHandler *newsig = (DWSignalHandler *)malloc(sizeof(DWSignalHandler));
665 665
666 newsig->message = message; 666 newsig->message = message;
667 newsig->window = window; 667 newsig->window = window;
668 newsig->id = msgid; 668 newsig->id = msgid;
669 newsig->signalfunction = signalfunction; 669 newsig->signalfunction = signalfunction;
673 673
674 if (!DWRoot) 674 if (!DWRoot)
675 DWRoot = newsig; 675 DWRoot = newsig;
676 else 676 else
677 { 677 {
678 SignalHandler *prev = nullptr, *tmp = DWRoot; 678 DWSignalHandler *prev = nullptr, *tmp = DWRoot;
679 while(tmp) 679 while(tmp)
680 { 680 {
681 if(tmp->message == message && 681 if(tmp->message == message &&
682 tmp->window == window && 682 tmp->window == window &&
683 tmp->id == msgid && 683 tmp->id == msgid &&
5911 * Parameters: 5911 * Parameters:
5912 * window: Window handle of callback to be removed. 5912 * window: Window handle of callback to be removed.
5913 */ 5913 */
5914 void API dw_signal_disconnect_by_name(HWND window, const char *signame) 5914 void API dw_signal_disconnect_by_name(HWND window, const char *signame)
5915 { 5915 {
5916 SignalHandler *prev = nullptr, *tmp = DWRoot; 5916 DWSignalHandler *prev = nullptr, *tmp = DWRoot;
5917 ULONG message; 5917 ULONG message;
5918 5918
5919 if(!window || !signame || (message = _dw_findsigmessage(signame)) == 0) 5919 if(!window || !signame || (message = _dw_findsigmessage(signame)) == 0)
5920 return; 5920 return;
5921 5921
5956 * Parameters: 5956 * Parameters:
5957 * window: Window handle of callback to be removed. 5957 * window: Window handle of callback to be removed.
5958 */ 5958 */
5959 void API dw_signal_disconnect_by_window(HWND window) 5959 void API dw_signal_disconnect_by_window(HWND window)
5960 { 5960 {
5961 SignalHandler *prev = nullptr, *tmp = DWRoot; 5961 DWSignalHandler *prev = nullptr, *tmp = DWRoot;
5962 5962
5963 while(tmp) 5963 while(tmp)
5964 { 5964 {
5965 if(tmp->window == window) 5965 if(tmp->window == window)
5966 { 5966 {
5998 * window: Window handle of callback to be removed. 5998 * window: Window handle of callback to be removed.
5999 * data: Pointer to the data to be compared against. 5999 * data: Pointer to the data to be compared against.
6000 */ 6000 */
6001 void API dw_signal_disconnect_by_data(HWND window, void *data) 6001 void API dw_signal_disconnect_by_data(HWND window, void *data)
6002 { 6002 {
6003 SignalHandler *prev = nullptr, *tmp = DWRoot; 6003 DWSignalHandler *prev = nullptr, *tmp = DWRoot;
6004 6004
6005 while(tmp) 6005 while(tmp)
6006 { 6006 {
6007 if(tmp->window == window && tmp->data == data) 6007 if(tmp->window == window && tmp->data == data)
6008 { 6008 {