glselectrectangle.hpp 3.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /* glselectrectangle.hpp: Handles creating hardware accelerated rectangles on the screen using X11 and OpenGL.
  2. *
  3. * Copyright (C) 2014: Dalton Nell, Slop Contributors (https://github.com/naelstrof/slop/graphs/contributors).
  4. *
  5. * This file is part of Slop.
  6. *
  7. * Slop is free software: you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation, either version 3 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * Slop is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with Slop. If not, see <http://www.gnu.org/licenses/>.
  19. */
  20. #ifndef IS_GL_SELECT_RECTANGLE_H_
  21. #define IS_GL_SELECT_RECTANGLE_H_
  22. #include "x.hpp"
  23. #include "selectrectangle.hpp"
  24. #include "resource.hpp"
  25. #include <unistd.h>
  26. #include <GL/gl.h>
  27. #include <GL/glx.h>
  28. #include <GL/glxext.h>
  29. #define ILUT_USE_OPENGL
  30. #include <IL/il.h>
  31. #include <IL/ilut.h>
  32. #include <X11/Xlib.h>
  33. #include <X11/Xatom.h>
  34. #include <X11/extensions/Xrender.h>
  35. #include <X11/Xutil.h>
  36. #include <cstdlib>
  37. #include <cmath>
  38. #include <cstdio>
  39. #include <string>
  40. #include <vector>
  41. namespace slop {
  42. class GLSelectRectangle: public SelectRectangle {
  43. public:
  44. GLSelectRectangle( int sx, int sy, int ex, int ey, int border, bool highlight, float r, float g, float b, float a );
  45. ~GLSelectRectangle();
  46. void setGeo( int x, int y, int w, int h );
  47. void update( double dt );
  48. void generateMagnifyingGlass();
  49. void setMagnifySettings( bool on, float magstrength, unsigned int pixels );
  50. void pushIn( int* x, int* y, int w, int h, int rx, int ry, int rw, int rh );
  51. void pushOut( int* x, int* y, int w, int h, int rx, int ry, int rw, int rh );
  52. void findOptimalGlassPosition();
  53. void constrainWithinMonitor( int* x, int* y, int* w, int* h );
  54. void setTheme( bool on, std::string name );
  55. float m_r;
  56. float m_g;
  57. float m_b;
  58. float m_a;
  59. GLXFBConfig m_fbconfig;
  60. XVisualInfo* m_visual;
  61. XRenderPictFormat* m_pictFormat;
  62. GLXContext m_renderContext;
  63. GLXWindow m_glxWindow;
  64. Colormap m_cmap;
  65. bool m_themed;
  66. unsigned int m_texid;
  67. unsigned int m_cornerids[4];
  68. unsigned int m_straightid;
  69. unsigned int m_straightwidth;
  70. unsigned int m_straightheight;
  71. int m_offsetx;
  72. int m_offsety;
  73. int m_offsetw;
  74. int m_offseth;
  75. unsigned int m_glassPixels;
  76. float m_glassSize;
  77. int m_glassBorder;
  78. float m_realglassx;
  79. float m_realglassy;
  80. int m_glassx;
  81. int m_glassy;
  82. bool m_glassEnabled;
  83. std::vector<XRRCrtcInfo*> m_monitors;
  84. };
  85. }
  86. #endif // IS_GL_SELECT_RECTANGLE_H_