xhelpers.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /*
  2. Copyright (C) 2014 by Leonhard Oelke <[email protected]>
  3. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation, either version 2 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. */
  14. #pragma once
  15. #ifdef __cplusplus
  16. extern "C" {
  17. #endif
  18. #include <X11/Xlib.h>
  19. #include <X11/extensions/XShm.h>
  20. #include <obs.h>
  21. typedef struct {
  22. XShmSegmentInfo info;
  23. XImage *image;
  24. Display *dpy;
  25. bool attached;
  26. } xshm_t;
  27. /**
  28. * Check for Xinerama extension
  29. *
  30. * @return > 0 if Xinerama is available and active
  31. */
  32. int_fast32_t xinerama_is_active(Display *dpy);
  33. /**
  34. * Get the number of Xinerama screens
  35. *
  36. * @return number of screens
  37. */
  38. int_fast32_t xinerama_screen_count(Display *dpy);
  39. /**
  40. * Get screen geometry for a Xinerama screen
  41. *
  42. * @note On error the passed coordinates/sizes will be set to 0.
  43. *
  44. * @param dpy X11 display
  45. * @param screen screen number to get geometry for
  46. * @param x x-coordinate of the screen
  47. * @param y y-coordinate of the screen
  48. * @param w width of the screen
  49. * @param h height of the screen
  50. *
  51. * @return < 0 on error
  52. */
  53. int_fast32_t xinerama_screen_geo(Display *dpy, const int_fast32_t screen,
  54. int_fast32_t *x, int_fast32_t *y, int_fast32_t *w, int_fast32_t *h);
  55. /**
  56. * Get screen geometry for a X11 screen
  57. *
  58. * @note On error the passed sizes will be set to 0.
  59. *
  60. * @param dpy X11 display
  61. * @param screen screen number to get geometry for
  62. * @param w width of the screen
  63. * @param h height of the screen
  64. *
  65. * @return < 0 on error
  66. */
  67. int_fast32_t x11_screen_geo(Display *dpy, const int_fast32_t screen,
  68. int_fast32_t *w, int_fast32_t *h);
  69. /**
  70. * Attach a shared memory segment to the X-Server
  71. *
  72. * @param dpy X11 Display
  73. * @param screen X11 Screen
  74. * @param w width for the shared memory segment
  75. * @param h height for the shared memory segment
  76. *
  77. * @return NULL on error
  78. */
  79. xshm_t *xshm_attach(Display *dpy, Screen *screen,
  80. int_fast32_t w, int_fast32_t h);
  81. /**
  82. * Detach a shared memory segment
  83. */
  84. void xshm_detach(xshm_t *xshm);
  85. #ifdef __cplusplus
  86. }
  87. #endif