annotate src/video/directfb/SDL_DirectFB_WM.c @ 5098:e4301cde4de1

Fixed compile error on Visual C++
author Sam Lantinga <slouken@libsdl.org>
date Tue, 25 Jan 2011 17:44:17 -0800
parents b196d2758026
children 164f20ba08eb
rev   line source
3023
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
1 /*
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
2 SDL - Simple DirectMedia Layer
3697
f7b03b6838cb Fixed bug #926
Sam Lantinga <slouken@libsdl.org>
parents: 3685
diff changeset
3 Copyright (C) 1997-2010 Sam Lantinga
3023
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
4
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
5 This library is free software; you can redistribute it and/or
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
6 modify it under the terms of the GNU Lesser General Public
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
7 License as published by the Free Software Foundation; either
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
8 version 2.1 of the License, or (at your option) any later version.
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
9
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
10 This library is distributed in the hope that it will be useful,
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
13 Lesser General Public License for more details.
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
14
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
15 You should have received a copy of the GNU Lesser General Public
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
16 License along with this library; if not, write to the Free Software
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
18
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
19 Sam Lantinga
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
20 slouken@libsdl.org
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
21 */
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
22 #include "SDL_config.h"
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
23
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
24 //#include "SDL_syswm.h"
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
25 //#include "../SDL_sysvideo.h"
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
26 //#include "../../events/SDL_keyboard_c.h"
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
27
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
28 #include "SDL_DirectFB_video.h"
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
29
4636
b196d2758026 Couriersud to Sam
Sam Lantinga <slouken@libsdl.org>
parents: 4568
diff changeset
30 #include "../../events/SDL_windowevents_c.h"
b196d2758026 Couriersud to Sam
Sam Lantinga <slouken@libsdl.org>
parents: 4568
diff changeset
31
3023
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
32 #define COLOR_EXPAND(col) col.r, col.g, col.b, col.a
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
33
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
34 static DFB_Theme theme_std = {
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
35 4, 4, 8, 8,
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
36 {255, 200, 200, 200},
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
37 24,
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
38 {255, 0, 0, 255},
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
39 16,
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
40 {255, 255, 255, 255},
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
41 "/usr/share/fonts/truetype/freefont/FreeSans.ttf",
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
42 {255, 255, 0, 0},
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
43 {255, 255, 255, 0},
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
44 };
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
45
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
46 static DFB_Theme theme_none = {
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
47 0, 0, 0, 0,
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
48 {0, 0, 0, 0},
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
49 0,
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
50 {0, 0, 0, 0},
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
51 0,
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
52 {0, 0, 0, 0},
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
53 NULL
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
54 };
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
55
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
56 static void
4636
b196d2758026 Couriersud to Sam
Sam Lantinga <slouken@libsdl.org>
parents: 4568
diff changeset
57 DrawTriangle(IDirectFBSurface * s, int down, int x, int y, int w)
3023
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
58 {
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
59 int x1, x2, x3;
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
60 int y1, y2, y3;
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
61
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
62 if (down) {
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
63 x1 = x + w / 2;
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
64 x2 = x;
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
65 x3 = x + w;
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
66 y1 = y + w;
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
67 y2 = y;
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
68 y3 = y;
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
69 } else {
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
70 x1 = x + w / 2;
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
71 x2 = x;
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
72 x3 = x + w;
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
73 y1 = y;
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
74 y2 = y + w;
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
75 y3 = y + w;
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
76 }
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
77 s->FillTriangle(s, x1, y1, x2, y2, x3, y3);
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
78 }
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
79
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
80 static void
4636
b196d2758026 Couriersud to Sam
Sam Lantinga <slouken@libsdl.org>
parents: 4568
diff changeset
81 LoadFont(_THIS, SDL_Window * window)
b196d2758026 Couriersud to Sam
Sam Lantinga <slouken@libsdl.org>
parents: 4568
diff changeset
82 {
b196d2758026 Couriersud to Sam
Sam Lantinga <slouken@libsdl.org>
parents: 4568
diff changeset
83 SDL_DFB_DEVICEDATA(_this);
b196d2758026 Couriersud to Sam
Sam Lantinga <slouken@libsdl.org>
parents: 4568
diff changeset
84 SDL_DFB_WINDOWDATA(window);
b196d2758026 Couriersud to Sam
Sam Lantinga <slouken@libsdl.org>
parents: 4568
diff changeset
85
b196d2758026 Couriersud to Sam
Sam Lantinga <slouken@libsdl.org>
parents: 4568
diff changeset
86 if (windata->font != NULL) {
b196d2758026 Couriersud to Sam
Sam Lantinga <slouken@libsdl.org>
parents: 4568
diff changeset
87 SDL_DFB_RELEASE(windata->font);
b196d2758026 Couriersud to Sam
Sam Lantinga <slouken@libsdl.org>
parents: 4568
diff changeset
88 windata->font = NULL;
b196d2758026 Couriersud to Sam
Sam Lantinga <slouken@libsdl.org>
parents: 4568
diff changeset
89 SDL_DFB_CHECK(windata->window_surface->SetFont(windata->window_surface, windata->font));
b196d2758026 Couriersud to Sam
Sam Lantinga <slouken@libsdl.org>
parents: 4568
diff changeset
90 }
b196d2758026 Couriersud to Sam
Sam Lantinga <slouken@libsdl.org>
parents: 4568
diff changeset
91
b196d2758026 Couriersud to Sam
Sam Lantinga <slouken@libsdl.org>
parents: 4568
diff changeset
92 if (windata->theme.font != NULL)
b196d2758026 Couriersud to Sam
Sam Lantinga <slouken@libsdl.org>
parents: 4568
diff changeset
93 {
b196d2758026 Couriersud to Sam
Sam Lantinga <slouken@libsdl.org>
parents: 4568
diff changeset
94 DFBFontDescription fdesc;
b196d2758026 Couriersud to Sam
Sam Lantinga <slouken@libsdl.org>
parents: 4568
diff changeset
95
b196d2758026 Couriersud to Sam
Sam Lantinga <slouken@libsdl.org>
parents: 4568
diff changeset
96 SDL_zero(fdesc);
b196d2758026 Couriersud to Sam
Sam Lantinga <slouken@libsdl.org>
parents: 4568
diff changeset
97 fdesc.flags = DFDESC_HEIGHT;
b196d2758026 Couriersud to Sam
Sam Lantinga <slouken@libsdl.org>
parents: 4568
diff changeset
98 fdesc.height = windata->theme.font_size;
b196d2758026 Couriersud to Sam
Sam Lantinga <slouken@libsdl.org>
parents: 4568
diff changeset
99 SDL_DFB_CHECK(devdata->
b196d2758026 Couriersud to Sam
Sam Lantinga <slouken@libsdl.org>
parents: 4568
diff changeset
100 dfb->CreateFont(devdata->dfb, windata->theme.font,
b196d2758026 Couriersud to Sam
Sam Lantinga <slouken@libsdl.org>
parents: 4568
diff changeset
101 &fdesc, &windata->font));
b196d2758026 Couriersud to Sam
Sam Lantinga <slouken@libsdl.org>
parents: 4568
diff changeset
102 SDL_DFB_CHECK(windata->window_surface->SetFont(windata->window_surface, windata->font));
b196d2758026 Couriersud to Sam
Sam Lantinga <slouken@libsdl.org>
parents: 4568
diff changeset
103 }
b196d2758026 Couriersud to Sam
Sam Lantinga <slouken@libsdl.org>
parents: 4568
diff changeset
104 }
b196d2758026 Couriersud to Sam
Sam Lantinga <slouken@libsdl.org>
parents: 4568
diff changeset
105
b196d2758026 Couriersud to Sam
Sam Lantinga <slouken@libsdl.org>
parents: 4568
diff changeset
106 static void
b196d2758026 Couriersud to Sam
Sam Lantinga <slouken@libsdl.org>
parents: 4568
diff changeset
107 DrawCraption(_THIS, IDirectFBSurface * s, int x, int y, char *text)
3023
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
108 {
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
109 DFBSurfaceTextFlags flags;
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
110
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
111 flags = DSTF_CENTER | DSTF_TOP;
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
112
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
113 s->DrawString(s, text, -1, x, y, flags);
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
114 }
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
115
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
116 void
4636
b196d2758026 Couriersud to Sam
Sam Lantinga <slouken@libsdl.org>
parents: 4568
diff changeset
117 DirectFB_WM_RedrawLayout(_THIS, SDL_Window * window)
3023
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
118 {
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
119 SDL_DFB_WINDOWDATA(window);
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
120 IDirectFBSurface *s = windata->window_surface;
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
121 DFB_Theme *t = &windata->theme;
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
122 int i;
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
123 int d = (t->caption_size - t->font_size) / 2;
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
124 int x, y, w;
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
125
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
126
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
127 if (!windata->is_managed || (window->flags & SDL_WINDOW_FULLSCREEN))
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
128 return;
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
129
4636
b196d2758026 Couriersud to Sam
Sam Lantinga <slouken@libsdl.org>
parents: 4568
diff changeset
130 LoadFont(_this, window);
3023
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
131 //s->SetDrawingFlags(s, DSDRAW_BLEND);
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
132 s->SetColor(s, COLOR_EXPAND(t->frame_color));
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
133 /* top */
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
134 for (i = 0; i < t->top_size; i++)
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
135 s->DrawLine(s, 0, i, windata->size.w, i);
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
136 /* bottom */
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
137 for (i = windata->size.h - t->bottom_size; i < windata->size.h; i++)
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
138 s->DrawLine(s, 0, i, windata->size.w, i);
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
139 /* left */
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
140 for (i = 0; i < t->left_size; i++)
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
141 s->DrawLine(s, i, 0, i, windata->size.h);
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
142 /* right */
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
143 for (i = windata->size.w - t->right_size; i < windata->size.w; i++)
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
144 s->DrawLine(s, i, 0, i, windata->size.h);
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
145 /* Caption */
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
146 s->SetColor(s, COLOR_EXPAND(t->caption_color));
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
147 s->FillRectangle(s, t->left_size, t->top_size, windata->client.w,
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
148 t->caption_size);
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
149 /* Close Button */
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
150 w = t->caption_size;
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
151 x = windata->size.w - t->right_size - w + d;
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
152 y = t->top_size + d;
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
153 s->SetColor(s, COLOR_EXPAND(t->close_color));
4636
b196d2758026 Couriersud to Sam
Sam Lantinga <slouken@libsdl.org>
parents: 4568
diff changeset
154 DrawTriangle(s, 1, x, y, w - 2 * d);
3023
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
155 /* Max Button */
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
156 s->SetColor(s, COLOR_EXPAND(t->max_color));
4636
b196d2758026 Couriersud to Sam
Sam Lantinga <slouken@libsdl.org>
parents: 4568
diff changeset
157 DrawTriangle(s, window->flags & SDL_WINDOW_MAXIMIZED ? 1 : 0, x - w,
3023
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
158 y, w - 2 * d);
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
159
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
160 /* Caption */
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
161 if (window->title) {
4636
b196d2758026 Couriersud to Sam
Sam Lantinga <slouken@libsdl.org>
parents: 4568
diff changeset
162 s->SetColor(s, COLOR_EXPAND(t->font_color));
b196d2758026 Couriersud to Sam
Sam Lantinga <slouken@libsdl.org>
parents: 4568
diff changeset
163 DrawCraption(_this, s, (x - w) / 2, t->top_size + d, window->title);
3023
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
164 }
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
165 /* Icon */
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
166 if (windata->icon) {
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
167 DFBRectangle dr;
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
168
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
169 dr.x = t->left_size + d;
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
170 dr.y = t->top_size + d;
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
171 dr.w = w - 2 * d;
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
172 dr.h = w - 2 * d;
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
173 s->SetBlittingFlags(s, DSBLIT_BLEND_ALPHACHANNEL);
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
174
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
175 s->StretchBlit(s, windata->icon, NULL, &dr);
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
176 }
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
177 windata->wm_needs_redraw = 0;
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
178 }
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
179
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
180 DFBResult
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
181 DirectFB_WM_GetClientSize(_THIS, SDL_Window * window, int *cw, int *ch)
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
182 {
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
183 SDL_DFB_WINDOWDATA(window);
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
184
4636
b196d2758026 Couriersud to Sam
Sam Lantinga <slouken@libsdl.org>
parents: 4568
diff changeset
185 SDL_DFB_CHECK(windata->window->GetSize(windata->window, cw, ch));
3023
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
186 *cw -= windata->theme.left_size + windata->theme.right_size;
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
187 *ch -=
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
188 windata->theme.top_size + windata->theme.caption_size +
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
189 windata->theme.bottom_size;
4636
b196d2758026 Couriersud to Sam
Sam Lantinga <slouken@libsdl.org>
parents: 4568
diff changeset
190 return DFB_OK;
3023
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
191 }
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
192
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
193 void
4636
b196d2758026 Couriersud to Sam
Sam Lantinga <slouken@libsdl.org>
parents: 4568
diff changeset
194 DirectFB_WM_AdjustWindowLayout(SDL_Window * window, int flags, int w, int h)
3023
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
195 {
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
196 SDL_DFB_WINDOWDATA(window);
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
197
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
198 if (!windata->is_managed)
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
199 windata->theme = theme_none;
4636
b196d2758026 Couriersud to Sam
Sam Lantinga <slouken@libsdl.org>
parents: 4568
diff changeset
200 else if (flags & SDL_WINDOW_FULLSCREEN) {
3023
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
201 windata->theme = theme_none;
4636
b196d2758026 Couriersud to Sam
Sam Lantinga <slouken@libsdl.org>
parents: 4568
diff changeset
202 } else if (flags & SDL_WINDOW_MAXIMIZED) {
3023
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
203 windata->theme = theme_std;
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
204 windata->theme.left_size = 0;
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
205 windata->theme.right_size = 0;
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
206 windata->theme.top_size = 0;
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
207 windata->theme.bottom_size = 0;
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
208 } else {
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
209 windata->theme = theme_std;
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
210 }
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
211
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
212 windata->client.x = windata->theme.left_size;
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
213 windata->client.y = windata->theme.top_size + windata->theme.caption_size;
4636
b196d2758026 Couriersud to Sam
Sam Lantinga <slouken@libsdl.org>
parents: 4568
diff changeset
214 windata->client.w = w;
b196d2758026 Couriersud to Sam
Sam Lantinga <slouken@libsdl.org>
parents: 4568
diff changeset
215 windata->client.h = h;
3023
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
216 windata->size.w =
4636
b196d2758026 Couriersud to Sam
Sam Lantinga <slouken@libsdl.org>
parents: 4568
diff changeset
217 w + windata->theme.left_size + windata->theme.right_size;
3023
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
218 windata->size.h =
4636
b196d2758026 Couriersud to Sam
Sam Lantinga <slouken@libsdl.org>
parents: 4568
diff changeset
219 h + windata->theme.top_size +
3023
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
220 windata->theme.caption_size + windata->theme.bottom_size;
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
221 }
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
222
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
223 void
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
224 DirectFB_WM_MaximizeWindow(_THIS, SDL_Window * window)
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
225 {
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
226 SDL_DFB_WINDOWDATA(window);
3685
64ce267332c6 Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents: 3040
diff changeset
227 SDL_VideoDisplay *display = window->display;
3023
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
228
4636
b196d2758026 Couriersud to Sam
Sam Lantinga <slouken@libsdl.org>
parents: 4568
diff changeset
229 SDL_DFB_CHECK(windata->window->GetPosition(windata->window,
b196d2758026 Couriersud to Sam
Sam Lantinga <slouken@libsdl.org>
parents: 4568
diff changeset
230 &windata->restore.x, &windata->restore.y));
b196d2758026 Couriersud to Sam
Sam Lantinga <slouken@libsdl.org>
parents: 4568
diff changeset
231 SDL_DFB_CHECK(windata->window->GetSize(windata->window, &windata->restore.w,
b196d2758026 Couriersud to Sam
Sam Lantinga <slouken@libsdl.org>
parents: 4568
diff changeset
232 &windata->restore.h));
3023
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
233
4636
b196d2758026 Couriersud to Sam
Sam Lantinga <slouken@libsdl.org>
parents: 4568
diff changeset
234 DirectFB_WM_AdjustWindowLayout(window, window->flags | SDL_WINDOW_MAXIMIZED, display->current_mode.w, display->current_mode.h) ;
3023
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
235
4636
b196d2758026 Couriersud to Sam
Sam Lantinga <slouken@libsdl.org>
parents: 4568
diff changeset
236 SDL_DFB_CHECK(windata->window->MoveTo(windata->window, 0, 0));
b196d2758026 Couriersud to Sam
Sam Lantinga <slouken@libsdl.org>
parents: 4568
diff changeset
237 SDL_DFB_CHECK(windata->window->Resize(windata->window,
b196d2758026 Couriersud to Sam
Sam Lantinga <slouken@libsdl.org>
parents: 4568
diff changeset
238 display->current_mode.w, display->current_mode.h));
3023
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
239 }
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
240
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
241 void
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
242 DirectFB_WM_RestoreWindow(_THIS, SDL_Window * window)
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
243 {
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
244 SDL_DFB_WINDOWDATA(window);
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
245
4636
b196d2758026 Couriersud to Sam
Sam Lantinga <slouken@libsdl.org>
parents: 4568
diff changeset
246 DirectFB_WM_AdjustWindowLayout(window, window->flags & ~(SDL_WINDOW_MAXIMIZED | SDL_WINDOW_MINIMIZED),
b196d2758026 Couriersud to Sam
Sam Lantinga <slouken@libsdl.org>
parents: 4568
diff changeset
247 windata->restore.w, windata->restore.h);
3023
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
248
4636
b196d2758026 Couriersud to Sam
Sam Lantinga <slouken@libsdl.org>
parents: 4568
diff changeset
249 SDL_DFB_CHECK(windata->window->Resize(windata->window, windata->restore.w,
b196d2758026 Couriersud to Sam
Sam Lantinga <slouken@libsdl.org>
parents: 4568
diff changeset
250 windata->restore.h));
b196d2758026 Couriersud to Sam
Sam Lantinga <slouken@libsdl.org>
parents: 4568
diff changeset
251 SDL_DFB_CHECK(windata->window->MoveTo(windata->window, windata->restore.x,
b196d2758026 Couriersud to Sam
Sam Lantinga <slouken@libsdl.org>
parents: 4568
diff changeset
252 windata->restore.y));
3023
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
253 }
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
254
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
255 enum
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
256 {
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
257 WM_POS_NONE = 0x00,
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
258 WM_POS_CAPTION = 0x01,
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
259 WM_POS_CLOSE = 0x02,
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
260 WM_POS_MAX = 0x04,
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
261 WM_POS_LEFT = 0x08,
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
262 WM_POS_RIGHT = 0x10,
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
263 WM_POS_TOP = 0x20,
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
264 WM_POS_BOTTOM = 0x40,
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
265 };
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
266
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
267 static int
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
268 WMIsClient(DFB_WindowData * p, int x, int y)
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
269 {
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
270 x -= p->client.x;
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
271 y -= p->client.y;
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
272 if (x < 0 || y < 0)
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
273 return 0;
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
274 if (x >= p->client.w || y >= p->client.h)
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
275 return 0;
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
276 return 1;
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
277 }
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
278
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
279 static int
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
280 WMPos(DFB_WindowData * p, int x, int y)
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
281 {
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
282 int pos = WM_POS_NONE;
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
283
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
284 if (!WMIsClient(p, x, y)) {
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
285 if (y < p->theme.top_size) {
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
286 pos |= WM_POS_TOP;
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
287 } else if (y < p->client.y) {
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
288 if (x <
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
289 p->size.w - p->theme.right_size - 2 * p->theme.caption_size) {
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
290 pos |= WM_POS_CAPTION;
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
291 } else if (x <
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
292 p->size.w - p->theme.right_size -
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
293 p->theme.caption_size) {
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
294 pos |= WM_POS_MAX;
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
295 } else {
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
296 pos |= WM_POS_CLOSE;
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
297 }
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
298 } else if (y >= p->size.h - p->theme.bottom_size) {
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
299 pos |= WM_POS_BOTTOM;
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
300 }
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
301 if (x < p->theme.left_size) {
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
302 pos |= WM_POS_LEFT;
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
303 } else if (x >= p->size.w - p->theme.right_size) {
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
304 pos |= WM_POS_RIGHT;
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
305 }
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
306 }
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
307 return pos;
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
308 }
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
309
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
310 static int wm_grab;
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
311 static int wm_lastx;
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
312 static int wm_lasty;
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
313
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
314 int
3040
Sam Lantinga <slouken@libsdl.org>
parents: 3023
diff changeset
315 DirectFB_WM_ProcessEvent(_THIS, SDL_Window * window, DFBWindowEvent * evt)
3023
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
316 {
4636
b196d2758026 Couriersud to Sam
Sam Lantinga <slouken@libsdl.org>
parents: 4568
diff changeset
317 SDL_DFB_DEVICEDATA(_this);
3023
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
318 SDL_DFB_WINDOWDATA(window);
4636
b196d2758026 Couriersud to Sam
Sam Lantinga <slouken@libsdl.org>
parents: 4568
diff changeset
319 DFB_WindowData *gwindata = ((devdata->grabbed_window) ? (DFB_WindowData *) ((devdata->grabbed_window)->driverdata) : NULL);
3023
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
320
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
321 if (!windata->is_managed)
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
322 return 0;
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
323
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
324 switch (evt->type) {
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
325 case DWET_BUTTONDOWN:
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
326 if (evt->buttons & DIBM_LEFT) {
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
327 int pos = WMPos(windata, evt->x, evt->y);
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
328 switch (pos) {
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
329 case WM_POS_NONE:
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
330 return 0;
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
331 case WM_POS_CLOSE:
4636
b196d2758026 Couriersud to Sam
Sam Lantinga <slouken@libsdl.org>
parents: 4568
diff changeset
332 wm_grab = WM_POS_NONE;
4568
25b9cd8bdc30 Couriersud to Sam
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
333 SDL_SendWindowEvent(window, SDL_WINDOWEVENT_CLOSE, 0,
3040
Sam Lantinga <slouken@libsdl.org>
parents: 3023
diff changeset
334 0);
3023
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
335 return 1;
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
336 case WM_POS_MAX:
4636
b196d2758026 Couriersud to Sam
Sam Lantinga <slouken@libsdl.org>
parents: 4568
diff changeset
337 wm_grab = WM_POS_NONE;
3023
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
338 if (window->flags & SDL_WINDOW_MAXIMIZED) {
4636
b196d2758026 Couriersud to Sam
Sam Lantinga <slouken@libsdl.org>
parents: 4568
diff changeset
339 SDL_RestoreWindow(window);
3023
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
340 } else {
4636
b196d2758026 Couriersud to Sam
Sam Lantinga <slouken@libsdl.org>
parents: 4568
diff changeset
341 SDL_MaximizeWindow(window);
3023
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
342 }
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
343 return 1;
4636
b196d2758026 Couriersud to Sam
Sam Lantinga <slouken@libsdl.org>
parents: 4568
diff changeset
344 case WM_POS_CAPTION:
b196d2758026 Couriersud to Sam
Sam Lantinga <slouken@libsdl.org>
parents: 4568
diff changeset
345 DirectFB_RaiseWindow(_this, window);
b196d2758026 Couriersud to Sam
Sam Lantinga <slouken@libsdl.org>
parents: 4568
diff changeset
346 /* fall through */
3023
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
347 default:
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
348 wm_grab = pos;
4636
b196d2758026 Couriersud to Sam
Sam Lantinga <slouken@libsdl.org>
parents: 4568
diff changeset
349 if (gwindata != NULL)
b196d2758026 Couriersud to Sam
Sam Lantinga <slouken@libsdl.org>
parents: 4568
diff changeset
350 SDL_DFB_CHECK(gwindata->window->UngrabPointer(gwindata->window));
b196d2758026 Couriersud to Sam
Sam Lantinga <slouken@libsdl.org>
parents: 4568
diff changeset
351 SDL_DFB_CHECK(windata->window->GrabPointer(windata->window));
3023
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
352 wm_lastx = evt->cx;
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
353 wm_lasty = evt->cy;
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
354 }
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
355 }
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
356 return 1;
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
357 case DWET_BUTTONUP:
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
358 break;
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
359 case DWET_MOTION:
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
360 if (!wm_grab)
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
361 return 0;
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
362 if (evt->buttons & DIBM_LEFT) {
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
363 int dx = evt->cx - wm_lastx;
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
364 int dy = evt->cy - wm_lasty;
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
365 int cw, ch;
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
366
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
367 if (wm_grab & WM_POS_CAPTION)
4636
b196d2758026 Couriersud to Sam
Sam Lantinga <slouken@libsdl.org>
parents: 4568
diff changeset
368 SDL_DFB_CHECK(windata->window->Move(windata->window, dx, dy));
b196d2758026 Couriersud to Sam
Sam Lantinga <slouken@libsdl.org>
parents: 4568
diff changeset
369 if (wm_grab & (WM_POS_RIGHT | WM_POS_BOTTOM)) {
b196d2758026 Couriersud to Sam
Sam Lantinga <slouken@libsdl.org>
parents: 4568
diff changeset
370 if ((wm_grab & (WM_POS_BOTTOM | WM_POS_RIGHT)) == WM_POS_BOTTOM)
b196d2758026 Couriersud to Sam
Sam Lantinga <slouken@libsdl.org>
parents: 4568
diff changeset
371 dx = 0;
b196d2758026 Couriersud to Sam
Sam Lantinga <slouken@libsdl.org>
parents: 4568
diff changeset
372 else if ((wm_grab & (WM_POS_BOTTOM | WM_POS_RIGHT)) == WM_POS_RIGHT)
b196d2758026 Couriersud to Sam
Sam Lantinga <slouken@libsdl.org>
parents: 4568
diff changeset
373 dy = 0;
b196d2758026 Couriersud to Sam
Sam Lantinga <slouken@libsdl.org>
parents: 4568
diff changeset
374 SDL_DFB_CHECK(windata->window->GetSize(windata->window, &cw, &ch));
b196d2758026 Couriersud to Sam
Sam Lantinga <slouken@libsdl.org>
parents: 4568
diff changeset
375 SDL_DFB_CHECK(windata->window->Resize(windata->window, cw + dx, ch + dy));
3023
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
376 }
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
377 wm_lastx = evt->cx;
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
378 wm_lasty = evt->cy;
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
379 return 1;
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
380 }
4636
b196d2758026 Couriersud to Sam
Sam Lantinga <slouken@libsdl.org>
parents: 4568
diff changeset
381 SDL_DFB_CHECK(windata->window->UngrabPointer(windata->window));
b196d2758026 Couriersud to Sam
Sam Lantinga <slouken@libsdl.org>
parents: 4568
diff changeset
382 if (gwindata != NULL)
b196d2758026 Couriersud to Sam
Sam Lantinga <slouken@libsdl.org>
parents: 4568
diff changeset
383 SDL_DFB_CHECK(gwindata->window->GrabPointer(gwindata->window));
3023
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
384 wm_grab = WM_POS_NONE;
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
385 break;
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
386 case DWET_KEYDOWN:
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
387 break;
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
388 case DWET_KEYUP:
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
389 break;
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
390 default:
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
391 ;
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
392 }
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
393 return 0;
d72a0dd80e8b DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff changeset
394 }