You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

fltk-1.3.x-screen_num.patch 4.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. diff -up fltk-1.3.0r9619/FL/Fl.H.screen_num fltk-1.3.0r9619/FL/Fl.H
  2. --- fltk-1.3.0r9619/FL/Fl.H.screen_num 2012-07-03 13:49:28.663085580 +0200
  3. +++ fltk-1.3.0r9619/FL/Fl.H 2012-07-03 13:49:28.731084402 +0200
  4. @@ -806,6 +806,8 @@ public:
  5. static void screen_xywh(int &X, int &Y, int &W, int &H, int mx, int my);
  6. static void screen_xywh(int &X, int &Y, int &W, int &H, int n);
  7. static void screen_xywh(int &X, int &Y, int &W, int &H, int mx, int my, int mw, int mh);
  8. + static int screen_num(int x, int y);
  9. + static int screen_num(int x, int y, int w, int h);
  10. static void screen_dpi(float &h, float &v, int n=0);
  11. static void screen_work_area(int &X, int &Y, int &W, int &H, int mx, int my);
  12. static void screen_work_area(int &X, int &Y, int &W, int &H, int n);
  13. diff -up fltk-1.3.0r9619/src/screen_xywh.cxx.screen_num fltk-1.3.0r9619/src/screen_xywh.cxx
  14. --- fltk-1.3.0r9619/src/screen_xywh.cxx.screen_num 2012-03-23 17:47:53.000000000 +0100
  15. +++ fltk-1.3.0r9619/src/screen_xywh.cxx 2012-07-03 13:58:01.947195396 +0200
  16. @@ -215,21 +215,6 @@ int Fl::screen_count() {
  17. return num_screens ? num_screens : 1;
  18. }
  19. -static int find_screen_with_point(int mx, int my) {
  20. - int screen = 0;
  21. - if (num_screens < 0) screen_init();
  22. -
  23. - for (int i = 0; i < num_screens; i ++) {
  24. - int sx, sy, sw, sh;
  25. - Fl::screen_xywh(sx, sy, sw, sh, i);
  26. - if ((mx >= sx) && (mx < (sx+sw)) && (my >= sy) && (my < (sy+sh))) {
  27. - screen = i;
  28. - break;
  29. - }
  30. - }
  31. - return screen;
  32. -}
  33. -
  34. /**
  35. Gets the bounding box of a screen
  36. that contains the specified screen position \p mx, \p my
  37. @@ -237,7 +222,7 @@ static int find_screen_with_point(int mx
  38. \param[in] mx, my the absolute screen position
  39. */
  40. void Fl::screen_xywh(int &X, int &Y, int &W, int &H, int mx, int my) {
  41. - screen_xywh(X, Y, W, H, find_screen_with_point(mx, my));
  42. + screen_xywh(X, Y, W, H, screen_num(mx, my));
  43. }
  44. @@ -248,7 +233,7 @@ void Fl::screen_xywh(int &X, int &Y, int
  45. \param[in] mx, my the absolute screen position
  46. */
  47. void Fl::screen_work_area(int &X, int &Y, int &W, int &H, int mx, int my) {
  48. - screen_work_area(X, Y, W, H, find_screen_with_point(mx, my));
  49. + screen_work_area(X, Y, W, H, screen_num(mx, my));
  50. }
  51. /**
  52. @@ -321,6 +306,38 @@ void Fl::screen_xywh(int &X, int &Y, int
  53. #endif // WIN32
  54. }
  55. +/**
  56. + Gets the screen bounding rect for the screen
  57. + which intersects the most with the rectangle
  58. + defined by \p mx, \p my, \p mw, \p mh.
  59. + \param[out] X,Y,W,H the corresponding screen bounding box
  60. + \param[in] mx, my, mw, mh the rectangle to search for intersection with
  61. + \see void screen_xywh(int &X, int &Y, int &W, int &H, int n)
  62. + */
  63. +void Fl::screen_xywh(int &X, int &Y, int &W, int &H, int mx, int my, int mw, int mh) {
  64. + screen_xywh(X, Y, W, H, screen_num(mx, my, mw, mh));
  65. +}
  66. +
  67. +/**
  68. + Gets the screen number of a screen
  69. + that contains the specified screen position \p x, \p y
  70. + \param[in] x, y the absolute screen position
  71. +*/
  72. +int Fl::screen_num(int x, int y) {
  73. + int screen = 0;
  74. + if (num_screens < 0) screen_init();
  75. +
  76. + for (int i = 0; i < num_screens; i ++) {
  77. + int sx, sy, sw, sh;
  78. + Fl::screen_xywh(sx, sy, sw, sh, i);
  79. + if ((x >= sx) && (x < (sx+sw)) && (y >= sy) && (y < (sy+sh))) {
  80. + screen = i;
  81. + break;
  82. + }
  83. + }
  84. + return screen;
  85. +}
  86. +
  87. static inline float fl_intersection(int x1, int y1, int w1, int h1,
  88. int x2, int y2, int w2, int h2) {
  89. if(x1+w1 < x2 || x2+w2 < x1 || y1+h1 < y2 || y2+h2 < y1)
  90. @@ -333,30 +350,27 @@ static inline float fl_intersection(int
  91. }
  92. /**
  93. - Gets the screen bounding rect for the screen
  94. + Gets the screen number for the screen
  95. which intersects the most with the rectangle
  96. - defined by \p mx, \p my, \p mw, \p mh.
  97. - \param[out] X,Y,W,H the corresponding screen bounding box
  98. - \param[in] mx, my, mw, mh the rectangle to search for intersection with
  99. - \see void screen_xywh(int &X, int &Y, int &W, int &H, int n)
  100. + defined by \p x, \p y, \p w, \p h.
  101. + \param[in] x, y, w, h the rectangle to search for intersection with
  102. */
  103. -void Fl::screen_xywh(int &X, int &Y, int &W, int &H, int mx, int my, int mw, int mh) {
  104. +int Fl::screen_num(int x, int y, int w, int h) {
  105. int best_screen = 0;
  106. float best_intersection = 0.;
  107. for(int i = 0; i < Fl::screen_count(); i++) {
  108. int sx, sy, sw, sh;
  109. Fl::screen_xywh(sx, sy, sw, sh, i);
  110. - float sintersection = fl_intersection(mx, my, mw, mh, sx, sy, sw, sh);
  111. + float sintersection = fl_intersection(x, y, w, h, sx, sy, sw, sh);
  112. if(sintersection > best_intersection) {
  113. best_screen = i;
  114. best_intersection = sintersection;
  115. }
  116. }
  117. - screen_xywh(X, Y, W, H, best_screen);
  118. + return best_screen;
  119. }
  120. -
  121. /**
  122. Gets the screen resolution in dots-per-inch for the given screen.
  123. \param[out] h, v horizontal and vertical resolution