#include ONCE "window9.bi"

sub SetPositionMenuPopupSub cdecl(menu as any ptr, x as gint ptr, y as gint ptr, push_in as gboolean ptr, user_data as gpointer)
	
	*x = loword(user_data)
	
	*y = hiword(user_data)
	
End Sub

sub DisplayPopupMenu(menu as HMENU , iXpos as Long  = FB_IGNORE, iYpos as Long = FB_IGNORE , hwnd as HWND = 0 , iFlag as Long = 0 ) export
	
	if iXpos = FB_IGNORE then
		
		iXpos = GlobalMouseX	
		
	EndIf
	
	if iYpos = FB_IGNORE then
		
		iYpos = GlobalMouseY	
		
	EndIf	
	
	dim as Long pData = Makelong(iXpos , iYpos)
	
	if hwnd = 0 then
	
		gtk_menu_popup (menu, 0, 0, cast(any ptr ,@SetPositionMenuPopupSub), cast(gpointer, cast(integer,pData)), 0, gtk_get_current_event_time())
		
	else

		gtk_menu_popup (menu, 0, 0, cast(any ptr ,@gtk_status_icon_position_menu), cast(gpointer, hwnd), 0, gtk_get_current_event_time())

	EndIf
	
End Sub