bool windows_tray_notification::show(std::string title, std::string message)
{
	adjust_length(title, message);

	const bool tray_icon_exist = nid != NULL;
	if (!tray_icon_exist) {
		const bool tray_icon_created = create_tray_icon();
		if (!tray_icon_created) {
			const bool memory_allocated = nid != NULL;
			if (memory_allocated) {
				destroy_tray_icon();
			}
			return false;
		}
	}

	// at this point tray icon was just created or already existed before, so it's safe to call `set_tray_message`

	const bool result = set_tray_message(title, message);
	// the `destroy_tray_icon` will be called by event only if `set_tray_message` succeeded
	// if it doesn't succeed, we have to call `destroy_tray_icon` manually
	if (!result) {
		destroy_tray_icon();
	}
	return result;
}
void windows_tray_notification::handle_system_event(const SDL_Event& event)
{
	if (event.syswm.msg->msg.win.msg != WM_TRAYNOTIFY) {
		return;
	}

	if (event.syswm.msg->msg.win.lParam == NIN_BALLOONUSERCLICK) {
		switch_to_wesnoth_window();
		destroy_tray_icon();
	} else if (event.syswm.msg->msg.win.lParam == NIN_BALLOONTIMEOUT) {
		destroy_tray_icon();
	}
	// Scenario: More than one notification arrives before the time-out triggers the tray icon destruction.
	// Problem: Events seem to be triggered differently in SDL 2.0. For the example of two notifications arriving at once:
	//	1. Balloon created for first notification
	//	2. Balloon created for second notification (message_reset set to true because of first notification already present)
	//	3. Balloon time-out for first notification (destroy_tray_icon skips tray icon destruction because of message_reset flag)
	//	4.	SDL 1.2: Balloon time-out for second notification (destroy_tray_icon destroys tray icon)
	//		SDL 2.0: Balloon time-out for second notification event is never received (tray icon remains indefinitely)
	// This results in the tray icon being 'stuck' until the user quits Wesnoth *and* hovers over the tray icon (and is only then killed off by the OS).
	// As a less-than-ideal-but-better-than-nothing-solution, call destroy_tray_icon when the user hovers mouse cursor over the tray icon. At least then the tray is 'reset'.
	// I could not find the matching definition for 0x0200 in the headers, but this message value is received when the mouse cursor is over the tray icon.
	// Drawback: The tray icon can still get 'stuck' if the user does not move the mouse cursor over the tray icon.
	//	Also, accidental destruction of the tray icon can occur if the user moves the mouse cursor over the tray icon before the balloon for a single notification has expired.
	else if (event.syswm.msg->msg.win.lParam == 0x0200 && !message_reset) {
		destroy_tray_icon();
	}
}
void windows_tray_notification::handle_system_event(const SDL_Event& event)
{
	if (event.syswm.msg->msg != WM_TRAYNOTIFY) {
		return;
	}

	if (event.syswm.msg->lParam == NIN_BALLOONUSERCLICK) {
		switch_to_wesnoth_window();
		destroy_tray_icon();
	} else if (event.syswm.msg->lParam == NIN_BALLOONTIMEOUT) {
		destroy_tray_icon();
	}
}
Beispiel #4
0
void destroy_tray()
{
  if (current_hime_win32_icon)
    destroy_tray_win32();
  else
    destroy_tray_icon();
}
Beispiel #5
0
void destroy_tray()
{
// TODO: optimze it , e.g. struct
  if (is_exist_tray())
    destroy_tray_icon();
  if (is_exist_tray_double())
    destroy_tray_double();
#if TRAY_UNITY
  if (is_exist_tray_appindicator())
    destroy_tray_appindicator();
#endif
}
Beispiel #6
0
void destroy_other_tray()
{
  if (!hime_status_tray) {
    destroy_tray();
    return;
  }
  if (is_exist_tray() && hime_tray_display != HIME_TRAY_DISPLAY_SINGLE)
    destroy_tray_icon();
  if (is_exist_tray_double() && hime_tray_display != HIME_TRAY_DISPLAY_DOUBLE)
    destroy_tray_double();
#if TRAY_UNITY
  if (is_exist_tray_appindicator() && hime_tray_display != HIME_TRAY_DISPLAY_APPINDICATOR)
    destroy_tray_appindicator();
#endif
}