Advertisement
Guest User

Untitled

a guest
Jun 3rd, 2017
531
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.55 KB | None | 0 0
  1. /*
  2. * Compiz Fusion Toggle-decoration plugin
  3. *
  4. * Copyright (c) 2008 Marco Diego Aurélio Mesquita <marcodiegomesquita@gmail.com>
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License
  8. * as published by the Free Software Foundation; either version 2
  9. * of the License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * Author(s):
  17. * Eduardo Gurgel Pinho <edgurgel@gmail.com>
  18. * Marco Diego Mesquita <marcodiegomesquita@gmail.com>
  19. *
  20. * Description:
  21. *
  22. * Toggles decorations of windows on/off.
  23. *
  24. */
  25.  
  26. #include "toggledeco.h"
  27.  
  28. /*
  29. * Initially triggered keybinding.
  30. * Fetch the window and toggles its decoration.
  31. */
  32. static Bool
  33. toggledecoTrigger(CompDisplay *d,
  34. CompAction *action,
  35. CompActionState state,
  36. CompOption *option,
  37. int nOption)
  38. {
  39. Window xid;
  40. CompWindow *w;
  41.  
  42. xid = getIntOptionNamed (option, nOption, "window", 0);
  43. w = findWindowAtDisplay (d, xid);
  44. if (w)
  45. {
  46. w->mwmDecor = w->mwmDecor ^ MwmDecorAll;
  47. (*w->screen->windowStateChangeNotify) (w, w->state);
  48. }
  49.  
  50. return TRUE;
  51. }
  52.  
  53. /*
  54. * Testing if two windows are on the same viewport
  55. */
  56.  
  57. bool
  58. ToggledecoScreen::sameViewport(CompWindow* w1,
  59. CompWindow* w2)
  60. {
  61. int x1,x2,y1,y2;
  62.  
  63. defaultViewportForWindow (w1,&x1,&y1);
  64. defaultViewportForWindow (w2,&x2,&y2);
  65. return ((x1 == x2) && (y1 == y2));
  66. }
  67.  
  68. /*
  69. * Initially triggered keybinding.
  70. * Fetch the every window and toggles its decoration.
  71. */
  72. bool
  73. ToggleDecoScreen::allTrigger (CompAction *action,
  74. CompAction::State state,
  75. CompOption::Vector &option)
  76. {
  77. CompWindow *cw = screen->findWindow (screen->activeWindow ());
  78. if (cw)
  79. {
  80. // CompScreen *s = w->screen;
  81. // CompWindow *window;
  82. CompWindowList windows = screen->windows ();
  83.  
  84. foreach (CompWindow *w, windows)
  85. {
  86. MwmHints mwmhints;
  87. Atom prop = Atoms::mwmHints;
  88.  
  89. memset(&mwmhints, 0, sizeof(mwmhints));
  90.  
  91. mwmhints.flags = MWM_HINTS_DECORATIONS;
  92. mwmhints.decorations = 0;
  93. if(!sameViewport (w, cw))
  94. continue;
  95.  
  96. XChangeProperty(screen->dpyt (), window, prop, prop, 32, PropModeReplace,
  97. (unsigned char *) &mwmhints,
  98. PROP_MWM_HINTS_ELEMENTS);
  99. // (*window->screen->windowStateChangeNotify) (window, window->state); core should pick this up automatically
  100. }
  101. }
  102.  
  103. return TRUE;
  104. }
  105.  
  106. ToggleDecoScreen::ToggleDecoScreen (CompScreen *screen) :
  107. PluginClassHandler <ToggleDecoScreen, CompScreen> (screen),
  108. screen (screen),
  109. cScreen (CompositeScreen::get (screen)),
  110. gScreen (GLScreen::get (screen))
  111. {
  112. ScreenInterface::setHandler (screen);
  113. CompositeScreenInterface::setHandler (cScreen);
  114. GLScreenInterface::setHandler (gScreen);
  115. }
  116.  
  117. bool
  118. ToggleDecoPluginVTable::init ()
  119. {
  120. if (!CompPlugin::checkPluginABI ("core", CORE_ABIVERSION))
  121. return false;
  122. if (!CompPlugin::checkPluginABI ("composite", COMPIZ_COMPOSITE_ABI))
  123. return false;
  124. if (!CompPlugin::checkPluginABI ("opengl", COMPIZ_OPENGL_ABI))
  125. return false;
  126.  
  127. return true;
  128. }
  129.  
  130. /* Configuration, initialization, boring stuff. ---------------------
  131. static Bool
  132. toggledecoInitDisplay (CompPlugin *p,
  133. CompDisplay *d)
  134. {
  135. if (!checkPluginABI ("core", CORE_ABIVERSION))
  136. return FALSE;
  137.  
  138. toggledecoSetTriggerKeyInitiate (d, toggledecoTrigger);
  139. toggledecoSetTriggerAllKeyInitiate (d, toggledecoAllTrigger);
  140.  
  141. return TRUE;
  142. }
  143.  
  144. static CompBool
  145. toggledecoInitObject (CompPlugin *p,
  146. CompObject *o)
  147. {
  148. static InitPluginObjectProc dispTab[] = {
  149. (InitPluginObjectProc) 0, // InitCore //
  150. (InitPluginObjectProc) toggledecoInitDisplay,
  151. 0,
  152. 0
  153. };
  154.  
  155. RETURN_DISPATCH (o, dispTab, ARRAY_SIZE (dispTab), TRUE, (p, o));
  156. }
  157.  
  158. static void
  159. toggledecoFiniObject (CompPlugin *p,
  160. CompObject *o)
  161. {
  162. static FiniPluginObjectProc dispTab[] = {
  163. (FiniPluginObjectProc) 0, // FiniCore //
  164. 0,
  165. 0,
  166. 0
  167. };
  168.  
  169. DISPATCH (o, dispTab, ARRAY_SIZE (dispTab), (p, o));
  170. }
  171.  
  172. CompPluginVTable toggledecoVTable = {
  173. "toggledeco",
  174. 0,
  175. 0,
  176. 0,
  177. toggledecoInitObject,
  178. toggledecoFiniObject,
  179. 0,
  180. 0
  181. };
  182.  
  183. CompPluginVTable*
  184. getCompPluginInfo (void)
  185. {
  186. return &toggledecoVTable;
  187. }
  188. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement