glselectrectangle.hpp 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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 "framebuffer.hpp"
  26. #include <unistd.h>
  27. #include <Imlib2.h>
  28. #include <GL/gl.h>
  29. #include <GL/glx.h>
  30. #include <GL/glew.h>
  31. #include <GL/glxext.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. void setShader( std::string name );
  56. float m_r;
  57. float m_g;
  58. float m_b;
  59. float m_a;
  60. GLXFBConfig m_fbconfig;
  61. XVisualInfo* m_visual;
  62. XRenderPictFormat* m_pictFormat;
  63. GLXContext m_renderContext;
  64. GLXWindow m_glxWindow;
  65. Colormap m_cmap;
  66. bool m_themed;
  67. unsigned int m_texid;
  68. unsigned int m_cornerids[4];
  69. unsigned int m_straightid;
  70. int m_straightwidth;
  71. int m_straightheight;
  72. int m_offsetx;
  73. int m_offsety;
  74. int m_offsetw;
  75. int m_offseth;
  76. unsigned int m_desktop;
  77. unsigned int m_glassPixels;
  78. float m_glassSize;
  79. int m_glassBorder;
  80. float m_realglassx;
  81. float m_realglassy;
  82. int m_glassx;
  83. int m_glassy;
  84. bool m_glassEnabled;
  85. double m_time;
  86. std::string m_shader;
  87. std::vector<XRRCrtcInfo*> m_monitors;
  88. slop::Framebuffer* m_framebuffer;
  89. private:
  90. unsigned int loadImage( unsigned int* texture, std::string path );
  91. };
  92. }
  93. #endif // IS_GL_SELECT_RECTANGLE_H_