Mercurial > sdl-ios-xcode
comparison src/video/photon/SDL_photon.c @ 3685:64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Thu, 21 Jan 2010 06:21:52 +0000 |
parents | 4b594623401b |
children | f7b03b6838cb |
comparison
equal
deleted
inserted
replaced
3684:cc564f08884f | 3685:64ce267332c6 |
---|---|
775 int | 775 int |
776 photon_createwindow(_THIS, SDL_Window * window) | 776 photon_createwindow(_THIS, SDL_Window * window) |
777 { | 777 { |
778 SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata; | 778 SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata; |
779 SDL_DisplayData *didata = | 779 SDL_DisplayData *didata = |
780 (SDL_DisplayData *) SDL_GetDisplayFromWindow(window)->driverdata; | 780 (SDL_DisplayData *) window->display->driverdata; |
781 SDL_WindowData *wdata; | 781 SDL_WindowData *wdata; |
782 PhDim_t winsize; | 782 PhDim_t winsize; |
783 PhPoint_t winpos; | 783 PhPoint_t winpos; |
784 PtArg_t winargs[32]; | 784 PtArg_t winargs[32]; |
785 uint32_t winargc = 0; | 785 uint32_t winargc = 0; |
995 | 995 |
996 /* Flush all widget operations again */ | 996 /* Flush all widget operations again */ |
997 PtFlush(); | 997 PtFlush(); |
998 | 998 |
999 /* By default last created window got a input focus */ | 999 /* By default last created window got a input focus */ |
1000 SDL_SetKeyboardFocus(0, window->id); | 1000 SDL_SetKeyboardFocus(0, window); |
1001 | 1001 |
1002 /* Emit focus gained event, because photon is not sending it */ | 1002 /* Emit focus gained event, because photon is not sending it */ |
1003 SDL_OnWindowFocusGained(window); | 1003 SDL_OnWindowFocusGained(window); |
1004 | 1004 |
1005 /* Window has been successfully created */ | 1005 /* Window has been successfully created */ |
1053 void | 1053 void |
1054 photon_setwindowposition(_THIS, SDL_Window * window) | 1054 photon_setwindowposition(_THIS, SDL_Window * window) |
1055 { | 1055 { |
1056 SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; | 1056 SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; |
1057 SDL_DisplayData *didata = | 1057 SDL_DisplayData *didata = |
1058 (SDL_DisplayData *) SDL_GetDisplayFromWindow(window)->driverdata; | 1058 (SDL_DisplayData *) window->display->driverdata; |
1059 PhPoint_t winpos; | 1059 PhPoint_t winpos; |
1060 int32_t status; | 1060 int32_t status; |
1061 | 1061 |
1062 /* Check if upper level requests WM to position window */ | 1062 /* Check if upper level requests WM to position window */ |
1063 if ((window->x == SDL_WINDOWPOS_UNDEFINED) | 1063 if ((window->x == SDL_WINDOWPOS_UNDEFINED) |
1221 void | 1221 void |
1222 photon_destroywindow(_THIS, SDL_Window * window) | 1222 photon_destroywindow(_THIS, SDL_Window * window) |
1223 { | 1223 { |
1224 SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata; | 1224 SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata; |
1225 SDL_DisplayData *didata = | 1225 SDL_DisplayData *didata = |
1226 (SDL_DisplayData *) SDL_GetDisplayFromWindow(window)->driverdata; | 1226 (SDL_DisplayData *) window->display->driverdata; |
1227 SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; | 1227 SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; |
1228 int32_t status; | 1228 int32_t status; |
1229 | 1229 |
1230 if (wdata != NULL) { | 1230 if (wdata != NULL) { |
1231 status = PtDestroyWidget(wdata->window); | 1231 status = PtDestroyWidget(wdata->window); |
1412 { | 1412 { |
1413 #if defined(SDL_VIDEO_OPENGL_ES) | 1413 #if defined(SDL_VIDEO_OPENGL_ES) |
1414 SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata; | 1414 SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata; |
1415 SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; | 1415 SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; |
1416 SDL_DisplayData *didata = | 1416 SDL_DisplayData *didata = |
1417 (SDL_DisplayData *) SDL_GetDisplayFromWindow(window)->driverdata; | 1417 (SDL_DisplayData *) window->display->driverdata; |
1418 EGLBoolean status; | 1418 EGLBoolean status; |
1419 int32_t gfstatus; | 1419 int32_t gfstatus; |
1420 EGLint configs; | 1420 EGLint configs; |
1421 uint32_t attr_pos; | 1421 uint32_t attr_pos; |
1422 EGLint attr_value; | 1422 EGLint attr_value; |
1939 { | 1939 { |
1940 #if defined(SDL_VIDEO_OPENGL_ES) | 1940 #if defined(SDL_VIDEO_OPENGL_ES) |
1941 SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata; | 1941 SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata; |
1942 SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; | 1942 SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; |
1943 SDL_DisplayData *didata = | 1943 SDL_DisplayData *didata = |
1944 (SDL_DisplayData *) SDL_GetDisplayFromWindow(window)->driverdata; | 1944 (SDL_DisplayData *) window->display->driverdata; |
1945 PhRect_t dst_rect; | 1945 PhRect_t dst_rect; |
1946 PhRect_t src_rect; | 1946 PhRect_t src_rect; |
1947 int32_t status; | 1947 int32_t status; |
1948 | 1948 |
1949 if (phdata->gfinitialized != SDL_TRUE) { | 1949 if (phdata->gfinitialized != SDL_TRUE) { |
2048 { | 2048 { |
2049 #if defined(SDL_VIDEO_OPENGL_ES) | 2049 #if defined(SDL_VIDEO_OPENGL_ES) |
2050 SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata; | 2050 SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata; |
2051 SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; | 2051 SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; |
2052 SDL_DisplayData *didata = | 2052 SDL_DisplayData *didata = |
2053 (SDL_DisplayData *) SDL_GetDisplayFromWindow(window)->driverdata; | 2053 (SDL_DisplayData *) window->display->driverdata; |
2054 SDL_bool makecurrent=SDL_FALSE; | 2054 SDL_bool makecurrent=SDL_FALSE; |
2055 int32_t gfstatus; | 2055 int32_t gfstatus; |
2056 | 2056 |
2057 /* Check if context has been initialized */ | 2057 /* Check if context has been initialized */ |
2058 if (wdata->gles_context == EGL_NO_CONTEXT) { | 2058 if (wdata->gles_context == EGL_NO_CONTEXT) { |
2197 switch (event->subtype) { | 2197 switch (event->subtype) { |
2198 case Ph_EV_PTR_ENTER: | 2198 case Ph_EV_PTR_ENTER: |
2199 { | 2199 { |
2200 /* Mouse cursor over handled window */ | 2200 /* Mouse cursor over handled window */ |
2201 if (window != NULL) { | 2201 if (window != NULL) { |
2202 SDL_SendWindowEvent(window->id, | 2202 SDL_SendWindowEvent(window, |
2203 SDL_WINDOWEVENT_ENTER, | 2203 SDL_WINDOWEVENT_ENTER, |
2204 0, 0); | 2204 0, 0); |
2205 SDL_SetMouseFocus(0, window->id); | 2205 SDL_SetMouseFocus(0, window); |
2206 } | 2206 } |
2207 } | 2207 } |
2208 break; | 2208 break; |
2209 case Ph_EV_PTR_LEAVE: | 2209 case Ph_EV_PTR_LEAVE: |
2210 { | 2210 { |
2211 /* Mouse cursor out of handled window */ | 2211 /* Mouse cursor out of handled window */ |
2212 if (window != NULL) { | 2212 if (window != NULL) { |
2213 SDL_SendWindowEvent(window->id, | 2213 SDL_SendWindowEvent(window, |
2214 SDL_WINDOWEVENT_LEAVE, | 2214 SDL_WINDOWEVENT_LEAVE, |
2215 0, 0); | 2215 0, 0); |
2216 } | 2216 } |
2217 } | 2217 } |
2218 break; | 2218 break; |
2680 | 2680 |
2681 switch (wmevent->event_f) { | 2681 switch (wmevent->event_f) { |
2682 case Ph_WM_CLOSE: | 2682 case Ph_WM_CLOSE: |
2683 { | 2683 { |
2684 if (window != NULL) { | 2684 if (window != NULL) { |
2685 SDL_SendWindowEvent(window->id, | 2685 SDL_SendWindowEvent(window, |
2686 SDL_WINDOWEVENT_CLOSE, | 2686 SDL_WINDOWEVENT_CLOSE, |
2687 0, 0); | 2687 0, 0); |
2688 } | 2688 } |
2689 } | 2689 } |
2690 break; | 2690 break; |
2693 if (wmevent->event_state == | 2693 if (wmevent->event_state == |
2694 Ph_WM_EVSTATE_FOCUS) { | 2694 Ph_WM_EVSTATE_FOCUS) { |
2695 if (window != NULL) { | 2695 if (window != NULL) { |
2696 PhRegion_t wregion; | 2696 PhRegion_t wregion; |
2697 | 2697 |
2698 SDL_SendWindowEvent(window->id, | 2698 SDL_SendWindowEvent(window, |
2699 SDL_WINDOWEVENT_FOCUS_GAINED, | 2699 SDL_WINDOWEVENT_FOCUS_GAINED, |
2700 0, 0); | 2700 0, 0); |
2701 SDL_SetKeyboardFocus(0, window->id); | 2701 SDL_SetKeyboardFocus(0, window); |
2702 | 2702 |
2703 /* Set window region sensible to mouse motion events */ | 2703 /* Set window region sensible to mouse motion events */ |
2704 PhRegionQuery(PtWidgetRid | 2704 PhRegionQuery(PtWidgetRid |
2705 (wdata->window), | 2705 (wdata->window), |
2706 &wregion, NULL, NULL, | 2706 &wregion, NULL, NULL, |
2710 Ph_EV_PTR_MOTION_NOBUTTON; | 2710 Ph_EV_PTR_MOTION_NOBUTTON; |
2711 PhRegionChange(Ph_REGION_EV_SENSE, 0, | 2711 PhRegionChange(Ph_REGION_EV_SENSE, 0, |
2712 &wregion, NULL, NULL); | 2712 &wregion, NULL, NULL); |
2713 | 2713 |
2714 /* If window got a focus, then it is visible */ | 2714 /* If window got a focus, then it is visible */ |
2715 SDL_SendWindowEvent(window->id, | 2715 SDL_SendWindowEvent(window, |
2716 SDL_WINDOWEVENT_SHOWN, | 2716 SDL_WINDOWEVENT_SHOWN, |
2717 0, 0); | 2717 0, 0); |
2718 } | 2718 } |
2719 } | 2719 } |
2720 if (wmevent->event_state == | 2720 if (wmevent->event_state == |
2721 Ph_WM_EVSTATE_FOCUSLOST) { | 2721 Ph_WM_EVSTATE_FOCUSLOST) { |
2722 if (window != NULL) { | 2722 if (window != NULL) { |
2723 PhRegion_t wregion; | 2723 PhRegion_t wregion; |
2724 | 2724 |
2725 SDL_SendWindowEvent(window->id, | 2725 SDL_SendWindowEvent(window, |
2726 SDL_WINDOWEVENT_FOCUS_LOST, | 2726 SDL_WINDOWEVENT_FOCUS_LOST, |
2727 0, 0); | 2727 0, 0); |
2728 | 2728 |
2729 /* Set window region ignore mouse motion events */ | 2729 /* Set window region ignore mouse motion events */ |
2730 PhRegionQuery(PtWidgetRid | 2730 PhRegionQuery(PtWidgetRid |
2741 } | 2741 } |
2742 break; | 2742 break; |
2743 case Ph_WM_MOVE: | 2743 case Ph_WM_MOVE: |
2744 { | 2744 { |
2745 if (window != NULL) { | 2745 if (window != NULL) { |
2746 SDL_SendWindowEvent(window->id, | 2746 SDL_SendWindowEvent(window, |
2747 SDL_WINDOWEVENT_MOVED, | 2747 SDL_WINDOWEVENT_MOVED, |
2748 wmevent->pos.x, | 2748 wmevent->pos.x, |
2749 wmevent->pos.y); | 2749 wmevent->pos.y); |
2750 } | 2750 } |
2751 } | 2751 } |
2752 break; | 2752 break; |
2753 case Ph_WM_RESIZE: | 2753 case Ph_WM_RESIZE: |
2754 { | 2754 { |
2755 if (window != NULL) { | 2755 if (window != NULL) { |
2756 /* Set new window position after resize */ | 2756 /* Set new window position after resize */ |
2757 SDL_SendWindowEvent(window->id, | 2757 SDL_SendWindowEvent(window, |
2758 SDL_WINDOWEVENT_MOVED, | 2758 SDL_WINDOWEVENT_MOVED, |
2759 wmevent->pos.x, | 2759 wmevent->pos.x, |
2760 wmevent->pos.y); | 2760 wmevent->pos.y); |
2761 | 2761 |
2762 /* Check if this window uses OpenGL ES */ | 2762 /* Check if this window uses OpenGL ES */ |
2764 /* If so, recreate surface with new dimensions */ | 2764 /* If so, recreate surface with new dimensions */ |
2765 photon_gl_recreatesurface(_this, window, wmevent->size.w, wmevent->size.h); | 2765 photon_gl_recreatesurface(_this, window, wmevent->size.w, wmevent->size.h); |
2766 } | 2766 } |
2767 | 2767 |
2768 /* Set new window size after resize */ | 2768 /* Set new window size after resize */ |
2769 SDL_SendWindowEvent(window->id, | 2769 SDL_SendWindowEvent(window, |
2770 SDL_WINDOWEVENT_RESIZED, | 2770 SDL_WINDOWEVENT_RESIZED, |
2771 wmevent->size.w, | 2771 wmevent->size.w, |
2772 wmevent->size.h); | 2772 wmevent->size.h); |
2773 } | 2773 } |
2774 } | 2774 } |
2775 break; | 2775 break; |
2776 case Ph_WM_HIDE: | 2776 case Ph_WM_HIDE: |
2777 { | 2777 { |
2778 if (window != NULL) { | 2778 if (window != NULL) { |
2779 /* Send new window state: minimized */ | 2779 /* Send new window state: minimized */ |
2780 SDL_SendWindowEvent(window->id, | 2780 SDL_SendWindowEvent(window, |
2781 SDL_WINDOWEVENT_MINIMIZED, | 2781 SDL_WINDOWEVENT_MINIMIZED, |
2782 0, 0); | 2782 0, 0); |
2783 /* In case window is minimized, then it is hidden */ | 2783 /* In case window is minimized, then it is hidden */ |
2784 SDL_SendWindowEvent(window->id, | 2784 SDL_SendWindowEvent(window, |
2785 SDL_WINDOWEVENT_HIDDEN, | 2785 SDL_WINDOWEVENT_HIDDEN, |
2786 0, 0); | 2786 0, 0); |
2787 } | 2787 } |
2788 } | 2788 } |
2789 break; | 2789 break; |
2790 case Ph_WM_MAX: | 2790 case Ph_WM_MAX: |
2791 { | 2791 { |
2792 if (window != NULL) { | 2792 if (window != NULL) { |
2793 if ((window->flags & SDL_WINDOW_RESIZABLE)==SDL_WINDOW_RESIZABLE) | 2793 if ((window->flags & SDL_WINDOW_RESIZABLE)==SDL_WINDOW_RESIZABLE) |
2794 { | 2794 { |
2795 SDL_SendWindowEvent(window->id, | 2795 SDL_SendWindowEvent(window, |
2796 SDL_WINDOWEVENT_MAXIMIZED, | 2796 SDL_WINDOWEVENT_MAXIMIZED, |
2797 0, 0); | 2797 0, 0); |
2798 } | 2798 } |
2799 else | 2799 else |
2800 { | 2800 { |
2804 } | 2804 } |
2805 break; | 2805 break; |
2806 case Ph_WM_RESTORE: | 2806 case Ph_WM_RESTORE: |
2807 { | 2807 { |
2808 if (window != NULL) { | 2808 if (window != NULL) { |
2809 SDL_SendWindowEvent(window->id, | 2809 SDL_SendWindowEvent(window, |
2810 SDL_WINDOWEVENT_RESTORED, | 2810 SDL_WINDOWEVENT_RESTORED, |
2811 0, 0); | 2811 0, 0); |
2812 } | 2812 } |
2813 } | 2813 } |
2814 break; | 2814 break; |