Mercurial > sdl-ios-xcode
annotate src/video/directfb/SDL_DirectFB_WM.c @ 4499:c2ebe3e020c6
Added Mac OS X implementation of clipboard support
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Thu, 08 Jul 2010 00:35:58 -0700 |
parents | f7b03b6838cb |
children | 25b9cd8bdc30 |
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 | 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 |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
30 #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
|
31 |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
32 static DFB_Theme theme_std = { |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
33 4, 4, 8, 8, |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
34 {255, 200, 200, 200}, |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
35 24, |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
36 {255, 0, 0, 255}, |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
37 16, |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
38 {255, 255, 255, 255}, |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
39 "/usr/share/fonts/truetype/freefont/FreeSans.ttf", |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
40 {255, 255, 0, 0}, |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
41 {255, 255, 255, 0}, |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
42 }; |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
43 |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
44 static DFB_Theme theme_none = { |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
45 0, 0, 0, 0, |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
46 {0, 0, 0, 0}, |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
47 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 NULL |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
52 }; |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
53 |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
54 static void |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
55 DrTriangle(IDirectFBSurface * s, int down, int x, int y, int w) |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
56 { |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
57 int x1, x2, x3; |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
58 int y1, y2, y3; |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
59 |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
60 if (down) { |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
61 x1 = x + w / 2; |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
62 x2 = x; |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
63 x3 = x + w; |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
64 y1 = y + w; |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
65 y2 = y; |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
66 y3 = y; |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
67 } else { |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
68 x1 = x + w / 2; |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
69 x2 = x; |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
70 x3 = x + w; |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
71 y1 = y; |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
72 y2 = y + w; |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
73 y3 = y + w; |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
74 } |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
75 s->FillTriangle(s, x1, y1, x2, y2, x3, y3); |
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 |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
78 static void |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
79 DrCaption(IDirectFBSurface * s, int x, int y, char *text) |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
80 { |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
81 DFBSurfaceTextFlags flags; |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
82 |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
83 flags = DSTF_CENTER | DSTF_TOP; |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
84 |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
85 s->DrawString(s, text, -1, x, y, flags); |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
86 } |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
87 |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
88 void |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
89 DirectFB_WM_RedrawLayout(SDL_Window * window) |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
90 { |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
91 SDL_DFB_WINDOWDATA(window); |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
92 IDirectFBSurface *s = windata->window_surface; |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
93 DFB_Theme *t = &windata->theme; |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
94 int i; |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
95 int d = (t->caption_size - t->font_size) / 2; |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
96 int x, y, w; |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
97 |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
98 |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
99 if (!windata->is_managed || (window->flags & SDL_WINDOW_FULLSCREEN)) |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
100 return; |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
101 |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
102 //s->SetDrawingFlags(s, DSDRAW_BLEND); |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
103 s->SetColor(s, COLOR_EXPAND(t->frame_color)); |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
104 /* top */ |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
105 for (i = 0; i < t->top_size; i++) |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
106 s->DrawLine(s, 0, i, windata->size.w, i); |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
107 /* bottom */ |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
108 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
|
109 s->DrawLine(s, 0, i, windata->size.w, i); |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
110 /* left */ |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
111 for (i = 0; i < t->left_size; i++) |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
112 s->DrawLine(s, i, 0, i, windata->size.h); |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
113 /* right */ |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
114 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
|
115 s->DrawLine(s, i, 0, i, windata->size.h); |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
116 /* Caption */ |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
117 s->SetColor(s, COLOR_EXPAND(t->caption_color)); |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
118 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
|
119 t->caption_size); |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
120 /* Close Button */ |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
121 w = t->caption_size; |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
122 x = windata->size.w - t->right_size - w + d; |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
123 y = t->top_size + d; |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
124 s->SetColor(s, COLOR_EXPAND(t->close_color)); |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
125 DrTriangle(s, 1, x, y, w - 2 * d); |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
126 /* Max Button */ |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
127 s->SetColor(s, COLOR_EXPAND(t->max_color)); |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
128 DrTriangle(s, window->flags & SDL_WINDOW_MAXIMIZED ? 1 : 0, x - w, |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
129 y, w - 2 * d); |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
130 |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
131 /* Caption */ |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
132 if (window->title) { |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
133 s->SetColor(s, COLOR_EXPAND(t->font_color)); |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
134 DrCaption(s, (x - w) / 2, t->top_size + d, window->title); |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
135 } |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
136 /* Icon */ |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
137 if (windata->icon) { |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
138 DFBRectangle dr; |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
139 |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
140 dr.x = t->left_size + d; |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
141 dr.y = t->top_size + d; |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
142 dr.w = w - 2 * d; |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
143 dr.h = w - 2 * d; |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
144 s->SetBlittingFlags(s, DSBLIT_BLEND_ALPHACHANNEL); |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
145 |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
146 s->StretchBlit(s, windata->icon, NULL, &dr); |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
147 } |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
148 windata->wm_needs_redraw = 0; |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
149 } |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
150 |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
151 DFBResult |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
152 DirectFB_WM_GetClientSize(_THIS, SDL_Window * window, int *cw, int *ch) |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
153 { |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
154 SDL_DFB_WINDOWDATA(window); |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
155 DFBResult ret; |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
156 |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
157 ret = windata->window->GetSize(windata->window, cw, ch); |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
158 *cw -= windata->theme.left_size + windata->theme.right_size; |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
159 *ch -= |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
160 windata->theme.top_size + windata->theme.caption_size + |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
161 windata->theme.bottom_size; |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
162 return ret; |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
163 } |
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 void |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
166 DirectFB_WM_AdjustWindowLayout(SDL_Window * window) |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
167 { |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
168 SDL_DFB_WINDOWDATA(window); |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
169 |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
170 if (!windata->is_managed) |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
171 windata->theme = theme_none; |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
172 else if (window->flags & SDL_WINDOW_FULLSCREEN) { |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
173 windata->theme = theme_none; |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
174 } else if (window->flags & SDL_WINDOW_MAXIMIZED) { |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
175 windata->theme = theme_std; |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
176 windata->theme.left_size = 0; |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
177 windata->theme.right_size = 0; |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
178 windata->theme.top_size = 0; |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
179 windata->theme.bottom_size = 0; |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
180 } else { |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
181 windata->theme = theme_std; |
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 |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
184 windata->client.x = windata->theme.left_size; |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
185 windata->client.y = windata->theme.top_size + windata->theme.caption_size; |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
186 windata->client.w = window->w; |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
187 windata->client.h = window->h; |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
188 windata->size.w = |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
189 window->w + windata->theme.left_size + windata->theme.right_size; |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
190 windata->size.h = |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
191 window->h + windata->theme.top_size + |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
192 windata->theme.caption_size + windata->theme.bottom_size; |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
193 } |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
194 |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
195 void |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
196 DirectFB_WM_MaximizeWindow(_THIS, SDL_Window * 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 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
|
199 SDL_VideoDisplay *display = window->display; |
3023
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
200 |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
201 windata->window->GetPosition(windata->window, |
3040 | 202 &windata->restore.x, &windata->restore.y); |
3023
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
203 windata->window->GetSize(windata->window, &windata->restore.w, |
3040 | 204 &windata->restore.h); |
3023
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
205 |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
206 /* Do this already here */ |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
207 window->flags |= SDL_WINDOW_MAXIMIZED; |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
208 DirectFB_WM_AdjustWindowLayout(window); |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
209 |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
210 windata->window->MoveTo(windata->window, 0, 0); |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
211 windata->window->Resize(windata->window, |
3040 | 212 display->current_mode.w, display->current_mode.h); |
3023
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
213 SDL_SendWindowEvent(windata->sdl_id, SDL_WINDOWEVENT_MAXIMIZED, 0, 0); |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
214 } |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
215 |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
216 void |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
217 DirectFB_WM_RestoreWindow(_THIS, SDL_Window * window) |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
218 { |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
219 SDL_DFB_WINDOWDATA(window); |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
220 |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
221 /* Do this already here */ |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
222 //window->flags &= ~(SDL_WINDOW_MAXIMIZED | SDL_WINDOW_MINIMIZED); |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
223 |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
224 DirectFB_WM_AdjustWindowLayout(window); |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
225 windata->window->MoveTo(windata->window, windata->restore.x, |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
226 windata->restore.y); |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
227 windata->window->Resize(windata->window, windata->restore.w, |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
228 windata->restore.h); |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
229 SDL_SendWindowEvent(windata->sdl_id, SDL_WINDOWEVENT_RESTORED, 0, 0); |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
230 } |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
231 |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
232 enum |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
233 { |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
234 WM_POS_NONE = 0x00, |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
235 WM_POS_CAPTION = 0x01, |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
236 WM_POS_CLOSE = 0x02, |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
237 WM_POS_MAX = 0x04, |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
238 WM_POS_LEFT = 0x08, |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
239 WM_POS_RIGHT = 0x10, |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
240 WM_POS_TOP = 0x20, |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
241 WM_POS_BOTTOM = 0x40, |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
242 }; |
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 static int |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
245 WMIsClient(DFB_WindowData * p, int x, int y) |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
246 { |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
247 x -= p->client.x; |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
248 y -= p->client.y; |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
249 if (x < 0 || y < 0) |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
250 return 0; |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
251 if (x >= p->client.w || y >= p->client.h) |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
252 return 0; |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
253 return 1; |
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 |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
256 static int |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
257 WMPos(DFB_WindowData * p, int x, int y) |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
258 { |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
259 int pos = WM_POS_NONE; |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
260 |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
261 if (!WMIsClient(p, x, y)) { |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
262 if (y < p->theme.top_size) { |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
263 pos |= WM_POS_TOP; |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
264 } else if (y < p->client.y) { |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
265 if (x < |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
266 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
|
267 pos |= WM_POS_CAPTION; |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
268 } else if (x < |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
269 p->size.w - p->theme.right_size - |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
270 p->theme.caption_size) { |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
271 pos |= WM_POS_MAX; |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
272 } else { |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
273 pos |= WM_POS_CLOSE; |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
274 } |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
275 } else if (y >= p->size.h - p->theme.bottom_size) { |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
276 pos |= WM_POS_BOTTOM; |
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 if (x < p->theme.left_size) { |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
279 pos |= WM_POS_LEFT; |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
280 } else if (x >= p->size.w - p->theme.right_size) { |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
281 pos |= WM_POS_RIGHT; |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
282 } |
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 return pos; |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
285 } |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
286 |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
287 static int wm_grab; |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
288 static int wm_lastx; |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
289 static int wm_lasty; |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
290 |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
291 int |
3040 | 292 DirectFB_WM_ProcessEvent(_THIS, SDL_Window * window, DFBWindowEvent * evt) |
3023
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
293 { |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
294 SDL_DFB_WINDOWDATA(window); |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
295 |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
296 if (!windata->is_managed) |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
297 return 0; |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
298 |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
299 switch (evt->type) { |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
300 case DWET_BUTTONDOWN: |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
301 if (evt->buttons & DIBM_LEFT) { |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
302 int pos = WMPos(windata, evt->x, evt->y); |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
303 switch (pos) { |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
304 case WM_POS_NONE: |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
305 return 0; |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
306 case WM_POS_CLOSE: |
3040 | 307 SDL_SendWindowEvent(windata->sdl_id, SDL_WINDOWEVENT_CLOSE, 0, |
308 0); | |
3023
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
309 return 1; |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
310 case WM_POS_MAX: |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
311 if (window->flags & SDL_WINDOW_MAXIMIZED) { |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
312 DirectFB_WM_RestoreWindow(_this, window); |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
313 } else { |
3040 | 314 DirectFB_WM_MaximizeWindow(_this, window); |
3023
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
315 } |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
316 return 1; |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
317 default: |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
318 wm_grab = pos; |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
319 windata->window->GrabPointer(windata->window); |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
320 wm_lastx = evt->cx; |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
321 wm_lasty = evt->cy; |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
322 } |
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 return 1; |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
325 case DWET_BUTTONUP: |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
326 break; |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
327 case DWET_MOTION: |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
328 if (!wm_grab) |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
329 return 0; |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
330 if (evt->buttons & DIBM_LEFT) { |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
331 int dx = evt->cx - wm_lastx; |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
332 int dy = evt->cy - wm_lasty; |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
333 int cw, ch; |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
334 |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
335 if (wm_grab & WM_POS_CAPTION) |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
336 windata->window->Move(windata->window, dx, dy); |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
337 if (wm_grab & WM_POS_RIGHT) { |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
338 windata->window->GetSize(windata->window, &cw, &ch); |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
339 windata->window->Resize(windata->window, cw + dx, ch); |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
340 } |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
341 if (wm_grab & WM_POS_BOTTOM) { |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
342 windata->window->GetSize(windata->window, &cw, &ch); |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
343 windata->window->Resize(windata->window, cw, ch + dy); |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
344 } |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
345 wm_lastx = evt->cx; |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
346 wm_lasty = evt->cy; |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
347 return 1; |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
348 } |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
349 windata->window->UngrabPointer(windata->window); |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
350 wm_grab = WM_POS_NONE; |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
351 break; |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
352 case DWET_KEYDOWN: |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
353 break; |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
354 case DWET_KEYUP: |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
355 break; |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
356 default: |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
357 ; |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
358 } |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
359 return 0; |
d72a0dd80e8b
DirectFB cleanups & simple window manager
Couriersud <couriersud@arcor.de>
parents:
diff
changeset
|
360 } |