mirror of
https://github.com/encounter/SDL.git
synced 2025-12-10 05:57:44 +00:00
* Some refactoring and bug fixes. Thanks Micha? Kuchta!
This commit is contained in:
@@ -210,6 +210,7 @@ ShouldUseTextureFramebuffer()
|
||||
#if SDL_VIDEO_OPENGL
|
||||
/* Ugh, find a way to cache this value! */
|
||||
{
|
||||
/*
|
||||
SDL_Window *window;
|
||||
SDL_GLContext context;
|
||||
SDL_bool hasAcceleratedOpenGL = SDL_FALSE;
|
||||
@@ -225,7 +226,6 @@ ShouldUseTextureFramebuffer()
|
||||
if (glGetStringFunc) {
|
||||
vendor = (const char *) glGetStringFunc(GL_VENDOR);
|
||||
}
|
||||
/* Add more vendors here at will... */
|
||||
if (vendor &&
|
||||
(SDL_strstr(vendor, "ATI Technologies") ||
|
||||
SDL_strstr(vendor, "NVIDIA"))) {
|
||||
@@ -235,7 +235,8 @@ ShouldUseTextureFramebuffer()
|
||||
}
|
||||
SDL_DestroyWindow(window);
|
||||
}
|
||||
return hasAcceleratedOpenGL;
|
||||
*/
|
||||
return 1;//hasAcceleratedOpenGL;
|
||||
}
|
||||
#elif SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2
|
||||
/* Let's be optimistic about this! */
|
||||
|
||||
@@ -237,7 +237,7 @@ HandleMouseEvent(MirPointerEvent const* pointer, SDL_Window* sdl_window)
|
||||
}
|
||||
|
||||
static void
|
||||
MIR_HandleInput(MirInputEvent const* input_event, SDL_Window* window)
|
||||
HandleInput(MirInputEvent const* input_event, SDL_Window* window)
|
||||
{
|
||||
switch (MIR_mir_input_event_get_type(input_event)) {
|
||||
case (mir_input_event_type_key):
|
||||
@@ -257,7 +257,7 @@ MIR_HandleInput(MirInputEvent const* input_event, SDL_Window* window)
|
||||
}
|
||||
|
||||
static void
|
||||
MIR_HandleResize(MirResizeEvent const* resize_event, SDL_Window* window)
|
||||
HandleResize(MirResizeEvent const* resize_event, SDL_Window* window)
|
||||
{
|
||||
int new_w = MIR_mir_resize_event_get_width (resize_event);
|
||||
int new_h = MIR_mir_resize_event_get_height(resize_event);
|
||||
@@ -270,7 +270,7 @@ MIR_HandleResize(MirResizeEvent const* resize_event, SDL_Window* window)
|
||||
}
|
||||
|
||||
static void
|
||||
MIR_HandleWindow(MirWindowEvent const* event, SDL_Window* window)
|
||||
HandleWindow(MirWindowEvent const* event, SDL_Window* window)
|
||||
{
|
||||
MirWindowAttrib attrib = MIR_mir_window_event_get_attribute(event);
|
||||
int value = MIR_mir_window_event_get_attribute_value(event);
|
||||
@@ -294,13 +294,13 @@ MIR_HandleEvent(MirWindow* mirwindow, MirEvent const* ev, void* context)
|
||||
if (window) {
|
||||
switch (event_type) {
|
||||
case (mir_event_type_input):
|
||||
MIR_HandleInput(MIR_mir_event_get_input_event(ev), window);
|
||||
HandleInput(MIR_mir_event_get_input_event(ev), window);
|
||||
break;
|
||||
case (mir_event_type_resize):
|
||||
MIR_HandleResize(MIR_mir_event_get_resize_event(ev), window);
|
||||
HandleResize(MIR_mir_event_get_resize_event(ev), window);
|
||||
break;
|
||||
case (mir_event_type_window):
|
||||
MIR_HandleWindow(MIR_mir_event_get_window_event(ev), window);
|
||||
HandleWindow(MIR_mir_event_get_window_event(ev), window);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
@@ -27,6 +27,8 @@
|
||||
|
||||
#if SDL_VIDEO_DRIVER_MIR
|
||||
|
||||
#include "SDL_log.h"
|
||||
|
||||
#include "SDL_mirwindow.h"
|
||||
#include "SDL_video.h"
|
||||
|
||||
@@ -98,7 +100,19 @@ MIR_Available()
|
||||
int available = 0;
|
||||
|
||||
if (SDL_MIR_LoadSymbols()) {
|
||||
/* !!! FIXME: try to make a MirConnection here. */
|
||||
|
||||
/* Lets ensure we can connect to the mir server */
|
||||
MirConnection* connection = MIR_mir_connect_sync(NULL, __PRETTY_FUNCTION__);
|
||||
|
||||
if (!MIR_mir_connection_is_valid(connection)) {
|
||||
SDL_LogWarn(SDL_LOG_CATEGORY_VIDEO, "Unable to connect to the mir server %s",
|
||||
MIR_mir_connection_get_error_message(connection));
|
||||
|
||||
return available;
|
||||
}
|
||||
|
||||
MIR_mir_connection_release(connection);
|
||||
|
||||
available = 1;
|
||||
SDL_MIR_UnloadSymbols();
|
||||
}
|
||||
|
||||
@@ -37,14 +37,14 @@
|
||||
#include "SDL_mirdyn.h"
|
||||
|
||||
int
|
||||
IsSurfaceValid(MIR_Window* mir_window)
|
||||
IsMirWindowValid(MIR_Window* mir_window)
|
||||
{
|
||||
if (!MIR_mir_window_is_valid(mir_window->window)) {
|
||||
const char* error = MIR_mir_window_get_error_message(mir_window->window);
|
||||
return SDL_SetError("Failed to created a mir surface: %s", error);
|
||||
}
|
||||
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
MirPixelFormat
|
||||
@@ -194,153 +194,90 @@ MIR_GetWindowWMInfo(_THIS, SDL_Window* window, SDL_SysWMinfo* info)
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
UpdateMirWindowState(MIR_Data* mir_data, MIR_Window* mir_window, MirWindowState window_state)
|
||||
{
|
||||
if (IsMirWindowValid(mir_window)) {
|
||||
MirWindowSpec* spec = MIR_mir_create_window_spec(mir_data->connection);
|
||||
MIR_mir_window_spec_set_state(spec, window_state);
|
||||
|
||||
MIR_mir_window_apply_spec(mir_window->window, spec);
|
||||
MIR_mir_window_spec_release(spec);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
MIR_SetWindowFullscreen(_THIS, SDL_Window* window,
|
||||
SDL_VideoDisplay* display,
|
||||
SDL_bool fullscreen)
|
||||
{
|
||||
MIR_Data* mir_data = _this->driverdata;
|
||||
MIR_Window* mir_window = window->driverdata;
|
||||
MirWindowSpec* spec;
|
||||
MirWindowState state;
|
||||
if (IsMirWindowValid(window->driverdata)) {
|
||||
MirWindowState state;
|
||||
|
||||
if (IsSurfaceValid(mir_window) < 0)
|
||||
return;
|
||||
if (fullscreen) {
|
||||
state = mir_window_state_fullscreen;
|
||||
}
|
||||
else {
|
||||
state = mir_window_state_restored;
|
||||
}
|
||||
|
||||
if (fullscreen) {
|
||||
state = mir_window_state_fullscreen;
|
||||
} else {
|
||||
state = mir_window_state_restored;
|
||||
UpdateMirWindowState(_this->driverdata, window->driverdata, state);
|
||||
}
|
||||
|
||||
spec = MIR_mir_create_window_spec(mir_data->connection);
|
||||
MIR_mir_window_spec_set_state(spec, state);
|
||||
|
||||
MIR_mir_window_apply_spec(mir_window->window, spec);
|
||||
MIR_mir_window_spec_release(spec);
|
||||
}
|
||||
|
||||
void
|
||||
MIR_MaximizeWindow(_THIS, SDL_Window* window)
|
||||
{
|
||||
MIR_Data* mir_data = _this->driverdata;
|
||||
MIR_Window* mir_window = window->driverdata;
|
||||
MirWindowSpec* spec;
|
||||
|
||||
if (IsSurfaceValid(mir_window) < 0)
|
||||
return;
|
||||
|
||||
spec = MIR_mir_create_window_spec(mir_data->connection);
|
||||
MIR_mir_window_spec_set_state(spec, mir_window_state_maximized);
|
||||
|
||||
MIR_mir_window_apply_spec(mir_window->window, spec);
|
||||
MIR_mir_window_spec_release(spec);
|
||||
UpdateMirWindowState(_this->driverdata, window->driverdata, mir_window_state_maximized);
|
||||
}
|
||||
|
||||
void
|
||||
MIR_MinimizeWindow(_THIS, SDL_Window* window)
|
||||
{
|
||||
MIR_Data* mir_data = _this->driverdata;
|
||||
MIR_Window* mir_window = window->driverdata;
|
||||
MirWindowSpec* spec;
|
||||
|
||||
if (IsSurfaceValid(mir_window) < 0)
|
||||
return;
|
||||
|
||||
spec = MIR_mir_create_window_spec(mir_data->connection);
|
||||
MIR_mir_window_spec_set_state(spec, mir_window_state_minimized);
|
||||
|
||||
MIR_mir_window_apply_spec(mir_window->window, spec);
|
||||
MIR_mir_window_spec_release(spec);
|
||||
UpdateMirWindowState(_this->driverdata, window->driverdata, mir_window_state_minimized);
|
||||
}
|
||||
|
||||
void
|
||||
MIR_RestoreWindow(_THIS, SDL_Window * window)
|
||||
{
|
||||
MIR_Data* mir_data = _this->driverdata;
|
||||
MIR_Window* mir_window = window->driverdata;
|
||||
MirWindowSpec* spec;
|
||||
|
||||
if (IsSurfaceValid(mir_window) < 0)
|
||||
return;
|
||||
|
||||
spec = MIR_mir_create_window_spec(mir_data->connection);
|
||||
MIR_mir_window_spec_set_state(spec, mir_window_state_restored);
|
||||
|
||||
MIR_mir_window_apply_spec(mir_window->window, spec);
|
||||
MIR_mir_window_spec_release(spec);
|
||||
UpdateMirWindowState(_this->driverdata, window->driverdata, mir_window_state_restored);
|
||||
}
|
||||
|
||||
void
|
||||
MIR_HideWindow(_THIS, SDL_Window* window)
|
||||
{
|
||||
MIR_Data* mir_data = _this->driverdata;
|
||||
MIR_Window* mir_window = window->driverdata;
|
||||
MirWindowSpec* spec;
|
||||
UpdateMirWindowState(_this->driverdata, window->driverdata, mir_window_state_hidden);
|
||||
}
|
||||
|
||||
if (IsSurfaceValid(mir_window) < 0)
|
||||
return;
|
||||
static void
|
||||
UpdateMirWindowSize(MIR_Data* mir_data, MIR_Window* mir_window, int width, int height)
|
||||
{
|
||||
if (IsMirWindowValid(mir_window)) {
|
||||
MirWindowSpec* spec = MIR_mir_create_window_spec(mir_data->connection);
|
||||
MIR_mir_window_spec_set_width (spec, width);
|
||||
MIR_mir_window_spec_set_height(spec, height);
|
||||
|
||||
spec = MIR_mir_create_window_spec(mir_data->connection);
|
||||
MIR_mir_window_spec_set_state(spec, mir_window_state_hidden);
|
||||
|
||||
MIR_mir_window_apply_spec(mir_window->window, spec);
|
||||
MIR_mir_window_spec_release(spec);
|
||||
MIR_mir_window_apply_spec(mir_window->window, spec);
|
||||
MIR_mir_window_spec_release(spec);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
MIR_SetWindowSize(_THIS, SDL_Window* window)
|
||||
{
|
||||
MIR_Data* mir_data = _this->driverdata;
|
||||
MIR_Window* mir_window = window->driverdata;
|
||||
MirWindowSpec* spec;
|
||||
|
||||
if (IsSurfaceValid(mir_window) < 0)
|
||||
return;
|
||||
|
||||
/* You cannot set the x/y of a mir window! So only update w/h */
|
||||
spec = MIR_mir_create_window_spec(mir_data->connection);
|
||||
MIR_mir_window_spec_set_width (spec, window->w);
|
||||
MIR_mir_window_spec_set_height(spec, window->h);
|
||||
|
||||
MIR_mir_window_apply_spec(mir_window->window, spec);
|
||||
MIR_mir_window_spec_release(spec);
|
||||
UpdateMirWindowSize(_this->driverdata, window->driverdata, window->w, window->h);
|
||||
}
|
||||
|
||||
void
|
||||
MIR_SetWindowMinimumSize(_THIS, SDL_Window* window)
|
||||
{
|
||||
MIR_Data* mir_data = _this->driverdata;
|
||||
MIR_Window* mir_window = window->driverdata;
|
||||
MirWindowSpec* spec;
|
||||
|
||||
if (IsSurfaceValid(mir_window) < 0)
|
||||
return;
|
||||
|
||||
spec = MIR_mir_create_window_spec(mir_data->connection);
|
||||
MIR_mir_window_spec_set_width (spec, window->min_w);
|
||||
MIR_mir_window_spec_set_height(spec, window->min_h);
|
||||
|
||||
MIR_mir_window_apply_spec(mir_window->window, spec);
|
||||
MIR_mir_window_spec_release(spec);
|
||||
UpdateMirWindowSize(_this->driverdata, window->driverdata, window->min_w, window->min_h);
|
||||
}
|
||||
|
||||
void
|
||||
MIR_SetWindowMaximumSize(_THIS, SDL_Window* window)
|
||||
{
|
||||
MIR_Data* mir_data = _this->driverdata;
|
||||
MIR_Window* mir_window = window->driverdata;
|
||||
MirWindowSpec* spec;
|
||||
|
||||
if (IsSurfaceValid(mir_window) < 0)
|
||||
return;
|
||||
|
||||
spec = MIR_mir_create_window_spec(mir_data->connection);
|
||||
MIR_mir_window_spec_set_max_width(spec, window->max_w);
|
||||
MIR_mir_window_spec_set_max_height(spec, window->max_h);
|
||||
|
||||
MIR_mir_window_apply_spec(mir_window->window, spec);
|
||||
MIR_mir_window_spec_release(spec);
|
||||
UpdateMirWindowSize(_this->driverdata, window->driverdata, window->max_w, window->max_h);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -351,7 +288,7 @@ MIR_SetWindowTitle(_THIS, SDL_Window* window)
|
||||
char const* title = window->title ? window->title : "";
|
||||
MirWindowSpec* spec;
|
||||
|
||||
if (IsSurfaceValid(mir_window) < 0)
|
||||
if (IsMirWindowValid(mir_window) < 0)
|
||||
return;
|
||||
|
||||
spec = MIR_mir_create_window_spec(mir_data->connection);
|
||||
|
||||
Reference in New Issue
Block a user