1 /* 2 * Copyright © 2007 Novell, Inc. 3 * 4 * Permission to use, copy, modify, distribute, and sell this software 5 * and its documentation for any purpose is hereby granted without 6 * fee, provided that the above copyright notice appear in all copies 7 * and that both that copyright notice and this permission notice 8 * appear in supporting documentation, and that the name of 9 * Novell, Inc. not be used in advertising or publicity pertaining to 10 * distribution of the software without specific, written prior permission. 11 * Novell, Inc. makes no representations about the suitability of this 12 * software for any purpose. It is provided "as is" without express or 13 * implied warranty. 14 * 15 * NOVELL, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 16 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN 17 * NO EVENT SHALL NOVELL, INC. BE LIABLE FOR ANY SPECIAL, INDIRECT OR 18 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 19 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 20 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION 21 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 22 * 23 * Author: David Reveman <davidr@novell.com> 24 */ 25 26 #ifndef _COMPIZ_CORE_H 27 #define _COMPIZ_CORE_H 28 29 #include <compiz-plugin.h> 30 31 #define CORE_ABIVERSION 20091102 32 33 #include <stdio.h> 34 #include <sys/time.h> 35 36 #include <X11/Xutil.h> 37 #include <X11/extensions/Xdamage.h> 38 #include <X11/extensions/Xcomposite.h> 39 #include <X11/extensions/Xinerama.h> 40 #include <X11/extensions/sync.h> 41 #include <X11/Xregion.h> 42 #include <X11/XKBlib.h> 43 44 #define SN_API_NOT_YET_FROZEN 45 #include <libsn/sn.h> 46 47 #include <GL/gl.h> 48 #include <GL/glx.h> 49 50 COMPIZ_BEGIN_DECLS 51 52 #if COMPOSITE_MAJOR > 0 || COMPOSITE_MINOR > 2 53 #define USE_COW 54 #endif 55 56 /* 57 * WORDS_BIGENDIAN should be defined before including this file for 58 * IMAGE_BYTE_ORDER and BITMAP_BIT_ORDER to be set correctly. 59 */ 60 #define LSBFirst 0 61 #define MSBFirst 1 62 63 #ifdef WORDS_BIGENDIAN 64 # define IMAGE_BYTE_ORDER MSBFirst 65 # define BITMAP_BIT_ORDER MSBFirst 66 #else 67 # define IMAGE_BYTE_ORDER LSBFirst 68 # define BITMAP_BIT_ORDER LSBFirst 69 #endif 70 71 typedef struct _CompTexture CompTexture; 72 typedef struct _CompIcon CompIcon; 73 typedef struct _CompWindowExtents CompWindowExtents; 74 typedef struct _CompWindowExtents CompFullscreenMonitorSet; 75 typedef struct _CompProgram CompProgram; 76 typedef struct _CompFunction CompFunction; 77 typedef struct _CompFunctionData CompFunctionData; 78 typedef struct _FragmentAttrib FragmentAttrib; 79 typedef struct _CompCursor CompCursor; 80 typedef struct _CompMatch CompMatch; 81 typedef struct _CompOutput CompOutput; 82 typedef struct _CompWalker CompWalker; 83 84 /* virtual modifiers */ 85 86 #define CompModAlt 0 87 #define CompModMeta 1 88 #define CompModSuper 2 89 #define CompModHyper 3 90 #define CompModModeSwitch 4 91 #define CompModNumLock 5 92 #define CompModScrollLock 6 93 #define CompModNum 7 94 95 #define CompAltMask (1 << 16) 96 #define CompMetaMask (1 << 17) 97 #define CompSuperMask (1 << 18) 98 #define CompHyperMask (1 << 19) 99 #define CompModeSwitchMask (1 << 20) 100 #define CompNumLockMask (1 << 21) 101 #define CompScrollLockMask (1 << 22) 102 103 #define CompNoMask (1 << 25) 104 105 #define CompWindowProtocolDeleteMask (1 << 0) 106 #define CompWindowProtocolTakeFocusMask (1 << 1) 107 #define CompWindowProtocolPingMask (1 << 2) 108 #define CompWindowProtocolSyncRequestMask (1 << 3) 109 110 #define CompWindowTypeDesktopMask (1 << 0) 111 #define CompWindowTypeDockMask (1 << 1) 112 #define CompWindowTypeToolbarMask (1 << 2) 113 #define CompWindowTypeMenuMask (1 << 3) 114 #define CompWindowTypeUtilMask (1 << 4) 115 #define CompWindowTypeSplashMask (1 << 5) 116 #define CompWindowTypeDialogMask (1 << 6) 117 #define CompWindowTypeNormalMask (1 << 7) 118 #define CompWindowTypeDropdownMenuMask (1 << 8) 119 #define CompWindowTypePopupMenuMask (1 << 9) 120 #define CompWindowTypeTooltipMask (1 << 10) 121 #define CompWindowTypeNotificationMask (1 << 11) 122 #define CompWindowTypeComboMask (1 << 12) 123 #define CompWindowTypeDndMask (1 << 13) 124 #define CompWindowTypeModalDialogMask (1 << 14) 125 #define CompWindowTypeFullscreenMask (1 << 15) 126 #define CompWindowTypeUnknownMask (1 << 16) 127 128 #define NO_FOCUS_MASK (CompWindowTypeDesktopMask | \ 129 CompWindowTypeDockMask | \ 130 CompWindowTypeSplashMask) 131 132 #define CompWindowStateModalMask (1 << 0) 133 #define CompWindowStateStickyMask (1 << 1) 134 #define CompWindowStateMaximizedVertMask (1 << 2) 135 #define CompWindowStateMaximizedHorzMask (1 << 3) 136 #define CompWindowStateShadedMask (1 << 4) 137 #define CompWindowStateSkipTaskbarMask (1 << 5) 138 #define CompWindowStateSkipPagerMask (1 << 6) 139 #define CompWindowStateHiddenMask (1 << 7) 140 #define CompWindowStateFullscreenMask (1 << 8) 141 #define CompWindowStateAboveMask (1 << 9) 142 #define CompWindowStateBelowMask (1 << 10) 143 #define CompWindowStateDemandsAttentionMask (1 << 11) 144 #define CompWindowStateDisplayModalMask (1 << 12) 145 146 #define MAXIMIZE_STATE (CompWindowStateMaximizedHorzMask | \ 147 CompWindowStateMaximizedVertMask) 148 149 #define CompWindowActionMoveMask (1 << 0) 150 #define CompWindowActionResizeMask (1 << 1) 151 #define CompWindowActionStickMask (1 << 2) 152 #define CompWindowActionMinimizeMask (1 << 3) 153 #define CompWindowActionMaximizeHorzMask (1 << 4) 154 #define CompWindowActionMaximizeVertMask (1 << 5) 155 #define CompWindowActionFullscreenMask (1 << 6) 156 #define CompWindowActionCloseMask (1 << 7) 157 #define CompWindowActionShadeMask (1 << 8) 158 #define CompWindowActionChangeDesktopMask (1 << 9) 159 #define CompWindowActionAboveMask (1 << 10) 160 #define CompWindowActionBelowMask (1 << 11) 161 162 #define MwmFuncAll (1L << 0) 163 #define MwmFuncResize (1L << 1) 164 #define MwmFuncMove (1L << 2) 165 #define MwmFuncIconify (1L << 3) 166 #define MwmFuncMaximize (1L << 4) 167 #define MwmFuncClose (1L << 5) 168 169 #define MwmDecorAll (1L << 0) 170 #define MwmDecorBorder (1L << 1) 171 #define MwmDecorHandle (1L << 2) 172 #define MwmDecorTitle (1L << 3) 173 #define MwmDecorMenu (1L << 4) 174 #define MwmDecorMinimize (1L << 5) 175 #define MwmDecorMaximize (1L << 6) 176 177 #define WmMoveResizeSizeTopLeft 0 178 #define WmMoveResizeSizeTop 1 179 #define WmMoveResizeSizeTopRight 2 180 #define WmMoveResizeSizeRight 3 181 #define WmMoveResizeSizeBottomRight 4 182 #define WmMoveResizeSizeBottom 5 183 #define WmMoveResizeSizeBottomLeft 6 184 #define WmMoveResizeSizeLeft 7 185 #define WmMoveResizeMove 8 186 #define WmMoveResizeSizeKeyboard 9 187 #define WmMoveResizeMoveKeyboard 10 188 #define WmMoveResizeCancel 11 189 190 /* EWMH source indication client types */ 191 #define ClientTypeUnknown 0 192 #define ClientTypeApplication 1 193 #define ClientTypePager 2 194 195 #define OPAQUE 0xffff 196 #define COLOR 0xffff 197 #define BRIGHT 0xffff 198 199 #define RED_SATURATION_WEIGHT 0.30f 200 #define GREEN_SATURATION_WEIGHT 0.59f 201 #define BLUE_SATURATION_WEIGHT 0.11f 202 203 extern char *programName; 204 extern char **programArgv; 205 extern int programArgc; 206 extern char *backgroundImage; 207 extern REGION emptyRegion; 208 extern REGION infiniteRegion; 209 extern GLushort defaultColor[4]; 210 extern Window currentRoot; 211 extern Bool shutDown; 212 extern Bool restartSignal; 213 extern CompWindow *lastFoundWindow; 214 extern CompWindow *lastDamagedWindow; 215 extern Bool replaceCurrentWm; 216 extern Bool indirectRendering; 217 extern Bool strictBinding; 218 extern Bool useCow; 219 extern Bool noDetection; 220 extern Bool useDesktopHints; 221 extern Bool onlyCurrentScreen; 222 223 extern char **initialPlugins; 224 extern int nInitialPlugins; 225 226 extern int defaultRefreshRate; 227 extern char *defaultTextureFilter; 228 229 extern int lastPointerX; 230 extern int lastPointerY; 231 extern int pointerX; 232 extern int pointerY; 233 234 extern CompCore core; 235 extern CompMetadata coreMetadata; 236 237 #define RESTRICT_VALUE(value, min, max) \ 238 (((value) < (min)) ? (min): ((value) > (max)) ? (max) : (value)) 239 240 #define MOD(a,b) ((a) < 0 ? ((b) - ((-(a) - 1) % (b))) - 1 : (a) % (b)) 241 242 243 /* privates.c */ 244 245 #define WRAP(priv, real, func, wrapFunc) \ 246 (priv)->func = (real)->func; \ 247 (real)->func = (wrapFunc) 248 249 #define UNWRAP(priv, real, func) \ 250 (real)->func = (priv)->func 251 252 typedef union _CompPrivate { 253 void *ptr; 254 long val; 255 unsigned long uval; 256 void *(*fptr) (void); 257 } CompPrivate; 258 259 typedef int (*ReallocPrivatesProc) (int size, void *closure); 260 261 int 262 allocatePrivateIndex (int *len, 263 char **indices, 264 ReallocPrivatesProc reallocProc, 265 void *closure); 266 267 void 268 freePrivateIndex (int len, 269 char *indices, 270 int index); 271 272 273 /* object.c */ 274 275 typedef unsigned int CompObjectType; 276 277 #define COMP_OBJECT_TYPE_CORE 0 278 #define COMP_OBJECT_TYPE_DISPLAY 1 279 #define COMP_OBJECT_TYPE_SCREEN 2 280 #define COMP_OBJECT_TYPE_WINDOW 3 281 282 struct _CompObject { 283 CompObjectType type; 284 CompPrivate *privates; 285 CompObject *parent; 286 }; 287 288 typedef CompBool (*ObjectCallBackProc) (CompObject *object, 289 void *closure); 290 291 typedef CompBool (*ObjectTypeCallBackProc) (CompObjectType type, 292 CompObject *parent, 293 void *closure); 294 295 void 296 compObjectInit (CompObject *object, 297 CompPrivate *privates, 298 CompObjectType type); 299 300 void 301 compObjectFini (CompObject *object); 302 303 int 304 compObjectAllocatePrivateIndex (CompObject *parent, 305 CompObjectType type); 306 307 void 308 compObjectFreePrivateIndex (CompObject *parent, 309 CompObjectType type, 310 int index); 311 312 CompBool 313 compObjectForEach (CompObject *parent, 314 CompObjectType type, 315 ObjectCallBackProc proc, 316 void *closure); 317 318 CompBool 319 compObjectForEachType (CompObject *parent, 320 ObjectTypeCallBackProc proc, 321 void *closure); 322 323 const char * 324 compObjectTypeName (CompObjectType type); 325 326 char * 327 compObjectName (CompObject *object); 328 329 CompObject * 330 compObjectFind (CompObject *parent, 331 CompObjectType type, 332 const char *name); 333 334 #define ARRAY_SIZE(array) \ 335 (sizeof (array) / sizeof (array[0])) 336 337 #define DISPATCH_CHECK(object, dispTab, tabSize) \ 338 ((object)->type < (tabSize) && (dispTab)[(object)->type]) 339 340 #define DISPATCH(object, dispTab, tabSize, args) \ 341 if (DISPATCH_CHECK (object, dispTab, tabSize)) \ 342 (*(dispTab)[(object)->type]) args 343 344 #define RETURN_DISPATCH(object, dispTab, tabSize, def, args) \ 345 if (DISPATCH_CHECK (object, dispTab, tabSize)) \ 346 return (*(dispTab)[(object)->type]) args; \ 347 else \ 348 return (def) 349 350 /* session.c */ 351 352 typedef enum { 353 CompSessionEventSaveYourself = 0, 354 CompSessionEventSaveComplete, 355 CompSessionEventDie, 356 CompSessionEventShutdownCancelled 357 } CompSessionEvent; 358 359 typedef enum { 360 CompSessionClientId = 0, 361 CompSessionPrevClientId 362 } CompSessionClientIdType; 363 364 typedef void (*SessionEventProc) (CompCore *c, 365 CompSessionEvent event, 366 CompOption *arguments, 367 unsigned int nArguments); 368 369 void 370 initSession (char *smPrevClientId); 371 372 void 373 closeSession (void); 374 375 void 376 sessionEvent (CompCore *c, 377 CompSessionEvent event, 378 CompOption *arguments, 379 unsigned int nArguments); 380 381 char * 382 getSessionClientId (CompSessionClientIdType type); 383 384 /* option.c */ 385 386 typedef enum { 387 CompBindingTypeNone = 0, 388 CompBindingTypeKey = 1 << 0, 389 CompBindingTypeButton = 1 << 1, 390 CompBindingTypeEdgeButton = 1 << 2 391 } CompBindingType; 392 393 typedef enum { 394 CompActionStateInitKey = 1 << 0, 395 CompActionStateTermKey = 1 << 1, 396 CompActionStateInitButton = 1 << 2, 397 CompActionStateTermButton = 1 << 3, 398 CompActionStateInitBell = 1 << 4, 399 CompActionStateInitEdge = 1 << 5, 400 CompActionStateTermEdge = 1 << 6, 401 CompActionStateInitEdgeDnd = 1 << 7, 402 CompActionStateTermEdgeDnd = 1 << 8, 403 CompActionStateCommit = 1 << 9, 404 CompActionStateCancel = 1 << 10, 405 CompActionStateAutoGrab = 1 << 11, 406 CompActionStateNoEdgeDelay = 1 << 12 407 } CompActionState; 408 409 typedef enum { 410 CompLogLevelFatal = 0, 411 CompLogLevelError, 412 CompLogLevelWarn, 413 CompLogLevelInfo, 414 CompLogLevelDebug 415 } CompLogLevel; 416 417 typedef struct _CompKeyBinding { 418 int keycode; 419 unsigned int modifiers; 420 } CompKeyBinding; 421 422 typedef struct _CompButtonBinding { 423 int button; 424 unsigned int modifiers; 425 } CompButtonBinding; 426 427 typedef struct _CompAction CompAction; 428 429 typedef Bool (*CompActionCallBackProc) (CompDisplay *d, 430 CompAction *action, 431 CompActionState state, 432 CompOption *option, 433 int nOption); 434 435 struct _CompAction { 436 CompActionCallBackProc initiate; 437 CompActionCallBackProc terminate; 438 439 CompActionState state; 440 441 CompBindingType type; 442 CompKeyBinding key; 443 CompButtonBinding button; 444 445 Bool bell; 446 447 unsigned int edgeMask; 448 449 CompPrivate priv; 450 }; 451 452 typedef union _CompMatchOp CompMatchOp; 453 454 struct _CompMatch { 455 CompDisplay *display; 456 CompMatchOp *op; 457 int nOp; 458 }; 459 460 typedef struct { 461 CompOptionType type; 462 CompOptionValue *value; 463 int nValue; 464 } CompListValue; 465 466 union _CompOptionValue { 467 Bool b; 468 int i; 469 float f; 470 char *s; 471 unsigned short c[4]; 472 CompAction action; 473 CompMatch match; 474 CompListValue list; 475 }; 476 477 typedef struct _CompOptionIntRestriction { 478 int min; 479 int max; 480 } CompOptionIntRestriction; 481 482 typedef struct _CompOptionFloatRestriction { 483 float min; 484 float max; 485 float precision; 486 } CompOptionFloatRestriction; 487 488 typedef union { 489 CompOptionIntRestriction i; 490 CompOptionFloatRestriction f; 491 } CompOptionRestriction; 492 493 struct _CompOption { 494 char *name; 495 CompOptionType type; 496 CompOptionValue value; 497 CompOptionRestriction rest; 498 }; 499 500 typedef CompOption *(*DisplayOptionsProc) (CompDisplay *display, int *count); 501 typedef CompOption *(*ScreenOptionsProc) (CompScreen *screen, int *count); 502 503 Bool 504 getBoolOptionNamed (CompOption *option, 505 int nOption, 506 const char *name, 507 Bool defaultValue); 508 509 int 510 getIntOptionNamed (CompOption *option, 511 int nOption, 512 const char *name, 513 int defaultValue); 514 515 float 516 getFloatOptionNamed (CompOption *option, 517 int nOption, 518 const char *name, 519 float defaultValue); 520 521 char * 522 getStringOptionNamed (CompOption *option, 523 int nOption, 524 const char *name, 525 char *defaultValue); 526 527 unsigned short * 528 getColorOptionNamed (CompOption *option, 529 int nOption, 530 const char *name, 531 unsigned short *defaultValue); 532 533 CompMatch * 534 getMatchOptionNamed (CompOption *option, 535 int nOption, 536 const char *name, 537 CompMatch *defaultValue); 538 539 char * 540 keyBindingToString (CompDisplay *d, 541 CompKeyBinding *key); 542 543 char * 544 buttonBindingToString (CompDisplay *d, 545 CompButtonBinding *button); 546 547 char * 548 keyActionToString (CompDisplay *d, 549 CompAction *action); 550 551 char * 552 buttonActionToString (CompDisplay *d, 553 CompAction *action); 554 555 Bool 556 stringToKeyBinding (CompDisplay *d, 557 const char *binding, 558 CompKeyBinding *key); 559 560 Bool 561 stringToButtonBinding (CompDisplay *d, 562 const char *binding, 563 CompButtonBinding *button); 564 565 void 566 stringToKeyAction (CompDisplay *d, 567 const char *binding, 568 CompAction *action); 569 570 void 571 stringToButtonAction (CompDisplay *d, 572 const char *binding, 573 CompAction *action); 574 575 const char * 576 edgeToString (unsigned int edge); 577 578 unsigned int 579 stringToEdgeMask (const char *edge); 580 581 char * 582 edgeMaskToString (unsigned int edgeMask); 583 584 Bool 585 stringToColor (const char *color, 586 unsigned short *rgba); 587 588 char * 589 colorToString (unsigned short *rgba); 590 591 const char * 592 optionTypeToString (CompOptionType type); 593 594 Bool 595 isActionOption (CompOption *option); 596 597 598 /* core.c */ 599 600 typedef CompBool (*InitPluginForObjectProc) (CompPlugin *plugin, 601 CompObject *object); 602 typedef void (*FiniPluginForObjectProc) (CompPlugin *plugin, 603 CompObject *object); 604 605 typedef CompBool (*SetOptionForPluginProc) (CompObject *object, 606 const char *plugin, 607 const char *name, 608 CompOptionValue *value); 609 610 typedef void (*ObjectAddProc) (CompObject *parent, 611 CompObject *object); 612 typedef void (*ObjectRemoveProc) (CompObject *parent, 613 CompObject *object); 614 615 #define NOTIFY_CREATE_MASK (1 << 0) 616 #define NOTIFY_DELETE_MASK (1 << 1) 617 #define NOTIFY_MOVE_MASK (1 << 2) 618 #define NOTIFY_MODIFY_MASK (1 << 3) 619 620 typedef void (*FileWatchCallBackProc) (const char *name, 621 void *closure); 622 623 typedef int CompFileWatchHandle; 624 625 typedef struct _CompFileWatch { 626 struct _CompFileWatch *next; 627 char *path; 628 int mask; 629 FileWatchCallBackProc callBack; 630 void *closure; 631 CompFileWatchHandle handle; 632 } CompFileWatch; 633 634 typedef void (*FileWatchAddedProc) (CompCore *core, 635 CompFileWatch *fileWatch); 636 637 typedef void (*FileWatchRemovedProc) (CompCore *core, 638 CompFileWatch *fileWatch); 639 640 typedef struct _CompTimeout { 641 struct _CompTimeout *next; 642 int minTime; 643 int maxTime; 644 int minLeft; 645 int maxLeft; 646 CallBackProc callBack; 647 void *closure; 648 CompTimeoutHandle handle; 649 } CompTimeout; 650 651 typedef struct _CompWatchFd { 652 struct _CompWatchFd *next; 653 int fd; 654 CallBackProc callBack; 655 void *closure; 656 CompWatchFdHandle handle; 657 } CompWatchFd; 658 659 typedef void (*LogMessageProc) (const char *componentName, 660 CompLogLevel level, 661 const char *message); 662 663 struct _CompCore { 664 CompObject base; 665 666 CompDisplay *displays; 667 668 Region tmpRegion; 669 Region outputRegion; 670 671 CompFileWatch *fileWatch; 672 CompFileWatchHandle lastFileWatchHandle; 673 674 CompTimeout *timeouts; 675 struct timeval lastTimeout; 676 CompTimeoutHandle lastTimeoutHandle; 677 678 CompWatchFd *watchFds; 679 CompWatchFdHandle lastWatchFdHandle; 680 struct pollfd *watchPollFds; 681 int nWatchFds; 682 683 InitPluginForObjectProc initPluginForObject; 684 FiniPluginForObjectProc finiPluginForObject; 685 686 SetOptionForPluginProc setOptionForPlugin; 687 688 ObjectAddProc objectAdd; 689 ObjectRemoveProc objectRemove; 690 691 FileWatchAddedProc fileWatchAdded; 692 FileWatchRemovedProc fileWatchRemoved; 693 694 SessionEventProc sessionEvent; 695 LogMessageProc logMessage; 696 }; 697 698 int 699 allocCoreObjectPrivateIndex (CompObject *parent); 700 701 void 702 freeCoreObjectPrivateIndex (CompObject *parent, 703 int index); 704 705 CompBool 706 forEachCoreObject (CompObject *parent, 707 ObjectCallBackProc proc, 708 void *closure); 709 710 char * 711 nameCoreObject (CompObject *object); 712 713 CompObject * 714 findCoreObject (CompObject *parent, 715 const char *name); 716 717 CompBool 718 initCore (void); 719 720 void 721 finiCore (void); 722 723 int 724 allocateCorePrivateIndex (void); 725 726 void 727 freeCorePrivateIndex (int index); 728 729 void 730 addDisplayToCore (CompDisplay *d); 731 732 CompFileWatchHandle 733 addFileWatch (const char *path, 734 int mask, 735 FileWatchCallBackProc callBack, 736 void *closure); 737 738 void 739 removeFileWatch (CompFileWatchHandle handle); 740 741 742 /* display.c */ 743 744 #define COMP_DISPLAY_OPTION_ABI 0 745 #define COMP_DISPLAY_OPTION_ACTIVE_PLUGINS 1 746 #define COMP_DISPLAY_OPTION_TEXTURE_FILTER 2 747 #define COMP_DISPLAY_OPTION_CLICK_TO_FOCUS 3 748 #define COMP_DISPLAY_OPTION_AUTORAISE 4 749 #define COMP_DISPLAY_OPTION_AUTORAISE_DELAY 5 750 #define COMP_DISPLAY_OPTION_CLOSE_WINDOW_KEY 6 751 #define COMP_DISPLAY_OPTION_CLOSE_WINDOW_BUTTON 7 752 #define COMP_DISPLAY_OPTION_SLOW_ANIMATIONS_KEY 8 753 #define COMP_DISPLAY_OPTION_RAISE_WINDOW_KEY 9 754 #define COMP_DISPLAY_OPTION_RAISE_WINDOW_BUTTON 10 755 #define COMP_DISPLAY_OPTION_LOWER_WINDOW_KEY 11 756 #define COMP_DISPLAY_OPTION_LOWER_WINDOW_BUTTON 12 757 #define COMP_DISPLAY_OPTION_UNMAXIMIZE_WINDOW_KEY 13 758 #define COMP_DISPLAY_OPTION_MINIMIZE_WINDOW_KEY 14 759 #define COMP_DISPLAY_OPTION_MINIMIZE_WINDOW_BUTTON 15 760 #define COMP_DISPLAY_OPTION_MAXIMIZE_WINDOW_KEY 16 761 #define COMP_DISPLAY_OPTION_MAXIMIZE_WINDOW_HORZ_KEY 17 762 #define COMP_DISPLAY_OPTION_MAXIMIZE_WINDOW_VERT_KEY 18 763 #define COMP_DISPLAY_OPTION_WINDOW_MENU_BUTTON 19 764 #define COMP_DISPLAY_OPTION_WINDOW_MENU_KEY 20 765 #define COMP_DISPLAY_OPTION_SHOW_DESKTOP_KEY 21 766 #define COMP_DISPLAY_OPTION_SHOW_DESKTOP_EDGE 22 767 #define COMP_DISPLAY_OPTION_RAISE_ON_CLICK 23 768 #define COMP_DISPLAY_OPTION_AUDIBLE_BELL 24 769 #define COMP_DISPLAY_OPTION_TOGGLE_WINDOW_MAXIMIZED_KEY 25 770 #define COMP_DISPLAY_OPTION_TOGGLE_WINDOW_MAXIMIZED_BUTTON 26 771 #define COMP_DISPLAY_OPTION_TOGGLE_WINDOW_MAXIMIZED_HORZ_KEY 27 772 #define COMP_DISPLAY_OPTION_TOGGLE_WINDOW_MAXIMIZED_VERT_KEY 28 773 #define COMP_DISPLAY_OPTION_HIDE_SKIP_TASKBAR_WINDOWS 29 774 #define COMP_DISPLAY_OPTION_TOGGLE_WINDOW_SHADED_KEY 30 775 #define COMP_DISPLAY_OPTION_IGNORE_HINTS_WHEN_MAXIMIZED 31 776 #define COMP_DISPLAY_OPTION_PING_DELAY 32 777 #define COMP_DISPLAY_OPTION_EDGE_DELAY 33 778 #define COMP_DISPLAY_OPTION_NUM 34 779 780 typedef void (*HandleEventProc) (CompDisplay *display, 781 XEvent *event); 782 783 typedef void (*HandleCompizEventProc) (CompDisplay *display, 784 const char *pluginName, 785 const char *eventName, 786 CompOption *option, 787 int nOption); 788 789 typedef void (*ForEachWindowProc) (CompWindow *window, 790 void *closure); 791 792 typedef Bool (*FileToImageProc) (CompDisplay *display, 793 const char *path, 794 const char *name, 795 int *width, 796 int *height, 797 int *stride, 798 void **data); 799 800 typedef Bool (*ImageToFileProc) (CompDisplay *display, 801 const char *path, 802 const char *name, 803 const char *format, 804 int width, 805 int height, 806 int stride, 807 void *data); 808 809 #define MATCH_OP_AND_MASK (1 << 0) 810 #define MATCH_OP_NOT_MASK (1 << 1) 811 812 typedef enum { 813 CompMatchOpTypeGroup, 814 CompMatchOpTypeExp 815 } CompMatchOpType; 816 817 typedef struct _CompMatchAnyOp { 818 CompMatchOpType type; 819 int flags; 820 } CompMatchAnyOp; 821 822 typedef struct _CompMatchGroupOp { 823 CompMatchOpType type; 824 int flags; 825 CompMatchOp *op; 826 int nOp; 827 } CompMatchGroupOp; 828 829 typedef void (*CompMatchExpFiniProc) (CompDisplay *display, 830 CompPrivate priv); 831 832 typedef Bool (*CompMatchExpEvalProc) (CompDisplay *display, 833 CompWindow *window, 834 CompPrivate priv); 835 836 typedef struct _CompMatchExp { 837 CompMatchExpFiniProc fini; 838 CompMatchExpEvalProc eval; 839 CompPrivate priv; 840 } CompMatchExp; 841 842 typedef struct _CompMatchExpOp { 843 CompMatchOpType type; 844 int flags; 845 char *value; 846 CompMatchExp e; 847 } CompMatchExpOp; 848 849 union _CompMatchOp { 850 CompMatchOpType type; 851 CompMatchAnyOp any; 852 CompMatchGroupOp group; 853 CompMatchExpOp exp; 854 }; 855 856 typedef void (*MatchInitExpProc) (CompDisplay *display, 857 CompMatchExp *exp, 858 const char *value); 859 860 typedef void (*MatchExpHandlerChangedProc) (CompDisplay *display); 861 862 typedef void (*MatchPropertyChangedProc) (CompDisplay *display, 863 CompWindow *window); 864 865 struct _CompDisplay { 866 CompObject base; 867 868 CompDisplay *next; 869 870 Display *display; 871 CompScreen *screens; 872 873 CompWatchFdHandle watchFdHandle; 874 875 char *screenPrivateIndices; 876 int screenPrivateLen; 877 878 int compositeEvent, compositeError, compositeOpcode; 879 int damageEvent, damageError; 880 int syncEvent, syncError; 881 int fixesEvent, fixesError, fixesVersion; 882 883 Bool randrExtension; 884 int randrEvent, randrError; 885 886 Bool shapeExtension; 887 int shapeEvent, shapeError; 888 889 Bool xkbExtension; 890 int xkbEvent, xkbError; 891 892 Bool xineramaExtension; 893 int xineramaEvent, xineramaError; 894 895 XineramaScreenInfo *screenInfo; 896 int nScreenInfo; 897 898 SnDisplay *snDisplay; 899 900 Atom supportedAtom; 901 Atom supportingWmCheckAtom; 902 903 Atom utf8StringAtom; 904 905 Atom wmNameAtom; 906 907 Atom winTypeAtom; 908 Atom winTypeDesktopAtom; 909 Atom winTypeDockAtom; 910 Atom winTypeToolbarAtom; 911 Atom winTypeMenuAtom; 912 Atom winTypeUtilAtom; 913 Atom winTypeSplashAtom; 914 Atom winTypeDialogAtom; 915 Atom winTypeNormalAtom; 916 Atom winTypeDropdownMenuAtom; 917 Atom winTypePopupMenuAtom; 918 Atom winTypeTooltipAtom; 919 Atom winTypeNotificationAtom; 920 Atom winTypeComboAtom; 921 Atom winTypeDndAtom; 922 923 Atom winOpacityAtom; 924 Atom winBrightnessAtom; 925 Atom winSaturationAtom; 926 Atom winActiveAtom; 927 Atom winDesktopAtom; 928 929 Atom workareaAtom; 930 931 Atom desktopViewportAtom; 932 Atom desktopGeometryAtom; 933 Atom currentDesktopAtom; 934 Atom numberOfDesktopsAtom; 935 936 Atom winStateAtom; 937 Atom winStateModalAtom; 938 Atom winStateStickyAtom; 939 Atom winStateMaximizedVertAtom; 940 Atom winStateMaximizedHorzAtom; 941 Atom winStateShadedAtom; 942 Atom winStateSkipTaskbarAtom; 943 Atom winStateSkipPagerAtom; 944 Atom winStateHiddenAtom; 945 Atom winStateFullscreenAtom; 946 Atom winStateAboveAtom; 947 Atom winStateBelowAtom; 948 Atom winStateDemandsAttentionAtom; 949 Atom winStateDisplayModalAtom; 950 951 Atom winActionMoveAtom; 952 Atom winActionResizeAtom; 953 Atom winActionStickAtom; 954 Atom winActionMinimizeAtom; 955 Atom winActionMaximizeHorzAtom; 956 Atom winActionMaximizeVertAtom; 957 Atom winActionFullscreenAtom; 958 Atom winActionCloseAtom; 959 Atom winActionShadeAtom; 960 Atom winActionChangeDesktopAtom; 961 Atom winActionAboveAtom; 962 Atom winActionBelowAtom; 963 964 Atom wmAllowedActionsAtom; 965 966 Atom wmStrutAtom; 967 Atom wmStrutPartialAtom; 968 969 Atom wmUserTimeAtom; 970 971 Atom wmIconAtom; 972 Atom wmIconGeometryAtom; 973 974 Atom clientListAtom; 975 Atom clientListStackingAtom; 976 977 Atom frameExtentsAtom; 978 Atom frameWindowAtom; 979 980 Atom wmStateAtom; 981 Atom wmChangeStateAtom; 982 Atom wmProtocolsAtom; 983 Atom wmClientLeaderAtom; 984 985 Atom wmDeleteWindowAtom; 986 Atom wmTakeFocusAtom; 987 Atom wmPingAtom; 988 989 Atom wmSyncRequestAtom; 990 Atom wmSyncRequestCounterAtom; 991 992 Atom wmFullscreenMonitorsAtom; 993 994 Atom closeWindowAtom; 995 Atom wmMoveResizeAtom; 996 Atom moveResizeWindowAtom; 997 Atom restackWindowAtom; 998 999 Atom showingDesktopAtom; 1000 1001 Atom xBackgroundAtom[2]; 1002 1003 Atom toolkitActionAtom; 1004 Atom toolkitActionWindowMenuAtom; 1005 Atom toolkitActionForceQuitDialogAtom; 1006 1007 Atom mwmHintsAtom; 1008 1009 Atom xdndAwareAtom; 1010 Atom xdndEnterAtom; 1011 Atom xdndLeaveAtom; 1012 Atom xdndPositionAtom; 1013 Atom xdndStatusAtom; 1014 Atom xdndDropAtom; 1015 1016 Atom managerAtom; 1017 Atom targetsAtom; 1018 Atom multipleAtom; 1019 Atom timestampAtom; 1020 Atom versionAtom; 1021 Atom atomPairAtom; 1022 1023 Atom startupIdAtom; 1024 1025 unsigned int lastPing; 1026 CompTimeoutHandle pingHandle; 1027 1028 GLenum textureFilter; 1029 1030 Window activeWindow; 1031 Window nextActiveWindow; 1032 1033 Window below; 1034 char displayString[256]; 1035 1036 XModifierKeymap *modMap; 1037 unsigned int modMask[CompModNum]; 1038 unsigned int ignoredModMask; 1039 1040 KeyCode escapeKeyCode; 1041 KeyCode returnKeyCode; 1042 1043 CompOption opt[COMP_DISPLAY_OPTION_NUM]; 1044 1045 CompTimeoutHandle autoRaiseHandle; 1046 Window autoRaiseWindow; 1047 1048 CompTimeoutHandle edgeDelayHandle; 1049 1050 CompOptionValue plugin; 1051 Bool dirtyPluginList; 1052 1053 HandleEventProc handleEvent; 1054 HandleCompizEventProc handleCompizEvent; 1055 1056 FileToImageProc fileToImage; 1057 ImageToFileProc imageToFile; 1058 1059 MatchInitExpProc matchInitExp; 1060 MatchExpHandlerChangedProc matchExpHandlerChanged; 1061 MatchPropertyChangedProc matchPropertyChanged; 1062 1063 LogMessageProc logMessage; 1064 1065 void *reserved; 1066 }; 1067 1068 #define GET_CORE_DISPLAY(object) ((CompDisplay *) (object)) 1069 #define CORE_DISPLAY(object) CompDisplay *d = GET_CORE_DISPLAY (object) 1070 1071 CompBool 1072 allocDisplayObjectPrivates (CompObject *object, 1073 CompObject *parent); 1074 1075 int 1076 allocDisplayObjectPrivateIndex (CompObject *parent); 1077 1078 void 1079 freeDisplayObjectPrivateIndex (CompObject *parent, 1080 int index); 1081 1082 CompBool 1083 forEachDisplayObject (CompObject *parent, 1084 ObjectCallBackProc proc, 1085 void *closure); 1086 1087 char * 1088 nameDisplayObject (CompObject *object); 1089 1090 CompObject * 1091 findDisplayObject (CompObject *parent, 1092 const char *name); 1093 1094 int 1095 allocateDisplayPrivateIndex (void); 1096 1097 void 1098 freeDisplayPrivateIndex (int index); 1099 1100 CompOption * 1101 getDisplayOptions (CompPlugin *plugin, 1102 CompDisplay *display, 1103 int *count); 1104 1105 Bool 1106 setDisplayOption (CompPlugin *plugin, 1107 CompDisplay *display, 1108 const char *name, 1109 CompOptionValue *value); 1110 1111 void 1112 compLogMessage (const char *componentName, 1113 CompLogLevel level, 1114 const char *format, 1115 ...); 1116 1117 void 1118 logMessage (const char *componentName, 1119 CompLogLevel level, 1120 const char *message); 1121 1122 const char * 1123 logLevelToString (CompLogLevel level); 1124 1125 int 1126 compCheckForError (Display *dpy); 1127 1128 void 1129 addScreenToDisplay (CompDisplay *display, 1130 CompScreen *s); 1131 1132 Bool 1133 addDisplay (const char *name); 1134 1135 void 1136 removeDisplay (CompDisplay *d); 1137 1138 Time 1139 getCurrentTimeFromDisplay (CompDisplay *d); 1140 1141 void 1142 forEachWindowOnDisplay (CompDisplay *display, 1143 ForEachWindowProc proc, 1144 void *closure); 1145 1146 CompScreen * 1147 findScreenAtDisplay (CompDisplay *d, 1148 Window root); 1149 1150 CompWindow * 1151 findWindowAtDisplay (CompDisplay *display, 1152 Window id); 1153 1154 CompWindow * 1155 findTopLevelWindowAtDisplay (CompDisplay *d, 1156 Window id); 1157 1158 unsigned int 1159 virtualToRealModMask (CompDisplay *d, 1160 unsigned int modMask); 1161 1162 void 1163 updateModifierMappings (CompDisplay *d); 1164 1165 unsigned int 1166 keycodeToModifiers (CompDisplay *d, 1167 int keycode); 1168 1169 void 1170 eventLoop (void); 1171 1172 void 1173 handleSelectionRequest (CompDisplay *display, 1174 XEvent *event); 1175 1176 void 1177 handleSelectionClear (CompDisplay *display, 1178 XEvent *event); 1179 1180 void 1181 warpPointer (CompScreen *screen, 1182 int dx, 1183 int dy); 1184 1185 Bool 1186 setDisplayAction (CompDisplay *display, 1187 CompOption *o, 1188 CompOptionValue *value); 1189 1190 Bool 1191 readImageFromFile (CompDisplay *display, 1192 const char *name, 1193 int *width, 1194 int *height, 1195 void **data); 1196 1197 Bool 1198 writeImageToFile (CompDisplay *display, 1199 const char *path, 1200 const char *name, 1201 const char *format, 1202 int width, 1203 int height, 1204 void *data); 1205 1206 Bool 1207 fileToImage (CompDisplay *display, 1208 const char *path, 1209 const char *name, 1210 int *width, 1211 int *height, 1212 int *stride, 1213 void **data); 1214 1215 Bool 1216 imageToFile (CompDisplay *display, 1217 const char *path, 1218 const char *name, 1219 const char *format, 1220 int width, 1221 int height, 1222 int stride, 1223 void *data); 1224 1225 CompCursor * 1226 findCursorAtDisplay (CompDisplay *display); 1227 1228 1229 /* event.c */ 1230 1231 typedef struct _CompDelayedEdgeSettings 1232 { 1233 CompDisplay *d; 1234 1235 unsigned int edge; 1236 unsigned int state; 1237 1238 CompOption option[7]; 1239 unsigned int nOption; 1240 } CompDelayedEdgeSettings; 1241 1242 void 1243 handleEvent (CompDisplay *display, 1244 XEvent *event); 1245 1246 void 1247 handleCompizEvent (CompDisplay *display, 1248 const char *pluginName, 1249 const char *eventName, 1250 CompOption *option, 1251 int nOption); 1252 1253 void 1254 handleSyncAlarm (CompWindow *w); 1255 1256 Bool 1257 eventMatches (CompDisplay *display, 1258 XEvent *event, 1259 CompOption *option); 1260 1261 Bool 1262 eventTerminates (CompDisplay *display, 1263 XEvent *event, 1264 CompOption *option); 1265 1266 void 1267 clearTargetOutput (CompDisplay *display, 1268 unsigned int mask); 1269 1270 /* paint.c */ 1271 1272 #define MULTIPLY_USHORT(us1, us2) \ 1273 (((GLuint) (us1) * (GLuint) (us2)) / 0xffff) 1274 1275 /* camera distance from screen, 0.5 * tan (FOV) */ 1276 #define DEFAULT_Z_CAMERA 0.866025404f 1277 1278 #define DEG2RAD (M_PI / 180.0f) 1279 1280 typedef struct _CompTransform { 1281 float m[16]; 1282 } CompTransform; 1283 1284 typedef union _CompVector { 1285 float v[4]; 1286 struct { 1287 float x; 1288 float y; 1289 float z; 1290 float w; 1291 }; 1292 } CompVector; 1293 1294 /* XXX: ScreenPaintAttrib will be removed */ 1295 typedef struct _ScreenPaintAttrib { 1296 GLfloat xRotate; 1297 GLfloat yRotate; 1298 GLfloat vRotate; 1299 GLfloat xTranslate; 1300 GLfloat yTranslate; 1301 GLfloat zTranslate; 1302 GLfloat zCamera; 1303 } ScreenPaintAttrib; 1304 1305 /* XXX: scale and translate fields will be removed */ 1306 typedef struct _WindowPaintAttrib { 1307 GLushort opacity; 1308 GLushort brightness; 1309 GLushort saturation; 1310 GLfloat xScale; 1311 GLfloat yScale; 1312 GLfloat xTranslate; 1313 GLfloat yTranslate; 1314 } WindowPaintAttrib; 1315 1316 extern ScreenPaintAttrib defaultScreenPaintAttrib; 1317 extern WindowPaintAttrib defaultWindowPaintAttrib; 1318 1319 typedef struct _CompMatrix { 1320 float xx; float yx; 1321 float xy; float yy; 1322 float x0; float y0; 1323 } CompMatrix; 1324 1325 #define COMP_TEX_COORD_X(m, vx) ((m)->xx * (vx) + (m)->x0) 1326 #define COMP_TEX_COORD_Y(m, vy) ((m)->yy * (vy) + (m)->y0) 1327 1328 #define COMP_TEX_COORD_XY(m, vx, vy) \ 1329 ((m)->xx * (vx) + (m)->xy * (vy) + (m)->x0) 1330 #define COMP_TEX_COORD_YX(m, vx, vy) \ 1331 ((m)->yx * (vx) + (m)->yy * (vy) + (m)->y0) 1332 1333 1334 typedef void (*PreparePaintScreenProc) (CompScreen *screen, 1335 int msSinceLastPaint); 1336 1337 typedef void (*DonePaintScreenProc) (CompScreen *screen); 1338 1339 #define PAINT_SCREEN_REGION_MASK (1 << 0) 1340 #define PAINT_SCREEN_FULL_MASK (1 << 1) 1341 #define PAINT_SCREEN_TRANSFORMED_MASK (1 << 2) 1342 #define PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS_MASK (1 << 3) 1343 #define PAINT_SCREEN_CLEAR_MASK (1 << 4) 1344 #define PAINT_SCREEN_NO_OCCLUSION_DETECTION_MASK (1 << 5) 1345 #define PAINT_SCREEN_NO_BACKGROUND_MASK (1 << 6) 1346 1347 typedef void (*PaintScreenProc) (CompScreen *screen, 1348 CompOutput *outputs, 1349 int numOutput, 1350 unsigned int mask); 1351 1352 typedef Bool (*PaintOutputProc) (CompScreen *screen, 1353 const ScreenPaintAttrib *sAttrib, 1354 const CompTransform *transform, 1355 Region region, 1356 CompOutput *output, 1357 unsigned int mask); 1358 1359 typedef void (*PaintTransformedOutputProc) (CompScreen *screen, 1360 const ScreenPaintAttrib *sAttrib, 1361 const CompTransform *transform, 1362 Region region, 1363 CompOutput *output, 1364 unsigned int mask); 1365 1366 /* XXX: ApplyScreenTransformProc will be removed */ 1367 typedef void (*ApplyScreenTransformProc) (CompScreen *screen, 1368 const ScreenPaintAttrib *sAttrib, 1369 CompOutput *output, 1370 CompTransform *transform); 1371 1372 typedef void (*EnableOutputClippingProc) (CompScreen *screen, 1373 const CompTransform *transform, 1374 Region region, 1375 CompOutput *output); 1376 1377 typedef void (*DisableOutputClippingProc) (CompScreen *screen); 1378 1379 typedef void (*WalkerFiniProc) (CompScreen *screen, 1380 CompWalker *walker); 1381 1382 typedef CompWindow *(*WalkInitProc) (CompScreen *screen); 1383 typedef CompWindow *(*WalkStepProc) (CompWindow *window); 1384 1385 struct _CompWalker { 1386 WalkerFiniProc fini; 1387 CompPrivate priv; 1388 1389 WalkInitProc first; 1390 WalkInitProc last; 1391 WalkStepProc next; 1392 WalkStepProc prev; 1393 }; 1394 1395 /* 1396 window paint flags 1397 1398 bit 1-16 are used for read-only flags and they provide 1399 information that describe the screen rendering pass 1400 currently in process. 1401 1402 bit 17-32 are writable flags and they provide information 1403 that is used to optimize rendering. 1404 */ 1405 1406 /* 1407 this flag is present when window is being painted 1408 on a transformed screen. 1409 */ 1410 #define PAINT_WINDOW_ON_TRANSFORMED_SCREEN_MASK (1 << 0) 1411 1412 /* 1413 this flag is present when window is being tested 1414 for occlusion of other windows. 1415 */ 1416 #define PAINT_WINDOW_OCCLUSION_DETECTION_MASK (1 << 1) 1417 1418 /* 1419 this flag indicates that the window ist painted with 1420 an offset 1421 */ 1422 #define PAINT_WINDOW_WITH_OFFSET_MASK (1 << 2) 1423 1424 /* 1425 flag indicate that window is translucent. 1426 */ 1427 #define PAINT_WINDOW_TRANSLUCENT_MASK (1 << 16) 1428 1429 /* 1430 flag indicate that window is transformed. 1431 */ 1432 #define PAINT_WINDOW_TRANSFORMED_MASK (1 << 17) 1433 1434 /* 1435 flag indicate that core PaintWindow function should 1436 not draw this window. 1437 */ 1438 #define PAINT_WINDOW_NO_CORE_INSTANCE_MASK (1 << 18) 1439 1440 /* 1441 flag indicate that blending is required. 1442 */ 1443 #define PAINT_WINDOW_BLEND_MASK (1 << 19) 1444 1445 1446 typedef Bool (*PaintWindowProc) (CompWindow *window, 1447 const WindowPaintAttrib *attrib, 1448 const CompTransform *transform, 1449 Region region, 1450 unsigned int mask); 1451 1452 typedef Bool (*DrawWindowProc) (CompWindow *window, 1453 const CompTransform *transform, 1454 const FragmentAttrib *fragment, 1455 Region region, 1456 unsigned int mask); 1457 1458 typedef void (*AddWindowGeometryProc) (CompWindow *window, 1459 CompMatrix *matrix, 1460 int nMatrix, 1461 Region region, 1462 Region clip); 1463 1464 typedef void (*DrawWindowTextureProc) (CompWindow *w, 1465 CompTexture *texture, 1466 const FragmentAttrib *fragment, 1467 unsigned int mask); 1468 1469 typedef void (*DrawWindowGeometryProc) (CompWindow *window); 1470 1471 typedef void (*PaintCursorProc) (CompCursor *cursor, 1472 const CompTransform *transform, 1473 Region region, 1474 unsigned int mask); 1475 1476 void 1477 preparePaintScreen (CompScreen *screen, 1478 int msSinceLastPaint); 1479 1480 void 1481 donePaintScreen (CompScreen *screen); 1482 1483 void 1484 transformToScreenSpace (CompScreen *screen, 1485 CompOutput *output, 1486 float z, 1487 CompTransform *transform); 1488 1489 /* XXX: prepareXCoords will be removed */ 1490 void 1491 prepareXCoords (CompScreen *screen, 1492 CompOutput *output, 1493 float z); 1494 1495 void 1496 paintTransformedOutput (CompScreen *screen, 1497 const ScreenPaintAttrib *sAttrib, 1498 const CompTransform *transform, 1499 Region region, 1500 CompOutput *output, 1501 unsigned int mask); 1502 1503 /* XXX: applyScreenTransform will be removed */ 1504 void 1505 applyScreenTransform (CompScreen *screen, 1506 const ScreenPaintAttrib *sAttrib, 1507 CompOutput *output, 1508 CompTransform *transform); 1509 1510 void 1511 enableOutputClipping (CompScreen *screen, 1512 const CompTransform *transform, 1513 Region region, 1514 CompOutput *output); 1515 1516 void 1517 disableOutputClipping (CompScreen *screen); 1518 1519 void 1520 paintScreen (CompScreen *screen, 1521 CompOutput *outputs, 1522 int numOutput, 1523 unsigned int mask); 1524 1525 Bool 1526 paintOutput (CompScreen *screen, 1527 const ScreenPaintAttrib *sAttrib, 1528 const CompTransform *transform, 1529 Region region, 1530 CompOutput *output, 1531 unsigned int mask); 1532 1533 Bool 1534 moreWindowVertices (CompWindow *w, 1535 int newSize); 1536 1537 Bool 1538 moreWindowIndices (CompWindow *w, 1539 int newSize); 1540 1541 void 1542 addWindowGeometry (CompWindow *w, 1543 CompMatrix *matrix, 1544 int nMatrix, 1545 Region region, 1546 Region clip); 1547 1548 void 1549 drawWindowTexture (CompWindow *w, 1550 CompTexture *texture, 1551 const FragmentAttrib *fragment, 1552 unsigned int mask); 1553 1554 Bool 1555 drawWindow (CompWindow *w, 1556 const CompTransform *transform, 1557 const FragmentAttrib *fragment, 1558 Region region, 1559 unsigned int mask); 1560 1561 Bool 1562 paintWindow (CompWindow *w, 1563 const WindowPaintAttrib *attrib, 1564 const CompTransform *transform, 1565 Region region, 1566 unsigned int mask); 1567 1568 void 1569 paintCursor (CompCursor *cursor, 1570 const CompTransform *transform, 1571 Region region, 1572 unsigned int mask); 1573 1574 /* texture.c */ 1575 1576 #define POWER_OF_TWO(v) ((v & (v - 1)) == 0) 1577 1578 typedef enum { 1579 COMP_TEXTURE_FILTER_FAST, 1580 COMP_TEXTURE_FILTER_GOOD 1581 } CompTextureFilter; 1582 1583 struct _CompTexture { 1584 GLuint name; 1585 GLenum target; 1586 GLfloat dx, dy; 1587 GLXPixmap pixmap; 1588 GLenum filter; 1589 GLenum wrap; 1590 CompMatrix matrix; 1591 Bool oldMipmaps; 1592 Bool mipmap; 1593 int refCount; 1594 }; 1595 1596 void 1597 initTexture (CompScreen *screen, 1598 CompTexture *texture); 1599 1600 void 1601 finiTexture (CompScreen *screen, 1602 CompTexture *texture); 1603 1604 CompTexture * 1605 createTexture (CompScreen *screen); 1606 1607 void 1608 destroyTexture (CompScreen *screen, 1609 CompTexture *texture); 1610 1611 Bool 1612 imageBufferToTexture (CompScreen *screen, 1613 CompTexture *texture, 1614 const char *image, 1615 unsigned int width, 1616 unsigned int height); 1617 1618 Bool 1619 imageDataToTexture (CompScreen *screen, 1620 CompTexture *texture, 1621 const char *image, 1622 unsigned int width, 1623 unsigned int height, 1624 GLenum format, 1625 GLenum type); 1626 1627 1628 Bool 1629 readImageToTexture (CompScreen *screen, 1630 CompTexture *texture, 1631 const char *imageFileName, 1632 unsigned int *width, 1633 unsigned int *height); 1634 1635 Bool 1636 iconToTexture (CompScreen *screen, 1637 CompIcon *icon); 1638 1639 Bool 1640 bindPixmapToTexture (CompScreen *screen, 1641 CompTexture *texture, 1642 Pixmap pixmap, 1643 int width, 1644 int height, 1645 int depth); 1646 1647 void 1648 releasePixmapFromTexture (CompScreen *screen, 1649 CompTexture *texture); 1650 1651 void 1652 enableTexture (CompScreen *screen, 1653 CompTexture *texture, 1654 CompTextureFilter filter); 1655 1656 void 1657 enableTextureClampToBorder (CompScreen *screen, 1658 CompTexture *texture, 1659 CompTextureFilter filter); 1660 1661 void 1662 enableTextureClampToEdge (CompScreen *screen, 1663 CompTexture *texture, 1664 CompTextureFilter filter); 1665 1666 void 1667 disableTexture (CompScreen *screen, 1668 CompTexture *texture); 1669 1670 1671 /* screen.c */ 1672 1673 #define COMP_SCREEN_OPTION_DETECT_REFRESH_RATE 0 1674 #define COMP_SCREEN_OPTION_LIGHTING 1 1675 #define COMP_SCREEN_OPTION_REFRESH_RATE 2 1676 #define COMP_SCREEN_OPTION_HSIZE 3 1677 #define COMP_SCREEN_OPTION_VSIZE 4 1678 #define COMP_SCREEN_OPTION_UNREDIRECT_FS 5 1679 #define COMP_SCREEN_OPTION_DEFAULT_ICON 6 1680 #define COMP_SCREEN_OPTION_SYNC_TO_VBLANK 7 1681 #define COMP_SCREEN_OPTION_NUMBER_OF_DESKTOPS 8 1682 #define COMP_SCREEN_OPTION_DETECT_OUTPUTS 9 1683 #define COMP_SCREEN_OPTION_OUTPUTS 10 1684 #define COMP_SCREEN_OPTION_OVERLAPPING_OUTPUTS 11 1685 #define COMP_SCREEN_OPTION_FOCUS_PREVENTION_LEVEL 12 1686 #define COMP_SCREEN_OPTION_FOCUS_PREVENTION_MATCH 13 1687 #define COMP_SCREEN_OPTION_TEXTURE_COMPRESSION 14 1688 #define COMP_SCREEN_OPTION_FORCE_INDEPENDENT 15 1689 #define COMP_SCREEN_OPTION_NUM 16 1690 1691 #ifndef GLX_EXT_texture_from_pixmap 1692 #define GLX_BIND_TO_TEXTURE_RGB_EXT 0x20D0 1693 #define GLX_BIND_TO_TEXTURE_RGBA_EXT 0x20D1 1694 #define GLX_BIND_TO_MIPMAP_TEXTURE_EXT 0x20D2 1695 #define GLX_BIND_TO_TEXTURE_TARGETS_EXT 0x20D3 1696 #define GLX_Y_INVERTED_EXT 0x20D4 1697 #define GLX_TEXTURE_FORMAT_EXT 0x20D5 1698 #define GLX_TEXTURE_TARGET_EXT 0x20D6 1699 #define GLX_MIPMAP_TEXTURE_EXT 0x20D7 1700 #define GLX_TEXTURE_FORMAT_NONE_EXT 0x20D8 1701 #define GLX_TEXTURE_FORMAT_RGB_EXT 0x20D9 1702 #define GLX_TEXTURE_FORMAT_RGBA_EXT 0x20DA 1703 #define GLX_TEXTURE_1D_BIT_EXT 0x00000001 1704 #define GLX_TEXTURE_2D_BIT_EXT 0x00000002 1705 #define GLX_TEXTURE_RECTANGLE_BIT_EXT 0x00000004 1706 #define GLX_TEXTURE_1D_EXT 0x20DB 1707 #define GLX_TEXTURE_2D_EXT 0x20DC 1708 #define GLX_TEXTURE_RECTANGLE_EXT 0x20DD 1709 #define GLX_FRONT_LEFT_EXT 0x20DE 1710 #endif 1711 1712 #define OUTPUT_OVERLAP_MODE_SMART 0 1713 #define OUTPUT_OVERLAP_MODE_PREFER_LARGER 1 1714 #define OUTPUT_OVERLAP_MODE_PREFER_SMALLER 2 1715 #define OUTPUT_OVERLAP_MODE_LAST OUTPUT_OVERLAP_MODE_PREFER_SMALLER 1716 1717 #define FOCUS_PREVENTION_LEVEL_NONE 0 1718 #define FOCUS_PREVENTION_LEVEL_LOW 1 1719 #define FOCUS_PREVENTION_LEVEL_NORMAL 2 1720 #define FOCUS_PREVENTION_LEVEL_HIGH 3 1721 #define FOCUS_PREVENTION_LEVEL_VERYHIGH 4 1722 #define FOCUS_PREVENTION_LEVEL_LAST FOCUS_PREVENTION_LEVEL_VERYHIGH 1723 1724 typedef void (*FuncPtr) (void); 1725 typedef FuncPtr (*GLXGetProcAddressProc) (const GLubyte *procName); 1726 1727 typedef void (*GLXBindTexImageProc) (Display *display, 1728 GLXDrawable drawable, 1729 int buffer, 1730 int *attribList); 1731 typedef void (*GLXReleaseTexImageProc) (Display *display, 1732 GLXDrawable drawable, 1733 int buffer); 1734 typedef void (*GLXQueryDrawableProc) (Display *display, 1735 GLXDrawable drawable, 1736 int attribute, 1737 unsigned int *value); 1738 1739 typedef void (*GLXCopySubBufferProc) (Display *display, 1740 GLXDrawable drawable, 1741 int x, 1742 int y, 1743 int width, 1744 int height); 1745 1746 typedef int (*GLXGetVideoSyncProc) (unsigned int *count); 1747 typedef int (*GLXWaitVideoSyncProc) (int divisor, 1748 int remainder, 1749 unsigned int *count); 1750 1751 #ifndef GLX_VERSION_1_3 1752 typedef struct __GLXFBConfigRec *GLXFBConfig; 1753 #endif 1754 1755 typedef GLXFBConfig *(*GLXGetFBConfigsProc) (Display *display, 1756 int screen, 1757 int *nElements); 1758 typedef int (*GLXGetFBConfigAttribProc) (Display *display, 1759 GLXFBConfig config, 1760 int attribute, 1761 int *value); 1762 typedef GLXPixmap (*GLXCreatePixmapProc) (Display *display, 1763 GLXFBConfig config, 1764 Pixmap pixmap, 1765 const int *attribList); 1766 typedef void (*GLXDestroyPixmapProc) (Display *display, 1767 GLXPixmap pixmap); 1768 1769 typedef void (*GLActiveTextureProc) (GLenum texture); 1770 typedef void (*GLClientActiveTextureProc) (GLenum texture); 1771 typedef void (*GLMultiTexCoord2fProc) (GLenum, GLfloat, GLfloat); 1772 1773 typedef void (*GLGenProgramsProc) (GLsizei n, 1774 GLuint *programs); 1775 typedef void (*GLDeleteProgramsProc) (GLsizei n, 1776 GLuint *programs); 1777 typedef void (*GLBindProgramProc) (GLenum target, 1778 GLuint program); 1779 typedef void (*GLProgramStringProc) (GLenum target, 1780 GLenum format, 1781 GLsizei len, 1782 const GLvoid *string); 1783 typedef void (*GLProgramParameter4fProc) (GLenum target, 1784 GLuint index, 1785 GLfloat x, 1786 GLfloat y, 1787 GLfloat z, 1788 GLfloat w); 1789 typedef void (*GLGetProgramivProc) (GLenum target, 1790 GLenum pname, 1791 int *params); 1792 1793 typedef void (*GLGenFramebuffersProc) (GLsizei n, 1794 GLuint *framebuffers); 1795 typedef void (*GLDeleteFramebuffersProc) (GLsizei n, 1796 GLuint *framebuffers); 1797 typedef void (*GLBindFramebufferProc) (GLenum target, 1798 GLuint framebuffer); 1799 typedef GLenum (*GLCheckFramebufferStatusProc) (GLenum target); 1800 typedef void (*GLFramebufferTexture2DProc) (GLenum target, 1801 GLenum attachment, 1802 GLenum textarget, 1803 GLuint texture, 1804 GLint level); 1805 typedef void (*GLGenerateMipmapProc) (GLenum target); 1806 1807 #define MAX_DEPTH 32 1808 1809 typedef void (*EnterShowDesktopModeProc) (CompScreen *screen); 1810 1811 typedef void (*LeaveShowDesktopModeProc) (CompScreen *screen, 1812 CompWindow *window); 1813 1814 typedef Bool (*DamageWindowRectProc) (CompWindow *w, 1815 Bool initial, 1816 BoxPtr rect); 1817 1818 typedef Bool (*DamageWindowRegionProc) (CompWindow *w, 1819 Region region); 1820 1821 typedef Bool (*DamageCursorRectProc) (CompCursor *c, 1822 Bool initial, 1823 BoxPtr rect); 1824 1825 1826 typedef void (*GetOutputExtentsForWindowProc) (CompWindow *w, 1827 CompWindowExtents *output); 1828 1829 typedef void (*GetAllowedActionsForWindowProc) (CompWindow *w, 1830 unsigned int *setActions, 1831 unsigned int *clearActions); 1832 1833 typedef Bool (*FocusWindowProc) (CompWindow *window); 1834 1835 typedef void (*ActivateWindowProc) (CompWindow *window); 1836 1837 typedef Bool (*PlaceWindowProc) (CompWindow *window, 1838 int x, 1839 int y, 1840 int *newX, 1841 int *newY); 1842 1843 typedef void (*ValidateWindowResizeRequestProc) (CompWindow *window, 1844 unsigned int *mask, 1845 XWindowChanges *xwc, 1846 unsigned int source); 1847 1848 typedef void (*WindowResizeNotifyProc) (CompWindow *window, 1849 int dx, 1850 int dy, 1851 int dwidth, 1852 int dheight); 1853 1854 typedef void (*WindowMoveNotifyProc) (CompWindow *window, 1855 int dx, 1856 int dy, 1857 Bool immediate); 1858 1859 #define CompWindowGrabKeyMask (1 << 0) 1860 #define CompWindowGrabButtonMask (1 << 1) 1861 #define CompWindowGrabMoveMask (1 << 2) 1862 #define CompWindowGrabResizeMask (1 << 3) 1863 #define CompWindowGrabExternalAppMask (1 << 4) 1864 1865 typedef void (*WindowGrabNotifyProc) (CompWindow *window, 1866 int x, 1867 int y, 1868 unsigned int state, 1869 unsigned int mask); 1870 1871 typedef void (*WindowUngrabNotifyProc) (CompWindow *window); 1872 1873 typedef void (*WindowStateChangeNotifyProc) (CompWindow *window, 1874 unsigned int lastState); 1875 1876 typedef void (*OutputChangeNotifyProc) (CompScreen *screen); 1877 1878 typedef unsigned int (*AddSupportedAtomsProc) (CompScreen *s, 1879 Atom *atoms, 1880 unsigned int size); 1881 1882 typedef void (*InitWindowWalkerProc) (CompScreen *screen, 1883 CompWalker *walker); 1884 1885 #define COMP_SCREEN_DAMAGE_PENDING_MASK (1 << 0) 1886 #define COMP_SCREEN_DAMAGE_REGION_MASK (1 << 1) 1887 #define COMP_SCREEN_DAMAGE_ALL_MASK (1 << 2) 1888 1889 typedef struct _CompKeyGrab { 1890 int keycode; 1891 unsigned int modifiers; 1892 int count; 1893 } CompKeyGrab; 1894 1895 typedef struct _CompButtonGrab { 1896 int button; 1897 unsigned int modifiers; 1898 int count; 1899 } CompButtonGrab; 1900 1901 typedef struct _CompGrab { 1902 Bool active; 1903 Cursor cursor; 1904 const char *name; 1905 } CompGrab; 1906 1907 typedef struct _CompGroup { 1908 struct _CompGroup *next; 1909 unsigned int refCnt; 1910 Window id; 1911 } CompGroup; 1912 1913 typedef struct _CompStartupSequence { 1914 struct _CompStartupSequence *next; 1915 SnStartupSequence *sequence; 1916 unsigned int viewportX; 1917 unsigned int viewportY; 1918 } CompStartupSequence; 1919 1920 typedef struct _CompFBConfig { 1921 GLXFBConfig fbConfig; 1922 int yInverted; 1923 int mipmap; 1924 int textureFormat; 1925 int textureTargets; 1926 } CompFBConfig; 1927 1928 #define NOTHING_TRANS_FILTER 0 1929 #define SCREEN_TRANS_FILTER 1 1930 #define WINDOW_TRANS_FILTER 2 1931 1932 #define SCREEN_EDGE_LEFT 0 1933 #define SCREEN_EDGE_RIGHT 1 1934 #define SCREEN_EDGE_TOP 2 1935 #define SCREEN_EDGE_BOTTOM 3 1936 #define SCREEN_EDGE_TOPLEFT 4 1937 #define SCREEN_EDGE_TOPRIGHT 5 1938 #define SCREEN_EDGE_BOTTOMLEFT 6 1939 #define SCREEN_EDGE_BOTTOMRIGHT 7 1940 #define SCREEN_EDGE_NUM 8 1941 1942 typedef struct _CompScreenEdge { 1943 Window id; 1944 unsigned int count; 1945 } CompScreenEdge; 1946 1947 struct _CompIcon { 1948 CompTexture texture; 1949 int width; 1950 int height; 1951 }; 1952 1953 struct _CompOutput { 1954 char *name; 1955 int id; 1956 REGION region; 1957 int width; 1958 int height; 1959 XRectangle workArea; 1960 }; 1961 1962 typedef struct _CompCursorImage { 1963 struct _CompCursorImage *next; 1964 1965 unsigned long serial; 1966 Pixmap pixmap; 1967 CompTexture texture; 1968 int xhot; 1969 int yhot; 1970 int width; 1971 int height; 1972 } CompCursorImage; 1973 1974 struct _CompCursor { 1975 struct _CompCursor *next; 1976 1977 CompScreen *screen; 1978 CompCursorImage *image; 1979 1980 int x; 1981 int y; 1982 1983 CompMatrix matrix; 1984 }; 1985 1986 #define ACTIVE_WINDOW_HISTORY_SIZE 64 1987 #define ACTIVE_WINDOW_HISTORY_NUM 32 1988 1989 typedef struct _CompActiveWindowHistory { 1990 Window id[ACTIVE_WINDOW_HISTORY_SIZE]; 1991 int x; 1992 int y; 1993 int activeNum; 1994 } CompActiveWindowHistory; 1995 1996 struct _CompScreen { 1997 CompObject base; 1998 1999 CompScreen *next; 2000 CompDisplay *display; 2001 CompWindow *windows; 2002 CompWindow *reverseWindows; 2003 2004 char *windowPrivateIndices; 2005 int windowPrivateLen; 2006 2007 Colormap colormap; 2008 int screenNum; 2009 int width; 2010 int height; 2011 int x; 2012 int y; 2013 int hsize; /* Number of horizontal viewports */ 2014 int vsize; /* Number of vertical viewports */ 2015 unsigned int nDesktop; 2016 unsigned int currentDesktop; 2017 REGION region; 2018 Region damage; 2019 unsigned long damageMask; 2020 Window root; 2021 Window overlay; 2022 Window output; 2023 XWindowAttributes attrib; 2024 Window grabWindow; 2025 CompFBConfig glxPixmapFBConfigs[MAX_DEPTH + 1]; 2026 int textureRectangle; 2027 int textureNonPowerOfTwo; 2028 int textureEnvCombine; 2029 int textureEnvCrossbar; 2030 int textureBorderClamp; 2031 int textureCompression; 2032 GLint maxTextureSize; 2033 int fbo; 2034 int fragmentProgram; 2035 int maxTextureUnits; 2036 Cursor invisibleCursor; 2037 XRectangle *exposeRects; 2038 int sizeExpose; 2039 int nExpose; 2040 CompTexture backgroundTexture; 2041 Bool backgroundLoaded; 2042 unsigned int pendingDestroys; 2043 int desktopWindowCount; 2044 unsigned int mapNum; 2045 unsigned int activeNum; 2046 2047 CompOutput *outputDev; 2048 int nOutputDev; 2049 int currentOutputDev; 2050 CompOutput fullscreenOutput; 2051 Bool hasOverlappingOutputs; 2052 2053 int windowOffsetX; 2054 int windowOffsetY; 2055 2056 XRectangle lastViewport; 2057 2058 CompActiveWindowHistory history[ACTIVE_WINDOW_HISTORY_NUM]; 2059 int currentHistory; 2060 2061 int overlayWindowCount; 2062 2063 CompScreenEdge screenEdge[SCREEN_EDGE_NUM]; 2064 2065 SnMonitorContext *snContext; 2066 CompStartupSequence *startupSequences; 2067 unsigned int startupSequenceTimeoutHandle; 2068 2069 int filter[3]; 2070 2071 CompGroup *groups; 2072 2073 CompIcon *defaultIcon; 2074 2075 Bool canDoSaturated; 2076 Bool canDoSlightlySaturated; 2077 2078 Window wmSnSelectionWindow; 2079 Atom wmSnAtom; 2080 Time wmSnTimestamp; 2081 2082 Cursor normalCursor; 2083 Cursor busyCursor; 2084 2085 CompWindow **clientList; 2086 int nClientList; 2087 2088 CompButtonGrab *buttonGrab; 2089 int nButtonGrab; 2090 CompKeyGrab *keyGrab; 2091 int nKeyGrab; 2092 2093 CompGrab *grabs; 2094 int grabSize; 2095 int maxGrab; 2096 2097 int rasterX; 2098 int rasterY; 2099 struct timeval lastRedraw; 2100 int nextRedraw; 2101 int redrawTime; 2102 int optimalRedrawTime; 2103 int frameStatus; 2104 int timeMult; 2105 Bool idle; 2106 int timeLeft; 2107 Bool pendingCommands; 2108 2109 int lastFunctionId; 2110 2111 CompFunction *fragmentFunctions; 2112 CompProgram *fragmentPrograms; 2113 2114 int saturateFunction[2][64]; 2115 2116 GLfloat projection[16]; 2117 2118 Bool clearBuffers; 2119 2120 Bool lighting; 2121 Bool slowAnimations; 2122 2123 XRectangle workArea; 2124 2125 unsigned int showingDesktopMask; 2126 2127 unsigned long *desktopHintData; 2128 int desktopHintSize; 2129 2130 CompCursor *cursors; 2131 CompCursorImage *cursorImages; 2132 2133 GLXGetProcAddressProc getProcAddress; 2134 GLXBindTexImageProc bindTexImage; 2135 GLXReleaseTexImageProc releaseTexImage; 2136 GLXQueryDrawableProc queryDrawable; 2137 GLXCopySubBufferProc copySubBuffer; 2138 GLXGetVideoSyncProc getVideoSync; 2139 GLXWaitVideoSyncProc waitVideoSync; 2140 GLXGetFBConfigsProc getFBConfigs; 2141 GLXGetFBConfigAttribProc getFBConfigAttrib; 2142 GLXCreatePixmapProc createPixmap; 2143 GLXDestroyPixmapProc destroyPixmap; 2144 2145 GLActiveTextureProc activeTexture; 2146 GLClientActiveTextureProc clientActiveTexture; 2147 GLMultiTexCoord2fProc multiTexCoord2f; 2148 2149 GLGenProgramsProc genPrograms; 2150 GLDeleteProgramsProc deletePrograms; 2151 GLBindProgramProc bindProgram; 2152 GLProgramStringProc programString; 2153 GLProgramParameter4fProc programEnvParameter4f; 2154 GLProgramParameter4fProc programLocalParameter4f; 2155 GLGetProgramivProc getProgramiv; 2156 2157 GLGenFramebuffersProc genFramebuffers; 2158 GLDeleteFramebuffersProc deleteFramebuffers; 2159 GLBindFramebufferProc bindFramebuffer; 2160 GLCheckFramebufferStatusProc checkFramebufferStatus; 2161 GLFramebufferTexture2DProc framebufferTexture2D; 2162 GLGenerateMipmapProc generateMipmap; 2163 2164 GLXContext ctx; 2165 2166 CompOption opt[COMP_SCREEN_OPTION_NUM]; 2167 2168 PreparePaintScreenProc preparePaintScreen; 2169 DonePaintScreenProc donePaintScreen; 2170 PaintScreenProc paintScreen; 2171 PaintOutputProc paintOutput; 2172 PaintTransformedOutputProc paintTransformedOutput; 2173 EnableOutputClippingProc enableOutputClipping; 2174 DisableOutputClippingProc disableOutputClipping; 2175 ApplyScreenTransformProc applyScreenTransform; 2176 PaintWindowProc paintWindow; 2177 DrawWindowProc drawWindow; 2178 AddWindowGeometryProc addWindowGeometry; 2179 DrawWindowTextureProc drawWindowTexture; 2180 DamageWindowRectProc damageWindowRect; 2181 GetOutputExtentsForWindowProc getOutputExtentsForWindow; 2182 GetAllowedActionsForWindowProc getAllowedActionsForWindow; 2183 FocusWindowProc focusWindow; 2184 ActivateWindowProc activateWindow; 2185 PlaceWindowProc placeWindow; 2186 ValidateWindowResizeRequestProc validateWindowResizeRequest; 2187 2188 PaintCursorProc paintCursor; 2189 DamageCursorRectProc damageCursorRect; 2190 2191 WindowResizeNotifyProc windowResizeNotify; 2192 WindowMoveNotifyProc windowMoveNotify; 2193 WindowGrabNotifyProc windowGrabNotify; 2194 WindowUngrabNotifyProc windowUngrabNotify; 2195 2196 EnterShowDesktopModeProc enterShowDesktopMode; 2197 LeaveShowDesktopModeProc leaveShowDesktopMode; 2198 2199 WindowStateChangeNotifyProc windowStateChangeNotify; 2200 2201 OutputChangeNotifyProc outputChangeNotify; 2202 AddSupportedAtomsProc addSupportedAtoms; 2203 2204 InitWindowWalkerProc initWindowWalker; 2205 2206 void *reserved; 2207 }; 2208 2209 #define GET_CORE_SCREEN(object) ((CompScreen *) (object)) 2210 #define CORE_SCREEN(object) CompScreen *s = GET_CORE_SCREEN (object) 2211 2212 CompBool 2213 allocScreenObjectPrivates (CompObject *object, 2214 CompObject *parent); 2215 2216 int 2217 allocScreenObjectPrivateIndex (CompObject *parent); 2218 2219 void 2220 freeScreenObjectPrivateIndex (CompObject *parent, 2221 int index); 2222 2223 CompBool 2224 forEachScreenObject (CompObject *parent, 2225 ObjectCallBackProc proc, 2226 void *closure); 2227 2228 char * 2229 nameScreenObject (CompObject *object); 2230 2231 CompObject * 2232 findScreenObject (CompObject *parent, 2233 const char *name); 2234 2235 int 2236 allocateScreenPrivateIndex (CompDisplay *display); 2237 2238 void 2239 freeScreenPrivateIndex (CompDisplay *display, 2240 int index); 2241 2242 CompOption * 2243 getScreenOptions (CompPlugin *plugin, 2244 CompScreen *screen, 2245 int *count); 2246 2247 Bool 2248 setScreenOption (CompPlugin *plugin, 2249 CompScreen *screen, 2250 const char *name, 2251 CompOptionValue *value); 2252 2253 void 2254 configureScreen (CompScreen *s, 2255 XConfigureEvent *ce); 2256 2257 void 2258 setCurrentOutput (CompScreen *s, 2259 int outputNum); 2260 2261 void 2262 setSupportedWmHints (CompScreen *s); 2263 2264 void 2265 updateScreenBackground (CompScreen *screen, 2266 CompTexture *texture); 2267 2268 void 2269 detectRefreshRateOfScreen (CompScreen *s); 2270 2271 void 2272 showOutputWindow (CompScreen *s); 2273 2274 void 2275 hideOutputWindow (CompScreen *s); 2276 2277 void 2278 updateOutputWindow (CompScreen *s); 2279 2280 Bool 2281 addScreen (CompDisplay *display, 2282 int screenNum, 2283 Window wmSnSelectionWindow, 2284 Atom wmSnAtom, 2285 Time wmSnTimestamp); 2286 2287 void 2288 removeScreen (CompScreen *s); 2289 2290 void 2291 damageScreenRegion (CompScreen *screen, 2292 Region region); 2293 2294 void 2295 damageScreen (CompScreen *screen); 2296 2297 void 2298 damagePendingOnScreen (CompScreen *s); 2299 2300 void 2301 insertWindowIntoScreen (CompScreen *s, 2302 CompWindow *w, 2303 Window aboveId); 2304 2305 void 2306 unhookWindowFromScreen (CompScreen *s, 2307 CompWindow *w); 2308 2309 void 2310 forEachWindowOnScreen (CompScreen *screen, 2311 ForEachWindowProc proc, 2312 void *closure); 2313 2314 CompWindow * 2315 findWindowAtScreen (CompScreen *s, 2316 Window id); 2317 2318 CompWindow * 2319 findTopLevelWindowAtScreen (CompScreen *s, 2320 Window id); 2321 2322 void 2323 focusDefaultWindow (CompScreen *s); 2324 2325 int 2326 pushScreenGrab (CompScreen *s, 2327 Cursor cursor, 2328 const char *name); 2329 2330 void 2331 updateScreenGrab (CompScreen *s, 2332 int index, 2333 Cursor cursor); 2334 2335 void 2336 removeScreenGrab (CompScreen *s, 2337 int index, 2338 XPoint *restorePointer); 2339 2340 Bool 2341 otherScreenGrabExist (CompScreen *s, ...); 2342 2343 Bool 2344 addScreenAction (CompScreen *s, 2345 CompAction *action); 2346 2347 void 2348 removeScreenAction (CompScreen *s, 2349 CompAction *action); 2350 2351 void 2352 updatePassiveGrabs (CompScreen *s); 2353 2354 void 2355 updateWorkareaForScreen (CompScreen *s); 2356 2357 void 2358 updateClientListForScreen (CompScreen *s); 2359 2360 Window 2361 getActiveWindow (CompDisplay *display, 2362 Window root); 2363 2364 void 2365 toolkitAction (CompScreen *s, 2366 Atom toolkitAction, 2367 Time eventTime, 2368 Window window, 2369 long data0, 2370 long data1, 2371 long data2); 2372 2373 void 2374 runCommand (CompScreen *s, 2375 const char *command); 2376 2377 void 2378 moveScreenViewport (CompScreen *s, 2379 int tx, 2380 int ty, 2381 Bool sync); 2382 2383 void 2384 moveWindowToViewportPosition (CompWindow *w, 2385 int x, 2386 int y, 2387 Bool sync); 2388 2389 CompGroup * 2390 addGroupToScreen (CompScreen *s, 2391 Window id); 2392 void 2393 removeGroupFromScreen (CompScreen *s, 2394 CompGroup *group); 2395 2396 CompGroup * 2397 findGroupAtScreen (CompScreen *s, 2398 Window id); 2399 2400 void 2401 applyStartupProperties (CompScreen *screen, 2402 CompWindow *window); 2403 2404 void 2405 sendWindowActivationRequest (CompScreen *s, 2406 Window id); 2407 2408 void 2409 screenTexEnvMode (CompScreen *s, 2410 GLenum mode); 2411 2412 void 2413 screenLighting (CompScreen *s, 2414 Bool lighting); 2415 2416 void 2417 enableScreenEdge (CompScreen *s, 2418 int edge); 2419 2420 void 2421 disableScreenEdge (CompScreen *s, 2422 int edge); 2423 2424 Window 2425 getTopWindow (CompScreen *s); 2426 2427 void 2428 makeScreenCurrent (CompScreen *s); 2429 2430 void 2431 finishScreenDrawing (CompScreen *s); 2432 2433 int 2434 outputDeviceForPoint (CompScreen *s, 2435 int x, 2436 int y); 2437 2438 void 2439 getCurrentOutputExtents (CompScreen *s, 2440 int *x1, 2441 int *y1, 2442 int *x2, 2443 int *y2); 2444 2445 void 2446 getWorkareaForOutput (CompScreen *s, 2447 int output, 2448 XRectangle *area); 2449 2450 void 2451 setNumberOfDesktops (CompScreen *s, 2452 unsigned int nDesktop); 2453 2454 void 2455 setCurrentDesktop (CompScreen *s, 2456 unsigned int desktop); 2457 2458 void 2459 setDefaultViewport (CompScreen *s); 2460 2461 void 2462 outputChangeNotify (CompScreen *s); 2463 2464 void 2465 clearScreenOutput (CompScreen *s, 2466 CompOutput *output, 2467 unsigned int mask); 2468 2469 void 2470 viewportForGeometry (CompScreen *s, 2471 int x, 2472 int y, 2473 int width, 2474 int height, 2475 int borderWidth, 2476 int *viewportX, 2477 int *viewportY); 2478 2479 int 2480 outputDeviceForGeometry (CompScreen *s, 2481 int x, 2482 int y, 2483 int width, 2484 int height, 2485 int borderWidth); 2486 2487 Bool 2488 updateDefaultIcon (CompScreen *screen); 2489 2490 CompCursor * 2491 findCursorAtScreen (CompScreen *screen); 2492 2493 CompCursorImage * 2494 findCursorImageAtScreen (CompScreen *screen, 2495 unsigned long serial); 2496 2497 void 2498 setCurrentActiveWindowHistory (CompScreen *s, 2499 int x, 2500 int y); 2501 2502 void 2503 addToCurrentActiveWindowHistory (CompScreen *s, 2504 Window id); 2505 2506 void 2507 setWindowPaintOffset (CompScreen *s, 2508 int x, 2509 int y); 2510 2511 2512 /* window.c */ 2513 2514 #define WINDOW_INVISIBLE(w) \ 2515 ((w)->attrib.map_state != IsViewable || \ 2516 (!(w)->damaged) || \ 2517 (w)->attrib.x + (w)->width + (w)->output.right <= 0 || \ 2518 (w)->attrib.y + (w)->height + (w)->output.bottom <= 0 || \ 2519 (w)->attrib.x - (w)->output.left >= (w)->screen->width || \ 2520 (w)->attrib.y - (w)->output.top >= (w)->screen->height) 2521 2522 typedef enum { 2523 CompStackingUpdateModeNone = 0, 2524 CompStackingUpdateModeNormal, 2525 CompStackingUpdateModeAboveFullscreen, 2526 CompStackingUpdateModeInitialMap, 2527 CompStackingUpdateModeInitialMapDeniedFocus 2528 } CompStackingUpdateMode; 2529 2530 typedef enum { 2531 CompFocusAllowed = 0, 2532 CompFocusPrevent, 2533 CompFocusDenied 2534 } CompFocusResult; 2535 2536 struct _CompWindowExtents { 2537 int left; 2538 int right; 2539 int top; 2540 int bottom; 2541 }; 2542 2543 typedef struct _CompStruts { 2544 XRectangle left; 2545 XRectangle right; 2546 XRectangle top; 2547 XRectangle bottom; 2548 } CompStruts; 2549 2550 struct _CompWindow { 2551 CompObject base; 2552 2553 CompScreen *screen; 2554 CompWindow *next; 2555 CompWindow *prev; 2556 2557 int refcnt; 2558 Window id; 2559 Window frame; 2560 unsigned int mapNum; 2561 unsigned int activeNum; 2562 XWindowAttributes attrib; 2563 int serverX; 2564 int serverY; 2565 int serverWidth; 2566 int serverHeight; 2567 int serverBorderWidth; 2568 Window transientFor; 2569 Window clientLeader; 2570 XWMHints *hints; 2571 XSizeHints sizeHints; 2572 Pixmap pixmap; 2573 CompTexture *texture; 2574 CompMatrix matrix; 2575 Damage damage; 2576 Bool inputHint; 2577 Bool alpha; 2578 GLint width; 2579 GLint height; 2580 Region region; 2581 Region clip; 2582 unsigned int wmType; 2583 unsigned int type; 2584 unsigned int state; 2585 unsigned int actions; 2586 unsigned int protocols; 2587 unsigned int mwmDecor; 2588 unsigned int mwmFunc; 2589 Bool invisible; 2590 Bool destroyed; 2591 Bool damaged; 2592 Bool redirected; 2593 Bool managed; 2594 Bool unmanaging; 2595 Bool bindFailed; 2596 Bool overlayWindow; 2597 int destroyRefCnt; 2598 int unmapRefCnt; 2599 2600 unsigned int initialViewportX; 2601 unsigned int initialViewportY; 2602 2603 Time initialTimestamp; 2604 Bool initialTimestampSet; 2605 2606 Bool placed; 2607 Bool minimized; 2608 Bool inShowDesktopMode; 2609 Bool shaded; 2610 Bool hidden; 2611 Bool grabbed; 2612 2613 unsigned int desktop; 2614 2615 int pendingUnmaps; 2616 int pendingMaps; 2617 2618 char *startupId; 2619 char *resName; 2620 char *resClass; 2621 2622 CompGroup *group; 2623 2624 unsigned int lastPong; 2625 Bool alive; 2626 2627 WindowPaintAttrib paint; 2628 WindowPaintAttrib lastPaint; 2629 2630 unsigned int lastMask; 2631 2632 CompWindowExtents input; 2633 CompWindowExtents output; 2634 2635 CompStruts *struts; 2636 2637 CompIcon **icon; 2638 int nIcon; 2639 2640 XRectangle iconGeometry; 2641 Bool iconGeometrySet; 2642 2643 XRectangle fullscreenMonitorRect; 2644 Bool fullscreenMonitorsSet; 2645 2646 XWindowChanges saveWc; 2647 int saveMask; 2648 2649 XSyncCounter syncCounter; 2650 XSyncValue syncValue; 2651 XSyncAlarm syncAlarm; 2652 unsigned long syncAlarmConnection; 2653 unsigned int syncWaitHandle; 2654 2655 Bool syncWait; 2656 int syncX; 2657 int syncY; 2658 int syncWidth; 2659 int syncHeight; 2660 int syncBorderWidth; 2661 2662 Bool closeRequests; 2663 Time lastCloseRequestTime; 2664 2665 XRectangle *damageRects; 2666 int sizeDamage; 2667 int nDamage; 2668 2669 GLfloat *vertices; 2670 int vertexSize; 2671 int vertexStride; 2672 GLushort *indices; 2673 int indexSize; 2674 int vCount; 2675 int texUnits; 2676 int texCoordSize; 2677 int indexCount; 2678 2679 /* must be set by addWindowGeometry */ 2680 DrawWindowGeometryProc drawWindowGeometry; 2681 2682 void *reserved; 2683 }; 2684 2685 #define GET_CORE_WINDOW(object) ((CompWindow *) (object)) 2686 #define CORE_WINDOW(object) CompWindow *w = GET_CORE_WINDOW (object) 2687 2688 CompBool 2689 allocWindowObjectPrivates (CompObject *object, 2690 CompObject *parent); 2691 2692 int 2693 allocWindowObjectPrivateIndex (CompObject *parent); 2694 2695 void 2696 freeWindowObjectPrivateIndex (CompObject *parent, 2697 int index); 2698 2699 CompBool 2700 forEachWindowObject (CompObject *parent, 2701 ObjectCallBackProc proc, 2702 void *closure); 2703 2704 char * 2705 nameWindowObject (CompObject *object); 2706 2707 CompObject * 2708 findWindowObject (CompObject *parent, 2709 const char *name); 2710 2711 int 2712 allocateWindowPrivateIndex (CompScreen *screen); 2713 2714 void 2715 freeWindowPrivateIndex (CompScreen *screen, 2716 int index); 2717 2718 unsigned int 2719 windowStateMask (CompDisplay *display, 2720 Atom state); 2721 2722 unsigned int 2723 windowStateFromString (const char *str); 2724 2725 unsigned int 2726 getWindowState (CompDisplay *display, 2727 Window id); 2728 2729 void 2730 setWindowState (CompDisplay *display, 2731 unsigned int state, 2732 Window id); 2733 2734 void 2735 changeWindowState (CompWindow *w, 2736 unsigned int newState); 2737 2738 void 2739 recalcWindowActions (CompWindow *w); 2740 2741 unsigned int 2742 constrainWindowState (unsigned int state, 2743 unsigned int actions); 2744 2745 unsigned int 2746 windowTypeFromString (const char *str); 2747 2748 unsigned int 2749 getWindowType (CompDisplay *display, 2750 Window id); 2751 2752 void 2753 recalcWindowType (CompWindow *w); 2754 2755 void 2756 getMwmHints (CompDisplay *display, 2757 Window id, 2758 unsigned int *func, 2759 unsigned int *decor); 2760 2761 unsigned int 2762 getProtocols (CompDisplay *display, 2763 Window id); 2764 2765 unsigned int 2766 getWindowProp (CompDisplay *display, 2767 Window id, 2768 Atom property, 2769 unsigned int defaultValue); 2770 2771 void 2772 setWindowProp (CompDisplay *display, 2773 Window id, 2774 Atom property, 2775 unsigned int value); 2776 2777 Bool 2778 readWindowProp32 (CompDisplay *display, 2779 Window id, 2780 Atom property, 2781 unsigned short *returnValue); 2782 2783 unsigned short 2784 getWindowProp32 (CompDisplay *display, 2785 Window id, 2786 Atom property, 2787 unsigned short defaultValue); 2788 2789 void 2790 setWindowProp32 (CompDisplay *display, 2791 Window id, 2792 Atom property, 2793 unsigned short value); 2794 2795 void 2796 updateNormalHints (CompWindow *window); 2797 2798 void 2799 updateWmHints (CompWindow *w); 2800 2801 void 2802 updateWindowClassHints (CompWindow *window); 2803 2804 void 2805 updateTransientHint (CompWindow *w); 2806 2807 void 2808 updateIconGeometry (CompWindow *w); 2809 2810 Window 2811 getClientLeader (CompWindow *w); 2812 2813 char * 2814 getStartupId (CompWindow *w); 2815 2816 int 2817 getWmState (CompDisplay *display, 2818 Window id); 2819 2820 void 2821 setWmState (CompDisplay *display, 2822 int state, 2823 Window id); 2824 2825 void 2826 setWindowFullscreenMonitors (CompWindow *w, 2827 CompFullscreenMonitorSet *monitors); 2828 2829 void 2830 setWindowFrameExtents (CompWindow *w, 2831 CompWindowExtents *input); 2832 2833 void 2834 updateWindowOutputExtents (CompWindow *w); 2835 2836 void 2837 updateWindowRegion (CompWindow *w); 2838 2839 Bool 2840 updateWindowStruts (CompWindow *w); 2841 2842 void 2843 addWindow (CompScreen *screen, 2844 Window id, 2845 Window aboveId); 2846 2847 void 2848 removeWindow (CompWindow *w); 2849 2850 void 2851 destroyWindow (CompWindow *w); 2852 2853 void 2854 sendConfigureNotify (CompWindow *w); 2855 2856 void 2857 mapWindow (CompWindow *w); 2858 2859 void 2860 unmapWindow (CompWindow *w); 2861 2862 Bool 2863 bindWindow (CompWindow *w); 2864 2865 void 2866 releaseWindow (CompWindow *w); 2867 2868 void 2869 moveWindow (CompWindow *w, 2870 int dx, 2871 int dy, 2872 Bool damage, 2873 Bool immediate); 2874 2875 void 2876 configureXWindow (CompWindow *w, 2877 unsigned int valueMask, 2878 XWindowChanges *xwc); 2879 2880 unsigned int 2881 adjustConfigureRequestForGravity (CompWindow *w, 2882 XWindowChanges *xwc, 2883 unsigned int xwcm, 2884 int gravity, 2885 int direction); 2886 2887 void 2888 moveResizeWindow (CompWindow *w, 2889 XWindowChanges *xwc, 2890 unsigned int xwcm, 2891 int gravity, 2892 unsigned int source); 2893 2894 void 2895 syncWindowPosition (CompWindow *w); 2896 2897 void 2898 sendSyncRequest (CompWindow *w); 2899 2900 Bool 2901 resizeWindow (CompWindow *w, 2902 int x, 2903 int y, 2904 int width, 2905 int height, 2906 int borderWidth); 2907 2908 void 2909 configureWindow (CompWindow *w, 2910 XConfigureEvent *ce); 2911 2912 void 2913 circulateWindow (CompWindow *w, 2914 XCirculateEvent *ce); 2915 2916 void 2917 addWindowDamageRect (CompWindow *w, 2918 BoxPtr rect); 2919 2920 void 2921 getOutputExtentsForWindow (CompWindow *w, 2922 CompWindowExtents *output); 2923 2924 void 2925 getAllowedActionsForWindow (CompWindow *w, 2926 unsigned int *setActions, 2927 unsigned int *clearActions); 2928 2929 void 2930 addWindowDamage (CompWindow *w); 2931 2932 void 2933 damageWindowOutputExtents (CompWindow *w); 2934 2935 Bool 2936 damageWindowRect (CompWindow *w, 2937 Bool initial, 2938 BoxPtr rect); 2939 2940 void 2941 damageTransformedWindowRect (CompWindow *w, 2942 float xScale, 2943 float yScale, 2944 float xTranslate, 2945 float yTranslate, 2946 BoxPtr rect); 2947 2948 Bool 2949 focusWindow (CompWindow *w); 2950 2951 Bool 2952 placeWindow (CompWindow *w, 2953 int x, 2954 int y, 2955 int *newX, 2956 int *newY); 2957 2958 void 2959 validateWindowResizeRequest (CompWindow *w, 2960 unsigned int *mask, 2961 XWindowChanges *xwc, 2962 unsigned int source); 2963 2964 void 2965 windowResizeNotify (CompWindow *w, 2966 int dx, 2967 int dy, 2968 int dwidth, 2969 int dheight); 2970 2971 void 2972 windowMoveNotify (CompWindow *w, 2973 int dx, 2974 int dy, 2975 Bool immediate); 2976 2977 void 2978 windowGrabNotify (CompWindow *w, 2979 int x, 2980 int y, 2981 unsigned int state, 2982 unsigned int mask); 2983 2984 void 2985 windowUngrabNotify (CompWindow *w); 2986 2987 void 2988 windowStateChangeNotify (CompWindow *w, 2989 unsigned int lastState); 2990 2991 void 2992 moveInputFocusToWindow (CompWindow *w); 2993 2994 void 2995 updateWindowSize (CompWindow *w); 2996 2997 void 2998 raiseWindow (CompWindow *w); 2999 3000 void 3001 lowerWindow (CompWindow *w); 3002 3003 void 3004 restackWindowAbove (CompWindow *w, 3005 CompWindow *sibling); 3006 3007 void 3008 restackWindowBelow (CompWindow *w, 3009 CompWindow *sibling); 3010 3011 void 3012 updateWindowAttributes (CompWindow *w, 3013 CompStackingUpdateMode stackingMode); 3014 3015 void 3016 activateWindow (CompWindow *w); 3017 3018 void 3019 closeWindow (CompWindow *w, 3020 Time serverTime); 3021 3022 Bool 3023 constrainNewWindowSize (CompWindow *w, 3024 int width, 3025 int height, 3026 int *newWidth, 3027 int *newHeight); 3028 3029 void 3030 hideWindow (CompWindow *w); 3031 3032 void 3033 showWindow (CompWindow *w); 3034 3035 void 3036 minimizeWindow (CompWindow *w); 3037 3038 void 3039 unminimizeWindow (CompWindow *w); 3040 3041 void 3042 maximizeWindow (CompWindow *w, 3043 int state); 3044 3045 Bool 3046 getWindowUserTime (CompWindow *w, 3047 Time *time); 3048 3049 void 3050 setWindowUserTime (CompWindow *w, 3051 Time time); 3052 3053 CompFocusResult 3054 allowWindowFocus (CompWindow *w, 3055 unsigned int noFocusMask, 3056 unsigned int viewportX, 3057 unsigned int viewportY, 3058 Time timestamp); 3059 3060 void 3061 unredirectWindow (CompWindow *w); 3062 3063 void 3064 redirectWindow (CompWindow *w); 3065 3066 void 3067 defaultViewportForWindow (CompWindow *w, 3068 int *vx, 3069 int *vy); 3070 3071 CompIcon * 3072 getWindowIcon (CompWindow *w, 3073 int width, 3074 int height); 3075 3076 void 3077 freeWindowIcons (CompWindow *w); 3078 3079 int 3080 outputDeviceForWindow (CompWindow *w); 3081 3082 Bool 3083 onCurrentDesktop (CompWindow *w); 3084 3085 void 3086 setDesktopForWindow (CompWindow *w, 3087 unsigned int desktop); 3088 3089 int 3090 compareWindowActiveness (CompWindow *w1, 3091 CompWindow *w2); 3092 3093 Bool 3094 windowOnAllViewports (CompWindow *w); 3095 3096 void 3097 getWindowMovementForOffset (CompWindow *w, 3098 int offX, 3099 int offY, 3100 int *retX, 3101 int *retY); 3102 3103 /* plugin.c */ 3104 3105 #define HOME_PLUGINDIR ".compiz/plugins" 3106 3107 typedef CompPluginVTable *(*PluginGetInfoProc) (void); 3108 3109 typedef Bool (*LoadPluginProc) (CompPlugin *p, 3110 const char *path, 3111 const char *name); 3112 3113 typedef void (*UnloadPluginProc) (CompPlugin *p); 3114 3115 typedef char **(*ListPluginsProc) (const char *path, 3116 int *n); 3117 3118 extern LoadPluginProc loaderLoadPlugin; 3119 extern UnloadPluginProc loaderUnloadPlugin; 3120 extern ListPluginsProc loaderListPlugins; 3121 3122 struct _CompPlugin { 3123 CompPlugin *next; 3124 CompPrivate devPrivate; 3125 char *devType; 3126 CompPluginVTable *vTable; 3127 }; 3128 3129 CompBool 3130 objectInitPlugins (CompObject *o); 3131 3132 void 3133 objectFiniPlugins (CompObject *o); 3134 3135 CompPlugin * 3136 findActivePlugin (const char *name); 3137 3138 CompPlugin * 3139 loadPlugin (const char *plugin); 3140 3141 void 3142 unloadPlugin (CompPlugin *p); 3143 3144 Bool 3145 pushPlugin (CompPlugin *p); 3146 3147 CompPlugin * 3148 popPlugin (void); 3149 3150 CompPlugin * 3151 getPlugins (void); 3152 3153 char ** 3154 availablePlugins (int *n); 3155 3156 int 3157 getPluginABI (const char *name); 3158 3159 Bool 3160 checkPluginABI (const char *name, 3161 int abi); 3162 3163 Bool 3164 getPluginDisplayIndex (CompDisplay *d, 3165 const char *name, 3166 int *index); 3167 3168 3169 /* fragment.c */ 3170 3171 #define MAX_FRAGMENT_FUNCTIONS 16 3172 3173 struct _FragmentAttrib { 3174 GLushort opacity; 3175 GLushort brightness; 3176 GLushort saturation; 3177 int nTexture; 3178 int function[MAX_FRAGMENT_FUNCTIONS]; 3179 int nFunction; 3180 int nParam; 3181 }; 3182 3183 CompFunctionData * 3184 createFunctionData (void); 3185 3186 void 3187 destroyFunctionData (CompFunctionData *data); 3188 3189 Bool 3190 addTempHeaderOpToFunctionData (CompFunctionData *data, 3191 const char *name); 3192 3193 Bool 3194 addParamHeaderOpToFunctionData (CompFunctionData *data, 3195 const char *name); 3196 3197 Bool 3198 addAttribHeaderOpToFunctionData (CompFunctionData *data, 3199 const char *name); 3200 3201 #define COMP_FETCH_TARGET_2D 0 3202 #define COMP_FETCH_TARGET_RECT 1 3203 #define COMP_FETCH_TARGET_NUM 2 3204 3205 Bool 3206 addFetchOpToFunctionData (CompFunctionData *data, 3207 const char *dst, 3208 const char *offset, 3209 int target); 3210 3211 Bool 3212 addColorOpToFunctionData (CompFunctionData *data, 3213 const char *dst, 3214 const char *src); 3215 3216 Bool 3217 addDataOpToFunctionData (CompFunctionData *data, 3218 const char *str, 3219 ...); 3220 3221 Bool 3222 addBlendOpToFunctionData (CompFunctionData *data, 3223 const char *str, 3224 ...); 3225 3226 int 3227 createFragmentFunction (CompScreen *s, 3228 const char *name, 3229 CompFunctionData *data); 3230 3231 void 3232 destroyFragmentFunction (CompScreen *s, 3233 int id); 3234 3235 int 3236 getSaturateFragmentFunction (CompScreen *s, 3237 CompTexture *texture, 3238 int param); 3239 3240 int 3241 allocFragmentTextureUnits (FragmentAttrib *attrib, 3242 int nTexture); 3243 3244 int 3245 allocFragmentParameters (FragmentAttrib *attrib, 3246 int nParam); 3247 3248 void 3249 addFragmentFunction (FragmentAttrib *attrib, 3250 int function); 3251 3252 void 3253 initFragmentAttrib (FragmentAttrib *attrib, 3254 const WindowPaintAttrib *paint); 3255 3256 Bool 3257 enableFragmentAttrib (CompScreen *s, 3258 FragmentAttrib *attrib, 3259 Bool *blending); 3260 3261 void 3262 disableFragmentAttrib (CompScreen *s, 3263 FragmentAttrib *attrib); 3264 3265 3266 /* matrix.c */ 3267 3268 void 3269 matrixMultiply (CompTransform *product, 3270 const CompTransform *transformA, 3271 const CompTransform *transformB); 3272 3273 void 3274 matrixMultiplyVector (CompVector *product, 3275 const CompVector *vector, 3276 const CompTransform *transform); 3277 3278 void 3279 matrixVectorDiv (CompVector *v); 3280 3281 void 3282 matrixRotate (CompTransform *transform, 3283 float angle, 3284 float x, 3285 float y, 3286 float z); 3287 3288 void 3289 matrixScale (CompTransform *transform, 3290 float x, 3291 float y, 3292 float z); 3293 3294 void 3295 matrixTranslate (CompTransform *transform, 3296 float x, 3297 float y, 3298 float z); 3299 3300 void 3301 matrixGetIdentity (CompTransform *m); 3302 3303 /* cursor.c */ 3304 3305 void 3306 addCursor (CompScreen *s); 3307 3308 Bool 3309 damageCursorRect (CompCursor *c, 3310 Bool initial, 3311 BoxPtr rect); 3312 3313 void 3314 addCursorDamageRect (CompCursor *c, 3315 BoxPtr rect); 3316 3317 void 3318 addCursorDamage (CompCursor *c); 3319 3320 void 3321 updateCursor (CompCursor *c, 3322 int x, 3323 int y, 3324 unsigned long serial); 3325 3326 3327 /* match.c */ 3328 3329 void 3330 matchInit (CompMatch *match); 3331 3332 void 3333 matchFini (CompMatch *match); 3334 3335 Bool 3336 matchEqual (CompMatch *m1, 3337 CompMatch *m2); 3338 3339 Bool 3340 matchCopy (CompMatch *dst, 3341 CompMatch *src); 3342 3343 Bool 3344 matchAddGroup (CompMatch *match, 3345 int flags, 3346 CompMatch *group); 3347 3348 Bool 3349 matchAddExp (CompMatch *match, 3350 int flags, 3351 const char *value); 3352 3353 void 3354 matchAddFromString (CompMatch *match, 3355 const char *str); 3356 3357 char * 3358 matchToString (CompMatch *match); 3359 3360 void 3361 matchUpdate (CompDisplay *display, 3362 CompMatch *match); 3363 3364 Bool 3365 matchEval (CompMatch *match, 3366 CompWindow *window); 3367 3368 void 3369 matchInitExp (CompDisplay *display, 3370 CompMatchExp *exp, 3371 const char *value); 3372 3373 void 3374 matchExpHandlerChanged (CompDisplay *display); 3375 3376 void 3377 matchPropertyChanged (CompDisplay *display, 3378 CompWindow *window); 3379 3380 3381 /* metadata.c */ 3382 3383 #define STRINGIFY(x) #x 3384 #define TOSTRING(x) STRINGIFY (x) 3385 #define MINTOSTRING(x) "<min>" TOSTRING (x) "</min>" 3386 #define MAXTOSTRING(x) "<max>" TOSTRING (x) "</max>" 3387 #define RESTOSTRING(min, max) MINTOSTRING (min) MAXTOSTRING (max) 3388 3389 typedef struct _CompMetadataOptionInfo { 3390 char *name; 3391 char *type; 3392 char *data; 3393 CompActionCallBackProc initiate; 3394 CompActionCallBackProc terminate; 3395 } CompMetadataOptionInfo; 3396 3397 extern const CompMetadataOptionInfo 3398 coreDisplayOptionInfo[COMP_DISPLAY_OPTION_NUM]; 3399 extern const CompMetadataOptionInfo 3400 coreScreenOptionInfo[COMP_SCREEN_OPTION_NUM]; 3401 3402 struct _CompMetadata { 3403 char *path; 3404 xmlDoc **doc; 3405 int nDoc; 3406 }; 3407 3408 Bool 3409 compInitPluginMetadataFromInfo (CompMetadata *metadata, 3410 const char *plugin, 3411 const CompMetadataOptionInfo *displayOptionInfo, 3412 int nDisplayOptionInfo, 3413 const CompMetadataOptionInfo *screenOptionInfo, 3414 int nScreenOptionInfo); 3415 3416 Bool 3417 compInitScreenOptionFromMetadata (CompScreen *screen, 3418 CompMetadata *metadata, 3419 CompOption *option, 3420 const char *name); 3421 3422 void 3423 compFiniScreenOption (CompScreen *screen, 3424 CompOption *option); 3425 3426 Bool 3427 compInitScreenOptionsFromMetadata (CompScreen *screen, 3428 CompMetadata *metadata, 3429 const CompMetadataOptionInfo *info, 3430 CompOption *option, 3431 int n); 3432 3433 void 3434 compFiniScreenOptions (CompScreen *screen, 3435 CompOption *option, 3436 int n); 3437 3438 Bool 3439 compSetScreenOption (CompScreen *screen, 3440 CompOption *option, 3441 CompOptionValue *value); 3442 3443 Bool 3444 compInitDisplayOptionFromMetadata (CompDisplay *display, 3445 CompMetadata *metadata, 3446 CompOption *option, 3447 const char *name); 3448 3449 void 3450 compFiniDisplayOption (CompDisplay *display, 3451 CompOption *option); 3452 3453 Bool 3454 compInitDisplayOptionsFromMetadata (CompDisplay *display, 3455 CompMetadata *metadata, 3456 const CompMetadataOptionInfo *info, 3457 CompOption *option, 3458 int n); 3459 3460 void 3461 compFiniDisplayOptions (CompDisplay *display, 3462 CompOption *option, 3463 int n); 3464 3465 Bool 3466 compSetDisplayOption (CompDisplay *display, 3467 CompOption *option, 3468 CompOptionValue *value); 3469 3470 char * 3471 compGetShortPluginDescription (CompMetadata *metadata); 3472 3473 char * 3474 compGetLongPluginDescription (CompMetadata *metadata); 3475 3476 char * 3477 compGetShortScreenOptionDescription (CompMetadata *metadata, 3478 CompOption *option); 3479 3480 char * 3481 compGetLongScreenOptionDescription (CompMetadata *metadata, 3482 CompOption *option); 3483 3484 char * 3485 compGetShortDisplayOptionDescription (CompMetadata *metadata, 3486 CompOption *option); 3487 3488 char * 3489 compGetLongDisplayOptionDescription (CompMetadata *metadata, 3490 CompOption *option); 3491 3492 int 3493 compReadXmlChunkFromMetadataOptionInfo (const CompMetadataOptionInfo *info, 3494 int *offset, 3495 char *buffer, 3496 int length); 3497 3498 3499 COMPIZ_END_DECLS 3500 3501 #endif 3502