Changeset View
Changeset View
Standalone View
Standalone View
source/blender/windowmanager/intern/wm_window.c
| Show All 18 Lines | |||||
| */ | */ | ||||
| /** \file | /** \file | ||||
| * \ingroup wm | * \ingroup wm | ||||
| * | * | ||||
| * Window management, wrap GHOST. | * Window management, wrap GHOST. | ||||
| */ | */ | ||||
| #include <CLG_log.h> | |||||
| #include <math.h> | #include <math.h> | ||||
| #include <stdio.h> | #include <stdio.h> | ||||
| #include <stdlib.h> | #include <stdlib.h> | ||||
| #include <string.h> | #include <string.h> | ||||
| #include "DNA_listBase.h" | #include "DNA_listBase.h" | ||||
| #include "DNA_screen_types.h" | #include "DNA_screen_types.h" | ||||
| #include "DNA_windowmanager_types.h" | #include "DNA_windowmanager_types.h" | ||||
| ▲ Show 20 Lines • Show All 1,082 Lines • ▼ Show 20 Lines | |||||
| void wm_window_make_drawable(wmWindowManager *wm, wmWindow *win) | void wm_window_make_drawable(wmWindowManager *wm, wmWindow *win) | ||||
| { | { | ||||
| BLI_assert(GPU_framebuffer_active_get() == NULL); | BLI_assert(GPU_framebuffer_active_get() == NULL); | ||||
| if (win != wm->windrawable && win->ghostwin) { | if (win != wm->windrawable && win->ghostwin) { | ||||
| // win->lmbut = 0; /* keeps hanging when mousepressed while other window opened */ | // win->lmbut = 0; /* keeps hanging when mousepressed while other window opened */ | ||||
| wm_window_clear_drawable(wm); | wm_window_clear_drawable(wm); | ||||
| if (G.debug & G_DEBUG_EVENTS) { | CLOG_VERBOSE(WM_LOG_EVENTS, 1, "Set drawable %d", win->winid); | ||||
| printf("%s: set drawable %d\n", __func__, win->winid); | |||||
| } | |||||
| wm_window_set_drawable(wm, win, true); | wm_window_set_drawable(wm, win, true); | ||||
| /* this can change per window */ | /* this can change per window */ | ||||
| WM_window_set_dpi(win); | WM_window_set_dpi(win); | ||||
| } | } | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 199 Lines • ▼ Show 20 Lines | #undef USE_WIN_ACTIVATE | ||||
| break; | break; | ||||
| } | } | ||||
| case GHOST_kEventWindowClose: { | case GHOST_kEventWindowClose: { | ||||
| wm_window_close(C, wm, win); | wm_window_close(C, wm, win); | ||||
| break; | break; | ||||
| } | } | ||||
| case GHOST_kEventWindowUpdate: { | case GHOST_kEventWindowUpdate: { | ||||
| if (G.debug & G_DEBUG_EVENTS) { | CLOG_VERBOSE(WM_LOG_EVENTS, 3, "ghost redraw %d", win->winid); | ||||
| printf("%s: ghost redraw %d\n", __func__, win->winid); | |||||
| } | |||||
| wm_window_make_drawable(wm, win); | wm_window_make_drawable(wm, win); | ||||
| WM_event_add_notifier(C, NC_WINDOW, NULL); | WM_event_add_notifier(C, NC_WINDOW, NULL); | ||||
| break; | break; | ||||
| } | } | ||||
| case GHOST_kEventWindowSize: | case GHOST_kEventWindowSize: | ||||
| case GHOST_kEventWindowMove: { | case GHOST_kEventWindowMove: { | ||||
| Show All 12 Lines | #undef USE_WIN_ACTIVATE | ||||
| * | * | ||||
| * It might be good to eventually do that at Ghost level, but that is for | * It might be good to eventually do that at Ghost level, but that is for | ||||
| * another time. | * another time. | ||||
| */ | */ | ||||
| if (wm_window_update_size_position(win)) { | if (wm_window_update_size_position(win)) { | ||||
| const bScreen *screen = WM_window_get_active_screen(win); | const bScreen *screen = WM_window_get_active_screen(win); | ||||
| /* debug prints */ | /* debug prints */ | ||||
| if (G.debug & G_DEBUG_EVENTS) { | if (CLOG_CHECK_LEVEL(WM_LOG_EVENTS, 1)) { | ||||
| const char *state_str; | const char *state_str; | ||||
| state = GHOST_GetWindowState(win->ghostwin); | state = GHOST_GetWindowState(win->ghostwin); | ||||
| if (state == GHOST_kWindowStateNormal) { | if (state == GHOST_kWindowStateNormal) { | ||||
| state_str = "normal"; | state_str = "normal"; | ||||
| } | } | ||||
| else if (state == GHOST_kWindowStateMinimized) { | else if (state == GHOST_kWindowStateMinimized) { | ||||
| state_str = "minimized"; | state_str = "minimized"; | ||||
| } | } | ||||
| else if (state == GHOST_kWindowStateMaximized) { | else if (state == GHOST_kWindowStateMaximized) { | ||||
| state_str = "maximized"; | state_str = "maximized"; | ||||
| } | } | ||||
| else if (state == GHOST_kWindowStateFullScreen) { | else if (state == GHOST_kWindowStateFullScreen) { | ||||
| state_str = "fullscreen"; | state_str = "fullscreen"; | ||||
| } | } | ||||
| else { | else { | ||||
| state_str = "<unknown>"; | state_str = "<unknown>"; | ||||
| } | } | ||||
| printf("%s: window %d state = %s\n", __func__, win->winid, state_str); | CLOG_VERBOSE(WM_LOG_EVENTS, 1, "window %d state = %s", win->winid, state_str); | ||||
| if (type != GHOST_kEventWindowSize) { | if (type != GHOST_kEventWindowSize) { | ||||
| printf("win move event pos %d %d size %d %d\n", | CLOG_VERBOSE(WM_LOG_EVENTS, | ||||
| 1, | |||||
| "win move event pos %d %d size %d %d", | |||||
| win->posx, | win->posx, | ||||
| win->posy, | win->posy, | ||||
| win->sizex, | win->sizex, | ||||
| win->sizey); | win->sizey); | ||||
| } | } | ||||
| } | } | ||||
| wm_window_make_drawable(wm, win); | wm_window_make_drawable(wm, win); | ||||
| BKE_icon_changed(screen->id.icon_id); | BKE_icon_changed(screen->id.icon_id); | ||||
| WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL); | WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL); | ||||
| WM_event_add_notifier(C, NC_WINDOW | NA_EDITED, NULL); | WM_event_add_notifier(C, NC_WINDOW | NA_EDITED, NULL); | ||||
| ▲ Show 20 Lines • Show All 64 Lines • ▼ Show 20 Lines | #endif | ||||
| event.type = EVT_DROP; | event.type = EVT_DROP; | ||||
| event.val = KM_RELEASE; | event.val = KM_RELEASE; | ||||
| event.custom = EVT_DATA_DRAGDROP; | event.custom = EVT_DATA_DRAGDROP; | ||||
| event.customdata = &wm->drags; | event.customdata = &wm->drags; | ||||
| event.customdatafree = 1; | event.customdatafree = 1; | ||||
| wm_event_add(win, &event); | wm_event_add(win, &event); | ||||
| /* printf("Drop detected\n"); */ | /* CLOG_INFO(WM_LOG_EVENTS, "Drop detected"); */ | ||||
| /* add drag data to wm for paths: */ | /* add drag data to wm for paths: */ | ||||
| if (ddd->dataType == GHOST_kDragnDropTypeFilenames) { | if (ddd->dataType == GHOST_kDragnDropTypeFilenames) { | ||||
| GHOST_TStringArray *stra = ddd->data; | GHOST_TStringArray *stra = ddd->data; | ||||
| int a, icon; | int a, icon; | ||||
| for (a = 0; a < stra->count; a++) { | for (a = 0; a < stra->count; a++) { | ||||
| printf("drop file %s\n", stra->strings[a]); | CLOG_INFO(WM_LOG_EVENTS, "drop file %s", stra->strings[a]); | ||||
| /* try to get icon type from extension */ | /* try to get icon type from extension */ | ||||
| icon = ED_file_extension_icon((char *)stra->strings[a]); | icon = ED_file_extension_icon((char *)stra->strings[a]); | ||||
| WM_event_start_drag(C, icon, WM_DRAG_PATH, stra->strings[a], 0.0, WM_DRAG_NOP); | WM_event_start_drag(C, icon, WM_DRAG_PATH, stra->strings[a], 0.0, WM_DRAG_NOP); | ||||
| /* void poin should point to string, it makes a copy */ | /* void poin should point to string, it makes a copy */ | ||||
| break; /* only one drop element supported now */ | break; /* only one drop element supported now */ | ||||
| } | } | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 1,024 Lines • Show Last 20 Lines | |||||