Fix problem dropping files when a popup window is opened.

This commit is contained in:
David Capello 2012-03-21 19:56:39 -03:00
parent c47ac99d86
commit 0b19612860
3 changed files with 18 additions and 3 deletions

View File

@ -21,13 +21,13 @@
#include <allegro.h>
#include <vector>
#include "gui/frame.h"
#include "app.h"
#include "base/mutex.h"
#include "base/scoped_lock.h"
#include "commands/commands.h"
#include "commands/params.h"
#include "gui/frame.h"
#include "gui/manager.h"
#include "ui_context.h"
#ifdef ALLEGRO_WINDOWS
@ -73,7 +73,9 @@ void check_for_dropped_files()
if (!base_wnd_proc) // drop-files hook not installed
return;
if (!app_get_top_window()->is_toplevel())
// If the main window is not the current foreground one. We discard
// the drop-files event.
if (jmanager_get_foreground_window() != app_get_top_window())
return;
ScopedLock lock(*dropped_files_mutex);

View File

@ -723,6 +723,18 @@ JWidget jmanager_get_top_window()
return NULL;
}
JWidget jmanager_get_foreground_window()
{
JLink link;
JI_LIST_FOR_EACH(default_manager->children, link) {
Frame* frame = (Frame*)link->data;
if (frame->is_foreground() ||
frame->is_desktop())
return frame;
}
return NULL;
}
JWidget jmanager_get_focus()
{
return focus_widget;

View File

@ -34,6 +34,7 @@ bool jmanager_timer_is_running(int timer_id);
void jmanager_enqueue_message(Message* msg);
JWidget jmanager_get_top_window();
JWidget jmanager_get_foreground_window();
JWidget jmanager_get_focus();
JWidget jmanager_get_mouse();