src/video/win32/SDL_win32window.c
author Szymon Wilczek <kazeuser@gmail.com>
Thu, 14 Aug 2008 08:28:19 +0000
branchgsoc2008_manymouse
changeset 3779 5f599ed92fb9
parent 3771 8cc36a399a12
permissions -rw-r--r--
Small improvements
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3767
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
     1
/*
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
     2
    SDL - Simple DirectMedia Layer
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
     3
    Copyright (C) 1997-2006 Sam Lantinga
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
     4
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
     5
    This library is free software; you can redistribute it and/or
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
     6
    modify it under the terms of the GNU Lesser General Public
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
     7
    License as published by the Free Software Foundation; either
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
     8
    version 2.1 of the License, or (at your option) any later version.
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
     9
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
    10
    This library is distributed in the hope that it will be useful,
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
    11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
    12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
    13
    Lesser General Public License for more details.
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
    14
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
    15
    You should have received a copy of the GNU Lesser General Public
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
    16
    License along with this library; if not, write to the Free Software
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
    17
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
    18
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
    19
    Sam Lantinga
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
    20
    slouken@libsdl.org
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
    21
*/
3768
1b87a8beab9d Project part1
Szymon Wilczek <kazeuser@gmail.com>
parents: 3767
diff changeset
    22
3771
8cc36a399a12 comments added and improved code look(windows part)
Szymon Wilczek <kazeuser@gmail.com>
parents: 3770
diff changeset
    23
/*we need to define it, so that raw input is included*/
8cc36a399a12 comments added and improved code look(windows part)
Szymon Wilczek <kazeuser@gmail.com>
parents: 3770
diff changeset
    24
3768
1b87a8beab9d Project part1
Szymon Wilczek <kazeuser@gmail.com>
parents: 3767
diff changeset
    25
#if (_WIN32_WINNT < 0x0501)
1b87a8beab9d Project part1
Szymon Wilczek <kazeuser@gmail.com>
parents: 3767
diff changeset
    26
#undef _WIN32_WINNT
1b87a8beab9d Project part1
Szymon Wilczek <kazeuser@gmail.com>
parents: 3767
diff changeset
    27
#define _WIN32_WINNT 0x0501
1b87a8beab9d Project part1
Szymon Wilczek <kazeuser@gmail.com>
parents: 3767
diff changeset
    28
#endif
1b87a8beab9d Project part1
Szymon Wilczek <kazeuser@gmail.com>
parents: 3767
diff changeset
    29
3767
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
    30
#include "SDL_config.h"
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
    31
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
    32
#include "../SDL_sysvideo.h"
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
    33
#include "../../events/SDL_keyboard_c.h"
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
    34
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
    35
#include "SDL_win32video.h"
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
    36
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
    37
/* This is included after SDL_win32video.h, which includes windows.h */
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
    38
#include "SDL_syswm.h"
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
    39
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
    40
#include <wintab.h>
3771
8cc36a399a12 comments added and improved code look(windows part)
Szymon Wilczek <kazeuser@gmail.com>
parents: 3770
diff changeset
    41
/*we're telling wintab that we want to receive movement, button events and pressure information in packets*/
3779
5f599ed92fb9 Small improvements
Szymon Wilczek <kazeuser@gmail.com>
parents: 3771
diff changeset
    42
#define PACKETDATA ( PK_X | PK_Y | PK_BUTTONS | PK_NORMAL_PRESSURE | PK_CURSOR)
3767
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
    43
#define PACKETMODE 0
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
    44
#include <pktdef.h>
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
    45
3771
8cc36a399a12 comments added and improved code look(windows part)
Szymon Wilczek <kazeuser@gmail.com>
parents: 3770
diff changeset
    46
extern HCTX* g_hCtx; /*the table of tablet event contexts, each windows has to have it's own tablet context*/
3767
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
    47
3771
8cc36a399a12 comments added and improved code look(windows part)
Szymon Wilczek <kazeuser@gmail.com>
parents: 3770
diff changeset
    48
int highestId=0; /*the highest id of the tablet context*/
3767
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
    49
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
    50
static int
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
    51
SetupWindowData(_THIS, SDL_Window * window, HWND hwnd, SDL_bool created)
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
    52
{
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
    53
    SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata;
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
    54
    SDL_WindowData *data;
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
    55
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
    56
    /* Allocate the window data */
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
    57
    data = (SDL_WindowData *) SDL_malloc(sizeof(*data));
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
    58
    if (!data) {
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
    59
        SDL_OutOfMemory();
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
    60
        return -1;
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
    61
    }
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
    62
    data->windowID = window->id;
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
    63
    data->hwnd = hwnd;
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
    64
    data->hdc = GetDC(hwnd);
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
    65
    data->created = created;
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
    66
    data->mouse_pressed = SDL_FALSE;
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
    67
    data->videodata = videodata;
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
    68
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
    69
    /* Associate the data with the window */
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
    70
    if (!SetProp(hwnd, TEXT("SDL_WindowData"), data)) {
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
    71
        ReleaseDC(hwnd, data->hdc);
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
    72
        SDL_free(data);
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
    73
        WIN_SetError("SetProp() failed");
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
    74
        return -1;
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
    75
    }
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
    76
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
    77
    /* Set up the window proc function */
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
    78
    data->wndproc = (WNDPROC) GetWindowLongPtr(hwnd, GWLP_WNDPROC);
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
    79
    if (data->wndproc == NULL) {
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
    80
        data->wndproc = DefWindowProc;
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
    81
    } else {
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
    82
        SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR) WIN_WindowProc);
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
    83
    }
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
    84
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
    85
    /* Fill in the SDL window with the window data */
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
    86
    {
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
    87
        POINT point;
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
    88
        point.x = 0;
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
    89
        point.y = 0;
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
    90
        if (ClientToScreen(hwnd, &point)) {
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
    91
            window->x = point.x;
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
    92
            window->y = point.y;
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
    93
        }
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
    94
    }
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
    95
    {
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
    96
        RECT rect;
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
    97
        if (GetClientRect(hwnd, &rect)) {
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
    98
            window->w = rect.right;
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
    99
            window->h = rect.bottom;
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   100
        }
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   101
    }
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   102
    {
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   103
        DWORD style = GetWindowLong(hwnd, GWL_STYLE);
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   104
        if (style & WS_VISIBLE) {
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   105
            window->flags |= SDL_WINDOW_SHOWN;
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   106
        } else {
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   107
            window->flags &= ~SDL_WINDOW_SHOWN;
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   108
        }
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   109
        if (style & (WS_BORDER | WS_THICKFRAME)) {
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   110
            window->flags &= ~SDL_WINDOW_BORDERLESS;
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   111
        } else {
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   112
            window->flags |= SDL_WINDOW_BORDERLESS;
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   113
        }
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   114
        if (style & WS_THICKFRAME) {
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   115
            window->flags |= SDL_WINDOW_RESIZABLE;
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   116
        } else {
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   117
            window->flags &= ~SDL_WINDOW_RESIZABLE;
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   118
        }
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   119
        if (style & WS_MAXIMIZE) {
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   120
            window->flags |= SDL_WINDOW_MAXIMIZED;
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   121
        } else {
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   122
            window->flags &= ~SDL_WINDOW_MAXIMIZED;
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   123
        }
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   124
        if (style & WS_MINIMIZE) {
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   125
            window->flags |= SDL_WINDOW_MINIMIZED;
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   126
        } else {
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   127
            window->flags &= ~SDL_WINDOW_MINIMIZED;
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   128
        }
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   129
    }
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   130
    if (GetFocus() == hwnd) {
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   131
        int index = data->videodata->keyboard;
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   132
        window->flags |= SDL_WINDOW_INPUT_FOCUS;
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   133
        SDL_SetKeyboardFocus(index, data->windowID);
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   134
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   135
        if (window->flags & SDL_WINDOW_INPUT_GRABBED) {
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   136
            RECT rect;
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   137
            GetClientRect(hwnd, &rect);
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   138
            ClientToScreen(hwnd, (LPPOINT) & rect);
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   139
            ClientToScreen(hwnd, (LPPOINT) & rect + 1);
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   140
            ClipCursor(&rect);
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   141
        }
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   142
    }
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   143
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   144
    /* All done! */
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   145
    window->driverdata = data;
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   146
    return 0;
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   147
}
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   148
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   149
int
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   150
WIN_CreateWindow(_THIS, SDL_Window * window)
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   151
{
3768
1b87a8beab9d Project part1
Szymon Wilczek <kazeuser@gmail.com>
parents: 3767
diff changeset
   152
	RAWINPUTDEVICE Rid;
3767
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   153
	AXIS TabX,TabY;
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   154
	LOGCONTEXT lc;
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   155
    HWND hwnd;
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   156
    HWND top;
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   157
    RECT rect;
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   158
    DWORD style = (WS_CLIPSIBLINGS | WS_CLIPCHILDREN);
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   159
    int x, y;
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   160
    int w, h;
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   161
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   162
    if (window->flags & SDL_WINDOW_BORDERLESS) {
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   163
        style |= WS_POPUP;
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   164
    } else {
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   165
        style |= (WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX);
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   166
    }
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   167
    if (window->flags & SDL_WINDOW_RESIZABLE) {
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   168
        style |= (WS_THICKFRAME | WS_MAXIMIZEBOX);
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   169
    }
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   170
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   171
    /* Figure out what the window area will be */
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   172
    if (window->flags & SDL_WINDOW_FULLSCREEN) {
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   173
        top = HWND_TOPMOST;
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   174
    } else {
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   175
        top = HWND_NOTOPMOST;
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   176
    }
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   177
    rect.left = 0;
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   178
    rect.top = 0;
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   179
    rect.right = window->w;
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   180
    rect.bottom = window->h;
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   181
    AdjustWindowRectEx(&rect, style, FALSE, 0);
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   182
    w = (rect.right - rect.left);
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   183
    h = (rect.bottom - rect.top);
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   184
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   185
    if (window->x == SDL_WINDOWPOS_CENTERED) {
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   186
        x = (GetSystemMetrics(SM_CXSCREEN) - w) / 2;
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   187
    } else if (window->x == SDL_WINDOWPOS_UNDEFINED) {
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   188
        x = CW_USEDEFAULT;
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   189
    } else {
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   190
        x = window->x + rect.left;
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   191
    }
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   192
    if (window->y == SDL_WINDOWPOS_CENTERED) {
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   193
        y = (GetSystemMetrics(SM_CYSCREEN) - h) / 2;
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   194
    } else if (window->y == SDL_WINDOWPOS_UNDEFINED) {
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   195
        y = CW_USEDEFAULT;
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   196
    } else {
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   197
        y = window->y + rect.top;
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   198
    }	
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   199
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   200
    hwnd =
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   201
        CreateWindow(SDL_Appname, TEXT(""), style, x, y, w, h, NULL, NULL,
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   202
                     SDL_Instance, NULL);
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   203
	
3771
8cc36a399a12 comments added and improved code look(windows part)
Szymon Wilczek <kazeuser@gmail.com>
parents: 3770
diff changeset
   204
	/*we're configuring the tablet data. See Wintab reference for more info*/
8cc36a399a12 comments added and improved code look(windows part)
Szymon Wilczek <kazeuser@gmail.com>
parents: 3770
diff changeset
   205
	
8cc36a399a12 comments added and improved code look(windows part)
Szymon Wilczek <kazeuser@gmail.com>
parents: 3770
diff changeset
   206
	if(WTInfo(WTI_DEFSYSCTX, 0, &lc)!=0)
8cc36a399a12 comments added and improved code look(windows part)
Szymon Wilczek <kazeuser@gmail.com>
parents: 3770
diff changeset
   207
	{
8cc36a399a12 comments added and improved code look(windows part)
Szymon Wilczek <kazeuser@gmail.com>
parents: 3770
diff changeset
   208
	
8cc36a399a12 comments added and improved code look(windows part)
Szymon Wilczek <kazeuser@gmail.com>
parents: 3770
diff changeset
   209
		lc.lcPktData = PACKETDATA;
8cc36a399a12 comments added and improved code look(windows part)
Szymon Wilczek <kazeuser@gmail.com>
parents: 3770
diff changeset
   210
		lc.lcPktMode = PACKETMODE;
8cc36a399a12 comments added and improved code look(windows part)
Szymon Wilczek <kazeuser@gmail.com>
parents: 3770
diff changeset
   211
		lc.lcOptions |= CXO_MESSAGES;
8cc36a399a12 comments added and improved code look(windows part)
Szymon Wilczek <kazeuser@gmail.com>
parents: 3770
diff changeset
   212
		lc.lcOptions |= CXO_SYSTEM;
8cc36a399a12 comments added and improved code look(windows part)
Szymon Wilczek <kazeuser@gmail.com>
parents: 3770
diff changeset
   213
		lc.lcMoveMask = PACKETDATA;
8cc36a399a12 comments added and improved code look(windows part)
Szymon Wilczek <kazeuser@gmail.com>
parents: 3770
diff changeset
   214
		lc.lcBtnDnMask=lc.lcBtnUpMask = PACKETDATA;
3767
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   215
3771
8cc36a399a12 comments added and improved code look(windows part)
Szymon Wilczek <kazeuser@gmail.com>
parents: 3770
diff changeset
   216
		WTInfo(WTI_DEVICES,DVC_X,&TabX);
8cc36a399a12 comments added and improved code look(windows part)
Szymon Wilczek <kazeuser@gmail.com>
parents: 3770
diff changeset
   217
		WTInfo(WTI_DEVICES,DVC_Y,&TabY);
3767
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   218
	
3771
8cc36a399a12 comments added and improved code look(windows part)
Szymon Wilczek <kazeuser@gmail.com>
parents: 3770
diff changeset
   219
		lc.lcInOrgX = 0;
8cc36a399a12 comments added and improved code look(windows part)
Szymon Wilczek <kazeuser@gmail.com>
parents: 3770
diff changeset
   220
		lc.lcInOrgY = 0;
3767
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   221
	
3771
8cc36a399a12 comments added and improved code look(windows part)
Szymon Wilczek <kazeuser@gmail.com>
parents: 3770
diff changeset
   222
		lc.lcInExtX = TabX.axMax;
8cc36a399a12 comments added and improved code look(windows part)
Szymon Wilczek <kazeuser@gmail.com>
parents: 3770
diff changeset
   223
		lc.lcInExtY = TabY.axMax;
3767
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   224
3771
8cc36a399a12 comments added and improved code look(windows part)
Szymon Wilczek <kazeuser@gmail.com>
parents: 3770
diff changeset
   225
		lc.lcOutOrgX = 0;
8cc36a399a12 comments added and improved code look(windows part)
Szymon Wilczek <kazeuser@gmail.com>
parents: 3770
diff changeset
   226
		lc.lcOutOrgY = 0;
8cc36a399a12 comments added and improved code look(windows part)
Szymon Wilczek <kazeuser@gmail.com>
parents: 3770
diff changeset
   227
8cc36a399a12 comments added and improved code look(windows part)
Szymon Wilczek <kazeuser@gmail.com>
parents: 3770
diff changeset
   228
		lc.lcOutExtX = GetSystemMetrics(SM_CXSCREEN);
8cc36a399a12 comments added and improved code look(windows part)
Szymon Wilczek <kazeuser@gmail.com>
parents: 3770
diff changeset
   229
		lc.lcOutExtY = -GetSystemMetrics(SM_CYSCREEN);
3767
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   230
3771
8cc36a399a12 comments added and improved code look(windows part)
Szymon Wilczek <kazeuser@gmail.com>
parents: 3770
diff changeset
   231
		if(window->id>highestId)
8cc36a399a12 comments added and improved code look(windows part)
Szymon Wilczek <kazeuser@gmail.com>
parents: 3770
diff changeset
   232
		{
8cc36a399a12 comments added and improved code look(windows part)
Szymon Wilczek <kazeuser@gmail.com>
parents: 3770
diff changeset
   233
			HCTX* tmp_hctx;
8cc36a399a12 comments added and improved code look(windows part)
Szymon Wilczek <kazeuser@gmail.com>
parents: 3770
diff changeset
   234
			highestId=window->id;
8cc36a399a12 comments added and improved code look(windows part)
Szymon Wilczek <kazeuser@gmail.com>
parents: 3770
diff changeset
   235
			tmp_hctx= (HCTX*)SDL_realloc(g_hCtx,(highestId+1)*sizeof(HCTX));
8cc36a399a12 comments added and improved code look(windows part)
Szymon Wilczek <kazeuser@gmail.com>
parents: 3770
diff changeset
   236
			if (!tmp_hctx) {
8cc36a399a12 comments added and improved code look(windows part)
Szymon Wilczek <kazeuser@gmail.com>
parents: 3770
diff changeset
   237
				SDL_OutOfMemory();
8cc36a399a12 comments added and improved code look(windows part)
Szymon Wilczek <kazeuser@gmail.com>
parents: 3770
diff changeset
   238
				return -1;
8cc36a399a12 comments added and improved code look(windows part)
Szymon Wilczek <kazeuser@gmail.com>
parents: 3770
diff changeset
   239
			}
8cc36a399a12 comments added and improved code look(windows part)
Szymon Wilczek <kazeuser@gmail.com>
parents: 3770
diff changeset
   240
			g_hCtx=tmp_hctx;
8cc36a399a12 comments added and improved code look(windows part)
Szymon Wilczek <kazeuser@gmail.com>
parents: 3770
diff changeset
   241
		}
8cc36a399a12 comments added and improved code look(windows part)
Szymon Wilczek <kazeuser@gmail.com>
parents: 3770
diff changeset
   242
8cc36a399a12 comments added and improved code look(windows part)
Szymon Wilczek <kazeuser@gmail.com>
parents: 3770
diff changeset
   243
		g_hCtx[window->id] = WTOpen(hwnd, &lc, TRUE);
3767
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   244
	}
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   245
3771
8cc36a399a12 comments added and improved code look(windows part)
Szymon Wilczek <kazeuser@gmail.com>
parents: 3770
diff changeset
   246
	/*we're telling the window, we want it to report raw input events from mice*/
3768
1b87a8beab9d Project part1
Szymon Wilczek <kazeuser@gmail.com>
parents: 3767
diff changeset
   247
1b87a8beab9d Project part1
Szymon Wilczek <kazeuser@gmail.com>
parents: 3767
diff changeset
   248
	Rid.usUsagePage = 0x01; 
1b87a8beab9d Project part1
Szymon Wilczek <kazeuser@gmail.com>
parents: 3767
diff changeset
   249
	Rid.usUsage = 0x02; 
3771
8cc36a399a12 comments added and improved code look(windows part)
Szymon Wilczek <kazeuser@gmail.com>
parents: 3770
diff changeset
   250
	Rid.dwFlags = RIDEV_INPUTSINK;  
3768
1b87a8beab9d Project part1
Szymon Wilczek <kazeuser@gmail.com>
parents: 3767
diff changeset
   251
	Rid.hwndTarget = hwnd;
1b87a8beab9d Project part1
Szymon Wilczek <kazeuser@gmail.com>
parents: 3767
diff changeset
   252
1b87a8beab9d Project part1
Szymon Wilczek <kazeuser@gmail.com>
parents: 3767
diff changeset
   253
	RegisterRawInputDevices(&Rid, 1, sizeof(Rid));
1b87a8beab9d Project part1
Szymon Wilczek <kazeuser@gmail.com>
parents: 3767
diff changeset
   254
		
1b87a8beab9d Project part1
Szymon Wilczek <kazeuser@gmail.com>
parents: 3767
diff changeset
   255
3767
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   256
    WIN_PumpEvents(_this);
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   257
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   258
    if (!hwnd) {
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   259
        WIN_SetError("Couldn't create window");
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   260
        return -1;
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   261
    }
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   262
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   263
    if (SetupWindowData(_this, window, hwnd, SDL_TRUE) < 0) {
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   264
        DestroyWindow(hwnd);
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   265
        return -1;
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   266
    }
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   267
#ifdef SDL_VIDEO_OPENGL_WGL
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   268
    if (window->flags & SDL_WINDOW_OPENGL) {
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   269
        if (WIN_GL_SetupWindow(_this, window) < 0) {
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   270
            WIN_DestroyWindow(_this, window);
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   271
            return -1;
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   272
        }
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   273
    }
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   274
#endif
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   275
    return 0;
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   276
}
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   277
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   278
int
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   279
WIN_CreateWindowFrom(_THIS, SDL_Window * window, const void *data)
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   280
{
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   281
    HWND hwnd = (HWND) data;
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   282
    LPTSTR title;
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   283
    int titleLen;
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   284
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   285
    /* Query the title from the existing window */
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   286
    titleLen = GetWindowTextLength(hwnd);
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   287
    title = SDL_stack_alloc(TCHAR, titleLen + 1);
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   288
    if (title) {
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   289
        titleLen = GetWindowText(hwnd, title, titleLen);
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   290
    } else {
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   291
        titleLen = 0;
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   292
    }
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   293
    if (titleLen > 0) {
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   294
        window->title = WIN_StringToUTF8(title);
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   295
    }
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   296
    if (title) {
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   297
        SDL_stack_free(title);
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   298
    }
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   299
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   300
    if (SetupWindowData(_this, window, hwnd, SDL_FALSE) < 0) {
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   301
        return -1;
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   302
    }
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   303
    return 0;
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   304
}
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   305
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   306
void
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   307
WIN_SetWindowTitle(_THIS, SDL_Window * window)
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   308
{
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   309
    HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd;
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   310
    LPTSTR title;
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   311
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   312
    if (window->title) {
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   313
        title = WIN_UTF8ToString(window->title);
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   314
    } else {
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   315
        title = NULL;
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   316
    }
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   317
    SetWindowText(hwnd, title ? title : TEXT(""));
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   318
    if (title) {
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   319
        SDL_free(title);
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   320
    }
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   321
}
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   322
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   323
void
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   324
WIN_SetWindowPosition(_THIS, SDL_Window * window)
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   325
{
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   326
    HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd;
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   327
    RECT rect;
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   328
    DWORD style;
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   329
    HWND top;
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   330
    int x, y;
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   331
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   332
    /* Figure out what the window area will be */
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   333
    if (window->flags & SDL_WINDOW_FULLSCREEN) {
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   334
        top = HWND_TOPMOST;
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   335
    } else {
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   336
        top = HWND_NOTOPMOST;
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   337
    }
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   338
    style = GetWindowLong(hwnd, GWL_STYLE);
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   339
    rect.left = 0;
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   340
    rect.top = 0;
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   341
    rect.right = window->w;
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   342
    rect.bottom = window->h;
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   343
    AdjustWindowRectEx(&rect, style,
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   344
                       (style & WS_CHILDWINDOW) ? FALSE : (GetMenu(hwnd) !=
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   345
                                                           NULL), 0);
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   346
    x = window->x + rect.left;
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   347
    y = window->y + rect.top;
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   348
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   349
    SetWindowPos(hwnd, top, x, y, 0, 0, (SWP_NOCOPYBITS | SWP_NOSIZE));
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   350
}
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   351
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   352
void
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   353
WIN_SetWindowSize(_THIS, SDL_Window * window)
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   354
{
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   355
    HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd;
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   356
    RECT rect;
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   357
    DWORD style;
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   358
    HWND top;
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   359
    int w, h;
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   360
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   361
    /* Figure out what the window area will be */
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   362
    if (window->flags & SDL_WINDOW_FULLSCREEN) {
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   363
        top = HWND_TOPMOST;
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   364
    } else {
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   365
        top = HWND_NOTOPMOST;
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   366
    }
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   367
    style = GetWindowLong(hwnd, GWL_STYLE);
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   368
    rect.left = 0;
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   369
    rect.top = 0;
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   370
    rect.right = window->w;
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   371
    rect.bottom = window->h;
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   372
    AdjustWindowRectEx(&rect, style,
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   373
                       (style & WS_CHILDWINDOW) ? FALSE : (GetMenu(hwnd) !=
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   374
                                                           NULL), 0);
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   375
    w = (rect.right - rect.left);
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   376
    h = (rect.bottom - rect.top);
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   377
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   378
    SetWindowPos(hwnd, top, 0, 0, h, w, (SWP_NOCOPYBITS | SWP_NOMOVE));
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   379
}
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   380
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   381
void
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   382
WIN_ShowWindow(_THIS, SDL_Window * window)
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   383
{
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   384
    HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd;
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   385
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   386
    ShowWindow(hwnd, SW_SHOW);
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   387
}
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   388
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   389
void
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   390
WIN_HideWindow(_THIS, SDL_Window * window)
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   391
{
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   392
    HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd;
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   393
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   394
    ShowWindow(hwnd, SW_HIDE);
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   395
}
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   396
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   397
void
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   398
WIN_RaiseWindow(_THIS, SDL_Window * window)
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   399
{
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   400
    HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd;
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   401
    HWND top;
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   402
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   403
    if (window->flags & SDL_WINDOW_FULLSCREEN) {
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   404
        top = HWND_TOPMOST;
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   405
    } else {
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   406
        top = HWND_NOTOPMOST;
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   407
    }
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   408
    SetWindowPos(hwnd, top, 0, 0, 0, 0, (SWP_NOMOVE | SWP_NOSIZE));
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   409
}
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   410
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   411
void
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   412
WIN_MaximizeWindow(_THIS, SDL_Window * window)
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   413
{
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   414
    HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd;
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   415
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   416
    ShowWindow(hwnd, SW_MAXIMIZE);
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   417
}
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   418
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   419
void
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   420
WIN_MinimizeWindow(_THIS, SDL_Window * window)
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   421
{
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   422
    HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd;
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   423
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   424
    ShowWindow(hwnd, SW_MINIMIZE);
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   425
}
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   426
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   427
void
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   428
WIN_RestoreWindow(_THIS, SDL_Window * window)
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   429
{
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   430
    HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd;
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   431
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   432
    ShowWindow(hwnd, SW_RESTORE);
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   433
}
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   434
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   435
void
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   436
WIN_SetWindowGrab(_THIS, SDL_Window * window)
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   437
{
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   438
    HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd;
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   439
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   440
    if ((window->flags & SDL_WINDOW_INPUT_GRABBED) &&
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   441
        (window->flags & SDL_WINDOW_INPUT_FOCUS)) {
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   442
        RECT rect;
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   443
        GetClientRect(hwnd, &rect);
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   444
        ClientToScreen(hwnd, (LPPOINT) & rect);
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   445
        ClientToScreen(hwnd, (LPPOINT) & rect + 1);
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   446
        ClipCursor(&rect);
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   447
    } else {
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   448
        ClipCursor(NULL);
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   449
    }
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   450
}
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   451
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   452
void
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   453
WIN_DestroyWindow(_THIS, SDL_Window * window)
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   454
{
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   455
    SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   456
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   457
    if (data) {
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   458
#ifdef SDL_VIDEO_OPENGL_WGL
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   459
        if (window->flags & SDL_WINDOW_OPENGL) {
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   460
            WIN_GL_CleanupWindow(_this, window);
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   461
        }
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   462
#endif
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   463
        ReleaseDC(data->hwnd, data->hdc);
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   464
        if (data->created) {
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   465
			WTClose(g_hCtx[window->id]);
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   466
            DestroyWindow(data->hwnd);
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   467
        }
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   468
        SDL_free(data);
3771
8cc36a399a12 comments added and improved code look(windows part)
Szymon Wilczek <kazeuser@gmail.com>
parents: 3770
diff changeset
   469
		/*lets close the tablet context for the destoryed window*/
3767
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   470
		WTClose(g_hCtx[window->id]);
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   471
    }
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   472
}
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   473
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   474
SDL_bool
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   475
WIN_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info)
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   476
{
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   477
    HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd;
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   478
    if (info->version.major <= SDL_MAJOR_VERSION) {
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   479
        info->window = hwnd;
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   480
        return SDL_TRUE;
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   481
    } else {
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   482
        SDL_SetError("Application not compiled with SDL %d.%d\n",
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   483
                     SDL_MAJOR_VERSION, SDL_MINOR_VERSION);
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   484
        return SDL_FALSE;
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   485
    }
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   486
}
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   487
abc8acb8e3d7 Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents: 1956
diff changeset
   488
/* vi: set ts=4 sw=4 expandtab: */
3770
81b649bad6d2 Implementation finished
Szymon Wilczek <kazeuser@gmail.com>
parents: 3768
diff changeset
   489