comparison gui/wm/ws.c @ 35656:f2093dc82b5f

Cosmetic: Rename wsTWindow wsWindow.
author ib
date Tue, 15 Jan 2013 12:37:42 +0000
parents 9ea476ced9ab
children eadf0731a29a
comparison
equal deleted inserted replaced
35655:9ea476ced9ab 35656:f2093dc82b5f
63 #include <sys/shm.h> 63 #include <sys/shm.h>
64 #endif 64 #endif
65 65
66 #define MOUSEHIDE_DELAY 1000 // in milliseconds 66 #define MOUSEHIDE_DELAY 1000 // in milliseconds
67 67
68 static wsTWindow *mouse_win; 68 static wsWindow *mouse_win;
69 static unsigned int mouse_time; 69 static unsigned int mouse_time;
70 70
71 typedef struct { 71 typedef struct {
72 unsigned long flags; 72 unsigned long flags;
73 unsigned long functions; 73 unsigned long functions;
101 int wsNonNativeOrder = 0; 101 int wsNonNativeOrder = 0;
102 102
103 Bool wsTrue = True; 103 Bool wsTrue = True;
104 104
105 #define wsWLCount 5 105 #define wsWLCount 5
106 wsTWindow *wsWindowList[wsWLCount] = { NULL, NULL, NULL, NULL, NULL }; 106 wsWindow *wsWindowList[wsWLCount] = { NULL, NULL, NULL, NULL, NULL };
107 107
108 unsigned long wsKeyTable[512]; 108 unsigned long wsKeyTable[512];
109 109
110 int wsUseXShm = True; 110 int wsUseXShm = True;
111 int wsUseXShape = True; 111 int wsUseXShape = True;
166 #define MWM_INPUT_FULL_APPLICATION_MODAL 3 166 #define MWM_INPUT_FULL_APPLICATION_MODAL 3
167 #define MWM_INPUT_APPLICATION_MODAL MWM_INPUT_PRIMARY_APPLICATION_MODAL 167 #define MWM_INPUT_APPLICATION_MODAL MWM_INPUT_PRIMARY_APPLICATION_MODAL
168 168
169 #define MWM_TEAROFF_WINDOW (1L << 0) 169 #define MWM_TEAROFF_WINDOW (1L << 0)
170 170
171 void wsWindowDecoration(wsTWindow *win, Bool decor) 171 void wsWindowDecoration(wsWindow *win, Bool decor)
172 { 172 {
173 wsMotifHints = XInternAtom(wsDisplay, "_MOTIF_WM_HINTS", 0); 173 wsMotifHints = XInternAtom(wsDisplay, "_MOTIF_WM_HINTS", 0);
174 174
175 if (wsMotifHints == None) 175 if (wsMotifHints == None)
176 return; 176 return;
220 * Set wsOrgX, wsOrgY, wsMaxX and wsMaxY as well as 220 * Set wsOrgX, wsOrgY, wsMaxX and wsMaxY as well as
221 * win->X, win->Y, win->Width and win->Height. 221 * win->X, win->Y, win->Width and win->Height.
222 * 222 *
223 * @param win pointer to a ws window structure or NULL 223 * @param win pointer to a ws window structure or NULL
224 */ 224 */
225 static void wsUpdateXineramaInfo(wsTWindow *win) 225 static void wsUpdateXineramaInfo(wsWindow *win)
226 { 226 {
227 if (win) { 227 if (win) {
228 vo_dx = win->X; 228 vo_dx = win->X;
229 vo_dy = win->Y; 229 vo_dy = win->Y;
230 vo_dwidth = win->Width; 230 vo_dwidth = win->Width;
403 * @param x x position of the window (real/absolute or mock) 403 * @param x x position of the window (real/absolute or mock)
404 * @param y y position of the window (real/absolute or mock) 404 * @param y y position of the window (real/absolute or mock)
405 * @param width width of the area to place the window in 405 * @param width width of the area to place the window in
406 * @param height height of the area to place the window in 406 * @param height height of the area to place the window in
407 */ 407 */
408 static void wsWindowPosition(wsTWindow *win, int x, int y, int width, int height) 408 static void wsWindowPosition(wsWindow *win, int x, int y, int width, int height)
409 { 409 {
410 switch (x) { 410 switch (x) {
411 case -1: 411 case -1:
412 win->X = wsOrgX + (wsMaxX - width) / 2; 412 win->X = wsOrgX + (wsMaxX - width) / 2;
413 break; 413 break;
439 /** 439 /**
440 * @brief Replace the size hints for the WM_NORMAL_HINTS property of a window. 440 * @brief Replace the size hints for the WM_NORMAL_HINTS property of a window.
441 * 441 *
442 * @param win pointer to a ws window structure 442 * @param win pointer to a ws window structure
443 */ 443 */
444 static void wsSizeHint(wsTWindow *win) 444 static void wsSizeHint(wsWindow *win)
445 { 445 {
446 win->SizeHint.flags = 0; 446 win->SizeHint.flags = 0;
447 447
448 /* obsolete, solely for compatibility reasons */ 448 /* obsolete, solely for compatibility reasons */
449 win->SizeHint.flags |= PPosition; 449 win->SizeHint.flags |= PPosition;
493 /** 493 /**
494 * @brief Wait until a window is mapped if its property requires it. 494 * @brief Wait until a window is mapped if its property requires it.
495 * 495 *
496 * @param win pointer to a ws window structure 496 * @param win pointer to a ws window structure
497 */ 497 */
498 static void wsMapWait(wsTWindow *win) 498 static void wsMapWait(wsWindow *win)
499 { 499 {
500 XEvent xev; 500 XEvent xev;
501 501
502 if (win->Property & wsWaitMap) { 502 if (win->Property & wsWaitMap) {
503 do 503 do
528 // w,h : window size 528 // w,h : window size
529 // b : window border size 529 // b : window border size
530 // c : mouse cursor visible 530 // c : mouse cursor visible
531 // p : properties - "decoration", visible titlebar, etc ... 531 // p : properties - "decoration", visible titlebar, etc ...
532 // ---------------------------------------------------------------------------------------------- 532 // ----------------------------------------------------------------------------------------------
533 void wsCreateWindow(wsTWindow *win, int x, int y, int w, int h, int b, int c, unsigned char p, char *label) 533 void wsCreateWindow(wsWindow *win, int x, int y, int w, int h, int b, int c, unsigned char p, char *label)
534 { 534 {
535 int depth; 535 int depth;
536 536
537 win->Property = p; 537 win->Property = p;
538 538
685 win->MouseHandler = NULL; 685 win->MouseHandler = NULL;
686 win->KeyHandler = NULL; 686 win->KeyHandler = NULL;
687 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[ws] window is created. ( %s ).\n", label); 687 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[ws] window is created. ( %s ).\n", label);
688 } 688 }
689 689
690 void wsDestroyWindow(wsTWindow *win) 690 void wsDestroyWindow(wsWindow *win)
691 { 691 {
692 int l; 692 int l;
693 693
694 l = wsSearch(win->WindowID); 694 l = wsSearch(win->WindowID);
695 695
1061 * 1061 *
1062 * Switch normal window to fullscreen and fullscreen window to normal. 1062 * Switch normal window to fullscreen and fullscreen window to normal.
1063 * 1063 *
1064 * @param win pointer to a ws window structure 1064 * @param win pointer to a ws window structure
1065 */ 1065 */
1066 void wsFullScreen(wsTWindow *win) 1066 void wsFullScreen(wsWindow *win)
1067 { 1067 {
1068 if (win->isFullScreen) { 1068 if (win->isFullScreen) {
1069 if (vo_fs_type & vo_wm_FULLSCREEN) 1069 if (vo_fs_type & vo_wm_FULLSCREEN)
1070 /* window manager supports EWMH */ 1070 /* window manager supports EWMH */
1071 vo_x11_ewmh_fullscreen(win->WindowID, _NET_WM_STATE_REMOVE); 1071 vo_x11_ewmh_fullscreen(win->WindowID, _NET_WM_STATE_REMOVE);
1116 } 1116 }
1117 1117
1118 // ---------------------------------------------------------------------------------------------- 1118 // ----------------------------------------------------------------------------------------------
1119 // Redraw screen. 1119 // Redraw screen.
1120 // ---------------------------------------------------------------------------------------------- 1120 // ----------------------------------------------------------------------------------------------
1121 void wsPostRedisplay(wsTWindow *win) 1121 void wsPostRedisplay(wsWindow *win)
1122 { 1122 {
1123 if (win->ReDraw) { 1123 if (win->ReDraw) {
1124 win->State = wsWindowExpose; 1124 win->State = wsWindowExpose;
1125 win->ReDraw(); 1125 win->ReDraw();
1126 XFlush(wsDisplay); 1126 XFlush(wsDisplay);
1137 } 1137 }
1138 1138
1139 // ---------------------------------------------------------------------------------------------- 1139 // ----------------------------------------------------------------------------------------------
1140 // Put 'Image' to window. 1140 // Put 'Image' to window.
1141 // ---------------------------------------------------------------------------------------------- 1141 // ----------------------------------------------------------------------------------------------
1142 void wsConvert(wsTWindow *win, unsigned char *Image) 1142 void wsConvert(wsWindow *win, unsigned char *Image)
1143 { 1143 {
1144 const uint8_t *src[4] = { Image, NULL, NULL, NULL }; 1144 const uint8_t *src[4] = { Image, NULL, NULL, NULL };
1145 int src_stride[4] = { 4 * win->xImage->width, 0, 0, 0 }; 1145 int src_stride[4] = { 4 * win->xImage->width, 0, 0, 0 };
1146 uint8_t *dst[4] = { win->ImageData, NULL, NULL, NULL }; 1146 uint8_t *dst[4] = { win->ImageData, NULL, NULL, NULL };
1147 int dst_stride[4]; 1147 int dst_stride[4];
1178 break; 1178 break;
1179 } 1179 }
1180 } 1180 }
1181 } 1181 }
1182 1182
1183 void wsPutImage(wsTWindow *win) 1183 void wsPutImage(wsWindow *win)
1184 { 1184 {
1185 #ifdef HAVE_SHM 1185 #ifdef HAVE_SHM
1186 if (wsUseXShm) { 1186 if (wsUseXShm) {
1187 XShmPutImage(wsDisplay, win->WindowID, win->wGC, win->xImage, 1187 XShmPutImage(wsDisplay, win->WindowID, win->wGC, win->xImage,
1188 0, 0, 1188 0, 0,
1199 } 1199 }
1200 1200
1201 // ---------------------------------------------------------------------------------------------- 1201 // ----------------------------------------------------------------------------------------------
1202 // Move window to x, y. 1202 // Move window to x, y.
1203 // ---------------------------------------------------------------------------------------------- 1203 // ----------------------------------------------------------------------------------------------
1204 void wsMoveWindow(wsTWindow *win, Bool abs, int x, int y) 1204 void wsMoveWindow(wsWindow *win, Bool abs, int x, int y)
1205 { 1205 {
1206 if (abs) { 1206 if (abs) {
1207 win->X = x; 1207 win->X = x;
1208 win->Y = y; 1208 win->Y = y;
1209 } else 1209 } else
1223 * @param win pointer to a ws window structure 1223 * @param win pointer to a ws window structure
1224 * @param abs flag whether the position is real/absolute (True) or mock (False) 1224 * @param abs flag whether the position is real/absolute (True) or mock (False)
1225 * @param x x position of the window (real/absolute or mock) 1225 * @param x x position of the window (real/absolute or mock)
1226 * @param y y position of the window (real/absolute or mock) 1226 * @param y y position of the window (real/absolute or mock)
1227 */ 1227 */
1228 void wsMoveWindowWithin(wsTWindow *win, Bool abs, int x, int y) 1228 void wsMoveWindowWithin(wsWindow *win, Bool abs, int x, int y)
1229 { 1229 {
1230 Bool fitting = True; 1230 Bool fitting = True;
1231 1231
1232 wsMoveWindow(win, abs, x, y); 1232 wsMoveWindow(win, abs, x, y);
1233 1233
1252 } 1252 }
1253 1253
1254 // ---------------------------------------------------------------------------------------------- 1254 // ----------------------------------------------------------------------------------------------
1255 // Resize window to sx, sy. 1255 // Resize window to sx, sy.
1256 // ---------------------------------------------------------------------------------------------- 1256 // ----------------------------------------------------------------------------------------------
1257 void wsResizeWindow(wsTWindow *win, int sx, int sy) 1257 void wsResizeWindow(wsWindow *win, int sx, int sy)
1258 { 1258 {
1259 win->Width = sx; 1259 win->Width = sx;
1260 win->Height = sy; 1260 win->Height = sy;
1261 1261
1262 if (vo_wm_type == 0) 1262 if (vo_wm_type == 0)
1275 /** 1275 /**
1276 * @brief Iconify a window. 1276 * @brief Iconify a window.
1277 * 1277 *
1278 * @param win pointer to a ws window structure 1278 * @param win pointer to a ws window structure
1279 */ 1279 */
1280 void wsIconify(wsTWindow *win) 1280 void wsIconify(wsWindow *win)
1281 { 1281 {
1282 XIconifyWindow(wsDisplay, win->WindowID, 0); 1282 XIconifyWindow(wsDisplay, win->WindowID, 0);
1283 } 1283 }
1284 1284
1285 /** 1285 /**
1295 } 1295 }
1296 1296
1297 // ---------------------------------------------------------------------------------------------- 1297 // ----------------------------------------------------------------------------------------------
1298 // Set window background to 'color'. 1298 // Set window background to 'color'.
1299 // ---------------------------------------------------------------------------------------------- 1299 // ----------------------------------------------------------------------------------------------
1300 void wsSetBackground(wsTWindow *win, int color) 1300 void wsSetBackground(wsWindow *win, int color)
1301 { 1301 {
1302 XSetWindowBackground(wsDisplay, win->WindowID, color); 1302 XSetWindowBackground(wsDisplay, win->WindowID, color);
1303 } 1303 }
1304 1304
1305 void wsSetBackgroundRGB(wsTWindow *win, int r, int g, int b) 1305 void wsSetBackgroundRGB(wsWindow *win, int r, int g, int b)
1306 { 1306 {
1307 int color = 0; 1307 int color = 0;
1308 1308
1309 switch (wsOutMask) { 1309 switch (wsOutMask) {
1310 case wsRGB32: 1310 case wsRGB32:
1335 } 1335 }
1336 1336
1337 XSetWindowBackground(wsDisplay, win->WindowID, color); 1337 XSetWindowBackground(wsDisplay, win->WindowID, color);
1338 } 1338 }
1339 1339
1340 void wsSetForegroundRGB(wsTWindow *win, int r, int g, int b) 1340 void wsSetForegroundRGB(wsWindow *win, int r, int g, int b)
1341 { 1341 {
1342 int color = 0; 1342 int color = 0;
1343 1343
1344 switch (wsOutMask) { 1344 switch (wsOutMask) {
1345 case wsRGB32: 1345 case wsRGB32:
1373 } 1373 }
1374 1374
1375 // ---------------------------------------------------------------------------------------------- 1375 // ----------------------------------------------------------------------------------------------
1376 // Show / hide mouse cursor. 1376 // Show / hide mouse cursor.
1377 // ---------------------------------------------------------------------------------------------- 1377 // ----------------------------------------------------------------------------------------------
1378 void wsVisibleMouse(wsTWindow *win, int m) 1378 void wsVisibleMouse(wsWindow *win, int m)
1379 { 1379 {
1380 switch (m) { 1380 switch (m) {
1381 case wsShowMouseCursor: 1381 case wsShowMouseCursor:
1382 1382
1383 if (win->wsCursor != None) { 1383 if (win->wsCursor != None) {
1445 void wsXDone(void) 1445 void wsXDone(void)
1446 { 1446 {
1447 XCloseDisplay(wsDisplay); 1447 XCloseDisplay(wsDisplay);
1448 } 1448 }
1449 1449
1450 void wsVisibleWindow(wsTWindow *win, int show) 1450 void wsVisibleWindow(wsWindow *win, int show)
1451 { 1451 {
1452 switch (show) { 1452 switch (show) {
1453 case wsShowWindow: 1453 case wsShowWindow:
1454 1454
1455 XMapRaised(wsDisplay, win->WindowID); 1455 XMapRaised(wsDisplay, win->WindowID);
1467 } 1467 }
1468 1468
1469 XFlush(wsDisplay); 1469 XFlush(wsDisplay);
1470 } 1470 }
1471 1471
1472 void wsDestroyImage(wsTWindow *win) 1472 void wsDestroyImage(wsWindow *win)
1473 { 1473 {
1474 if (win->xImage) { 1474 if (win->xImage) {
1475 XDestroyImage(win->xImage); 1475 XDestroyImage(win->xImage);
1476 1476
1477 #ifdef HAVE_SHM 1477 #ifdef HAVE_SHM
1483 } 1483 }
1484 1484
1485 win->xImage = NULL; 1485 win->xImage = NULL;
1486 } 1486 }
1487 1487
1488 void wsCreateImage(wsTWindow *win, int Width, int Height) 1488 void wsCreateImage(wsWindow *win, int Width, int Height)
1489 { 1489 {
1490 #ifdef HAVE_SHM 1490 #ifdef HAVE_SHM
1491 if (wsUseXShm) { 1491 if (wsUseXShm) {
1492 win->xImage = XShmCreateImage(wsDisplay, win->VisualInfo.visual, 1492 win->xImage = XShmCreateImage(wsDisplay, win->VisualInfo.visual,
1493 win->VisualInfo.depth, ZPixmap, NULL, &win->Shminfo, Width, Height); 1493 win->VisualInfo.depth, ZPixmap, NULL, &win->Shminfo, Width, Height);
1539 win->ImageData = (unsigned char *)win->xImage->data; 1539 win->ImageData = (unsigned char *)win->xImage->data;
1540 win->ImageDataw = (unsigned short int *)win->xImage->data; 1540 win->ImageDataw = (unsigned short int *)win->xImage->data;
1541 win->ImageDatadw = (unsigned int *)win->xImage->data; 1541 win->ImageDatadw = (unsigned int *)win->xImage->data;
1542 } 1542 }
1543 1543
1544 void wsResizeImage(wsTWindow *win, int Width, int Height) 1544 void wsResizeImage(wsWindow *win, int Width, int Height)
1545 { 1545 {
1546 wsDestroyImage(win); 1546 wsDestroyImage(win);
1547 wsCreateImage(win, Width, Height); 1547 wsCreateImage(win, Width, Height);
1548 } 1548 }
1549 1549
1579 /** 1579 /**
1580 * @brief Clear the entire area in a window. 1580 * @brief Clear the entire area in a window.
1581 * 1581 *
1582 * @param win pointer to a ws window structure 1582 * @param win pointer to a ws window structure
1583 */ 1583 */
1584 void wsClearWindow(wsTWindow *win) 1584 void wsClearWindow(wsWindow *win)
1585 { 1585 {
1586 XClearWindow(wsDisplay, win->WindowID); 1586 XClearWindow(wsDisplay, win->WindowID);
1587 } 1587 }
1588 1588
1589 void wsSetTitle(wsTWindow *win, char *name) 1589 void wsSetTitle(wsWindow *win, char *name)
1590 { 1590 {
1591 XStoreName(wsDisplay, win->WindowID, name); 1591 XStoreName(wsDisplay, win->WindowID, name);
1592 } 1592 }
1593 1593
1594 void wsSetMousePosition(wsTWindow *win, int x, int y) 1594 void wsSetMousePosition(wsWindow *win, int x, int y)
1595 { 1595 {
1596 XWarpPointer(wsDisplay, wsRootWin, win->WindowID, 0, 0, 0, 0, x, y); 1596 XWarpPointer(wsDisplay, wsRootWin, win->WindowID, 0, 0, 0, 0, x, y);
1597 } 1597 }
1598 1598
1599 void wsSetShape(wsTWindow *win, char *data) 1599 void wsSetShape(wsWindow *win, char *data)
1600 { 1600 {
1601 #ifdef CONFIG_XSHAPE 1601 #ifdef CONFIG_XSHAPE
1602 if (!wsUseXShape) 1602 if (!wsUseXShape)
1603 return; 1603 return;
1604 1604