Create window_focused callback

This commit is contained in:
twinaphex 2016-06-04 17:24:46 +02:00
parent b5830de236
commit fc9954d967
4 changed files with 24 additions and 0 deletions

View File

@ -70,11 +70,21 @@ void ui_window_cocoa_set_droppable(void *data, bool droppable)
}
}
bool ui_window_cocoa_focused(void *data)
{
ui_window_cocoa_t *cocoa = (ui_window_cocoa_t*)data;
CocoaView *cocoa_view = (CocoaView*)cocoa->data;
if ([[cocoa_view window] isMainWindow] == YES)
return true;
return false;
}
const ui_window_t ui_window_cocoa = {
ui_window_cocoa_destroy,
ui_window_cocoa_set_focused,
ui_window_cocoa_set_visible,
ui_window_cocoa_set_title,
ui_window_cocoa_set_droppable,
ui_window_cocoa_focused,
"cocoa"
};

View File

@ -42,11 +42,17 @@ static void ui_window_null_set_droppable(void *data, bool droppable)
{
}
static bool ui_window_null_focused(void *data)
{
return true;
}
const ui_window_t ui_window_null = {
ui_window_null_destroy,
ui_window_null_set_focused,
ui_window_null_set_visible,
ui_window_null_set_title,
ui_window_null_set_droppable,
ui_window_null_focused,
"null"
};

View File

@ -79,11 +79,18 @@ void ui_window_win32_set_droppable(void *data, bool droppable)
DragAcceptFiles(window->hwnd, droppable);
}
bool ui_window_win32_focused(void *data)
{
ui_window_win32_t *window = (ui_window_win32_t*)data;
return (GetForeGroundWindow() == window->hwnd);
}
const ui_window_t ui_window_win32 = {
ui_window_win32_destroy,
ui_window_win32_set_focused,
ui_window_win32_set_visible,
ui_window_win32_set_title,
ui_window_win32_set_droppable,
ui_window_win32_focused,
"win32"
};

View File

@ -38,6 +38,7 @@ typedef struct ui_window
void (*set_visible)(void *data, bool visible);
void (*set_title)(void *data, char *buf);
void (*set_droppable)(void *data, bool droppable);
bool (*focused)(void *data);
const char *ident;
} ui_window_t;