PDA

View Full Version : Is GUI_EVENT evil?



Asuna Yuuki Nagato
02-08-2024, 09:46 PM
GUI_EVENT is a macro #defined in jwin.h:



#define GUI_EVENT(dlg, event) \
do \
{ \
if(dlg->flags&D_NEW_GUI) \
{ \
int32_t ret = new_gui_event(dlg-1, event); \
if(ret >= 0) \
return ret; \
} \
} while(false)


Is it evil? What abuse is occurring here in top_level.cpp?



int32_t TopLevelWidget::proc(int32_t msg, DIALOG* d, int32_t c)
{
if(msg == MSG_XCHAR)
{
uint16_t actual = (key_shifts&0x07)|(c&0xFF00);
if(actual == d->d1)
// Abusing the mechanism here slightly...
GUI_EVENT(d, (guiEvent)(-(d->d1+1)));
}
return D_O_K;
}


Should we refactor it?