Moving content of a window affects to moving content in other windows

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • Moving content of a window affects to moving content in other windows

      Hello to everyone,

      my problem is following: here is a simple code with 3 simple windows with content inside the windows that can be moved using motion support.

      1st window - content can be moved circularly.
      2nd window - content can be moved horizontally.
      3rd window - content can be moved vertically.

      If I move content in 2nd and 3rd window all is fine and moves as it should.

      But if I move content in 1st window with circular motion support and after that I try to move content in other windows then begins the following:
      2nd window - content moves much faster (WM_MOTION_MOVE: pInfo->dx returns much higher values);
      3rd window - content doesn't move at all (WM_MOTION_MOVE: pInfo->dy returns 0).

      Here is the code using latest simulation package v6.26:

      C Source Code

      1. #include "DIALOG.h"
      2. int x1, y1, ang1 = 0;
      3. int x2 = 10;
      4. int y3 = 10;
      5. void _cbWin1(WM_MESSAGE * pMsg) {
      6. WM_MOTION_INFO * pInfo;
      7. switch (pMsg->MsgId) {
      8. case WM_MOTION:
      9. pInfo = (WM_MOTION_INFO *)pMsg->Data.p;
      10. switch (pInfo->Cmd) {
      11. case WM_MOTION_INIT:
      12. pInfo->Flags = WM_CF_MOTION_R | WM_MOTION_MANAGE_BY_WINDOW;
      13. break;
      14. case WM_MOTION_MOVE:
      15. ang1 += pInfo->da;
      16. WM_InvalidateWindow(pMsg->hWin);
      17. break;
      18. case WM_MOTION_GETPOS:
      19. pInfo->xPos = ang1;
      20. break;
      21. }
      22. break;
      23. case WM_PAINT:
      24. GUI_SetBkColor(GUI_WHITE);
      25. GUI_Clear();
      26. GUI_SetColor(GUI_BLACK);
      27. GUI_DispStringHCenterAt("Radial motion", 100, 10);
      28. x1 = (int)(GUI__SinHQ(ang1 * 100) * 85 * 0.0000152587890625f) + 100;
      29. y1 = (int)(GUI__CosHQ(ang1 * 100) * 85 * 0.0000152587890625f) + 100;
      30. GUI_SetColor(GUI_RED);
      31. GUI_FillCircle(x1, y1, 10);
      32. break;
      33. default:
      34. WM_DefaultProc(pMsg);
      35. break;
      36. }
      37. }
      38. void _cbWin2(WM_MESSAGE * pMsg) {
      39. WM_MOTION_INFO * pInfo;
      40. switch (pMsg->MsgId) {
      41. case WM_MOTION:
      42. pInfo = (WM_MOTION_INFO *)pMsg->Data.p;
      43. switch (pInfo->Cmd) {
      44. case WM_MOTION_INIT:
      45. pInfo->Flags = WM_CF_MOTION_X | WM_MOTION_MANAGE_BY_WINDOW;
      46. break;
      47. case WM_MOTION_MOVE:
      48. x2 += pInfo->dx;
      49. if (x2 < 10)
      50. x2 = 10;
      51. if (x2 > 290)
      52. x2 = 290;
      53. WM_InvalidateWindow(pMsg->hWin);
      54. break;
      55. case WM_MOTION_GETPOS:
      56. pInfo->xPos = x2;
      57. break;
      58. }
      59. break;
      60. case WM_PAINT:
      61. GUI_SetBkColor(GUI_WHITE);
      62. GUI_Clear();
      63. GUI_SetColor(GUI_BLACK);
      64. GUI_DispStringHCenterAt("Horizontal motion", 150, 10);
      65. GUI_SetColor(GUI_BLUE);
      66. GUI_FillCircle(x2, 50, 10);
      67. break;
      68. default:
      69. WM_DefaultProc(pMsg);
      70. break;
      71. }
      72. }
      73. void _cbWin3(WM_MESSAGE * pMsg) {
      74. WM_MOTION_INFO * pInfo;
      75. switch (pMsg->MsgId) {
      76. case WM_MOTION:
      77. pInfo = (WM_MOTION_INFO *)pMsg->Data.p;
      78. switch (pInfo->Cmd) {
      79. case WM_MOTION_INIT:
      80. pInfo->Flags = WM_CF_MOTION_Y | WM_MOTION_MANAGE_BY_WINDOW;
      81. break;
      82. case WM_MOTION_MOVE:
      83. y3 += pInfo->dy;
      84. if (y3 < 10)
      85. y3 = 10;
      86. if (y3 > 290)
      87. y3 = 290;
      88. WM_InvalidateWindow(pMsg->hWin);
      89. break;
      90. case WM_MOTION_GETPOS:
      91. pInfo->yPos = y3;
      92. break;
      93. }
      94. break;
      95. case WM_PAINT:
      96. GUI_SetBkColor(GUI_WHITE);
      97. GUI_Clear();
      98. GUI_SetColor(GUI_BLACK);
      99. GUI_DispStringHCenterAt("Vertical motion", 50, 10);
      100. GUI_SetColor(GUI_GREEN);
      101. GUI_FillCircle(50, y3, 10);
      102. break;
      103. default:
      104. WM_DefaultProc(pMsg);
      105. break;
      106. }
      107. }
      108. void MainTask(void) {
      109. GUI_Init();
      110. WM_MULTIBUF_Enable(1);
      111. WM_SetDesktopColor(GUI_BLACK);
      112. WM_SetScreenSize(1024, 768);
      113. WM_CreateWindow(100, 100, 200, 200, WM_CF_SHOW, _cbWin1, 0);
      114. WM_CreateWindow(400, 100, 300, 100, WM_CF_SHOW, _cbWin2, 0);
      115. WM_CreateWindow(800, 100, 100, 300, WM_CF_SHOW, _cbWin3, 0);
      116. WM_MOTION_Enable(1);
      117. while (1) {
      118. GUI_Delay(50);
      119. }
      120. }
      Display All
      What am I doing wrong?

      Thanks,
      Alex.
    • Hi Alex,

      Thank you for reporting this issue! The issue only occurs when WM_MOTION_R would be used initially and then vertical/horizontal motion afterwards. It will be fixed with the next bugfix release.

      If you need a fix for this as soon as possible, please have a look at the attached file. An internal function pointer was not reset from radial movements back to XY movements which is what I added to your sample.

      Best regards,
      Florian
      Files
      Please read the forum rules before posting.

      Keep in mind, this is *not* a support forum.
      Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
      Should you be entitled to support you can contact us via our support system: segger.com/ticket/

      Or you can contact us via e-mail.