Mercurial > mplayer.hg
comparison gui/wm/ws.c @ 33995:9c2779f24077
Move common code to new function wsWindowPosition().
Use the new function in wsCreateWindow() and wsMoveWindow().
author | ib |
---|---|
date | Thu, 08 Sep 2011 13:30:50 +0000 |
parents | 8e5680eccf54 |
children | acf8545dc4b5 |
comparison
equal
deleted
inserted
replaced
33994:8e5680eccf54 | 33995:9c2779f24077 |
---|---|
375 out_pix_fmt = PIX_FMT_BGR555; | 375 out_pix_fmt = PIX_FMT_BGR555; |
376 break; | 376 break; |
377 } | 377 } |
378 } | 378 } |
379 | 379 |
380 /** | |
381 * @brief Calculate and store the x and y position for a window. | |
382 * | |
383 * @param win pointer to a ws window structure | |
384 * @param x x position of the window (real/absolute or mock) | |
385 * @param y y position of the window (real/absolute or mock) | |
386 * @param width width of the area to place the window in | |
387 * @param height height of the area to place the window in | |
388 */ | |
389 static void wsWindowPosition(wsTWindow *win, int x, int y, int width, int height) | |
390 { | |
391 switch (x) { | |
392 case -1: | |
393 win->X = wsOrgX + (wsMaxX - width) / 2; | |
394 break; | |
395 | |
396 case -2: | |
397 win->X = wsOrgX + wsMaxX - width; | |
398 break; | |
399 | |
400 default: | |
401 win->X = x; | |
402 break; | |
403 } | |
404 | |
405 switch (y) { | |
406 case -1: | |
407 win->Y = wsOrgY + (wsMaxY - height) / 2; | |
408 break; | |
409 | |
410 case -2: | |
411 win->Y = wsOrgY + wsMaxY - height; | |
412 break; | |
413 | |
414 default: | |
415 win->Y = y; | |
416 break; | |
417 } | |
418 } | |
419 | |
380 // ---------------------------------------------------------------------------------------------- | 420 // ---------------------------------------------------------------------------------------------- |
381 // Create window. | 421 // Create window. |
382 // X,Y : window position | 422 // X,Y : window position |
383 // wX,wY : size of window | 423 // wX,wY : size of window |
384 // bW : border width | 424 // bW : border width |
400 if (D & wsShowFrame) | 440 if (D & wsShowFrame) |
401 win->Decorations = 1; | 441 win->Decorations = 1; |
402 | 442 |
403 wsHGC = DefaultGC(wsDisplay, wsScreen); | 443 wsHGC = DefaultGC(wsDisplay, wsScreen); |
404 | 444 |
405 // The window position and size. | 445 wsWindowPosition(win, X, Y, wX, hY); |
406 switch (X) { | |
407 case -1: | |
408 win->X = (wsMaxX / 2) - (wX / 2) + wsOrgX; | |
409 break; | |
410 | |
411 case -2: | |
412 win->X = wsMaxX - wX - 1 + wsOrgX; | |
413 break; | |
414 | |
415 default: | |
416 win->X = X; | |
417 break; | |
418 } | |
419 | |
420 switch (Y) { | |
421 case -1: | |
422 win->Y = (wsMaxY / 2) - (hY / 2) + wsOrgY; | |
423 break; | |
424 | |
425 case -2: | |
426 win->Y = wsMaxY - hY - 1 + wsOrgY; | |
427 break; | |
428 | |
429 default: | |
430 win->Y = Y; | |
431 break; | |
432 } | |
433 | 446 |
434 win->Width = wX; | 447 win->Width = wX; |
435 win->Height = hY; | 448 win->Height = hY; |
436 win->OldX = win->X; | 449 win->OldX = win->X; |
437 win->OldY = win->Y; | 450 win->OldY = win->Y; |
1058 void wsMoveWindow(wsTWindow *win, Bool abs, int x, int y) | 1071 void wsMoveWindow(wsTWindow *win, Bool abs, int x, int y) |
1059 { | 1072 { |
1060 if (abs) { | 1073 if (abs) { |
1061 win->X = x; | 1074 win->X = x; |
1062 win->Y = y; | 1075 win->Y = y; |
1063 } else { | 1076 } else |
1064 switch (x) { | 1077 wsWindowPosition(win, x, y, win->Width, win->Height); |
1065 case -1: | |
1066 win->X = (wsMaxX / 2) - (win->Width / 2) + wsOrgX; | |
1067 break; | |
1068 | |
1069 case -2: | |
1070 win->X = wsMaxX - win->Width + wsOrgX; | |
1071 break; | |
1072 | |
1073 default: | |
1074 win->X = x; | |
1075 break; | |
1076 } | |
1077 | |
1078 switch (y) { | |
1079 case -1: | |
1080 win->Y = (wsMaxY / 2) - (win->Height / 2) + wsOrgY; | |
1081 break; | |
1082 | |
1083 case -2: | |
1084 win->Y = wsMaxY - win->Height + wsOrgY; | |
1085 break; | |
1086 | |
1087 default: | |
1088 win->Y = y; | |
1089 break; | |
1090 } | |
1091 } | |
1092 | 1078 |
1093 win->SizeHint.flags = PPosition | PWinGravity; | 1079 win->SizeHint.flags = PPosition | PWinGravity; |
1094 win->SizeHint.x = win->X; | 1080 win->SizeHint.x = win->X; |
1095 win->SizeHint.y = win->Y; | 1081 win->SizeHint.y = win->Y; |
1096 win->SizeHint.win_gravity = StaticGravity; | 1082 win->SizeHint.win_gravity = StaticGravity; |