Blender  V2.93
Classes | Macros | Typedefs | Enumerations | Functions | Variables
wm_window.c File Reference
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "DNA_listBase.h"
#include "DNA_screen_types.h"
#include "DNA_windowmanager_types.h"
#include "DNA_workspace_types.h"
#include "MEM_guardedalloc.h"
#include "GHOST_C-api.h"
#include "BLI_blenlib.h"
#include "BLI_math.h"
#include "BLI_utildefines.h"
#include "BLT_translation.h"
#include "BKE_context.h"
#include "BKE_global.h"
#include "BKE_icons.h"
#include "BKE_layer.h"
#include "BKE_main.h"
#include "BKE_screen.h"
#include "BKE_workspace.h"
#include "RNA_access.h"
#include "RNA_define.h"
#include "RNA_enum_types.h"
#include "WM_api.h"
#include "WM_types.h"
#include "wm.h"
#include "wm_draw.h"
#include "wm_event_system.h"
#include "wm_files.h"
#include "wm_platform_support.h"
#include "wm_window.h"
#include "wm_window_private.h"
#include "ED_anim_api.h"
#include "ED_fileselect.h"
#include "ED_render.h"
#include "ED_scene.h"
#include "ED_screen.h"
#include "UI_interface.h"
#include "UI_interface_icons.h"
#include "PIL_time.h"
#include "BLF_api.h"
#include "GPU_batch.h"
#include "GPU_batch_presets.h"
#include "GPU_context.h"
#include "GPU_framebuffer.h"
#include "GPU_immediate.h"
#include "GPU_init_exit.h"
#include "GPU_platform.h"
#include "GPU_state.h"
#include "GPU_texture.h"
#include "UI_resources.h"
#include "BLI_threads.h"

Go to the source code of this file.

Classes

struct  WMInitStruct
 

Macros

#define GHOST_WINDOW_STATE_DEFAULT   GHOST_kWindowStateMaximized
 

Typedefs

typedef enum eWinOverrideFlag eWinOverrideFlag
 

Enumerations

enum  eWinOverrideFlag { WIN_OVERRIDE_GEOM = (1 << 0) , WIN_OVERRIDE_WINSTATE = (1 << 1) }
 
enum  modifierKeyType { SHIFT = 's' , CONTROL = 'c' , ALT = 'a' , OS = 'C' }
 

Functions

void wm_window_close (bContext *C, wmWindowManager *wm, wmWindow *win)
 
void wm_window_title (wmWindowManager *wm, wmWindow *win)
 
void WM_window_set_dpi (const wmWindow *win)
 
static void wm_window_update_eventstate (wmWindow *win)
 
static void wm_window_ensure_eventstate (wmWindow *win)
 
static void wm_window_ghostwindow_add (wmWindowManager *wm, const char *title, wmWindow *win, bool is_dialog)
 
static void wm_window_ghostwindow_ensure (wmWindowManager *wm, wmWindow *win, bool is_dialog)
 
void wm_window_ghostwindows_ensure (wmWindowManager *wm)
 
void wm_window_ghostwindows_remove_invalid (bContext *C, wmWindowManager *wm)
 
static bool wm_window_update_size_position (wmWindow *win)
 
wmWindowWM_window_open (bContext *C, const char *title, int x, int y, int sizex, int sizey, int space_type, bool dialog, bool temp, WindowAlignment alignment)
 
int wm_window_close_exec (bContext *C, wmOperator *UNUSED(op))
 
int wm_window_new_exec (bContext *C, wmOperator *UNUSED(op))
 
int wm_window_new_main_exec (bContext *C, wmOperator *UNUSED(op))
 
int wm_window_fullscreen_toggle_exec (bContext *C, wmOperator *UNUSED(op))
 
void wm_cursor_position_from_ghost (wmWindow *win, int *x, int *y)
 
void wm_cursor_position_to_ghost (wmWindow *win, int *x, int *y)
 
void wm_cursor_position_get (wmWindow *win, int *r_x, int *r_y)
 
static int query_qual (modifierKeyType qual)
 
void wm_window_clear_drawable (wmWindowManager *wm)
 
void wm_window_make_drawable (wmWindowManager *wm, wmWindow *win)
 
void wm_window_reset_drawable (void)
 
static int ghost_event_proc (GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr)
 
void wm_window_process_events (const bContext *C)
 
Window Open & Close
static void wm_window_set_drawable (wmWindowManager *wm, wmWindow *win, bool activate)
 
static int wm_window_timer (const bContext *C)
 
void wm_get_screensize (int *r_width, int *r_height)
 
void wm_get_desktopsize (int *r_width, int *r_height)
 
static void wm_window_check_size (rcti *rect)
 
static void wm_ghostwindow_destroy (wmWindowManager *wm, wmWindow *win)
 
void wm_window_free (bContext *C, wmWindowManager *wm, wmWindow *win)
 
static int find_free_winid (wmWindowManager *wm)
 
wmWindowwm_window_new (const Main *bmain, wmWindowManager *wm, wmWindow *parent, bool dialog)
 
wmWindowwm_window_copy (Main *bmain, wmWindowManager *wm, wmWindow *win_src, const bool duplicate_layout, const bool child)
 
wmWindowwm_window_copy_test (bContext *C, wmWindow *win_src, const bool duplicate_layout, const bool child)
 
Quit Confirmation Dialog
static void wm_save_file_on_quit_dialog_callback (bContext *C, void *UNUSED(user_data))
 
static void wm_confirm_quit (bContext *C)
 
void wm_quit_with_optional_confirmation_prompt (bContext *C, wmWindow *win)
 
Ghost Init/Exit
void wm_ghost_init (bContext *C)
 
void wm_ghost_exit (void)
 
Event Timer
void WM_event_timer_sleep (wmWindowManager *wm, wmWindow *UNUSED(win), wmTimer *timer, bool do_sleep)
 
wmTimerWM_event_add_timer (wmWindowManager *wm, wmWindow *win, int event_type, double timestep)
 
wmTimerWM_event_add_timer_notifier (wmWindowManager *wm, wmWindow *win, unsigned int type, double timestep)
 
void WM_event_remove_timer (wmWindowManager *wm, wmWindow *UNUSED(win), wmTimer *timer)
 
void WM_event_remove_timer_notifier (wmWindowManager *wm, wmWindow *win, wmTimer *timer)
 
Clipboard
static char * wm_clipboard_text_get_ex (bool selection, int *r_len, bool firstline)
 
char * WM_clipboard_text_get (bool selection, int *r_len)
 
char * WM_clipboard_text_get_firstline (bool selection, int *r_len)
 
void WM_clipboard_text_set (const char *buf, bool selection)
 
Progress Bar
void WM_progress_set (wmWindow *win, float progress)
 
void WM_progress_clear (wmWindow *win)
 
Window Position/Size (internal)
void wm_window_get_position (wmWindow *win, int *r_pos_x, int *r_pos_y)
 
void wm_window_set_size (wmWindow *win, int width, int height)
 
Window Depth (Raise/Lower)
void wm_window_lower (wmWindow *win)
 
void wm_window_raise (wmWindow *win)
 
Window Buffers
void wm_window_swap_buffers (wmWindow *win)
 Push rendered buffer to the screen. More...
 
void wm_window_set_swap_interval (wmWindow *win, int interval)
 
bool wm_window_get_swap_interval (wmWindow *win, int *intervalOut)
 
Find Window Utility
static void wm_window_desktop_pos_get (const wmWindow *win, const int screen_pos[2], int r_desk_pos[2])
 
static void wm_window_screen_pos_get (const wmWindow *win, const int desktop_pos[2], int r_scr_pos[2])
 
bool WM_window_find_under_cursor (const wmWindowManager *wm, const wmWindow *win_ignore, const wmWindow *win, const int mval[2], wmWindow **r_win, int r_mval[2])
 
void WM_window_pixel_sample_read (const wmWindowManager *wm, const wmWindow *win, const int pos[2], float r_col[3])
 
Window Screen Shot Utility

Include here since it can involve low level buffer switching.

uintWM_window_pixels_read (wmWindowManager *wm, wmWindow *win, int r_size[2])
 
Initial Window State API
void WM_init_state_size_set (int stax, int stay, int sizx, int sizy)
 
void WM_init_state_fullscreen_set (void)
 
void WM_init_state_normal_set (void)
 
void WM_init_state_maximized_set (void)
 
void WM_init_window_focus_set (bool do_it)
 
void WM_init_native_pixels (bool do_it)
 
Cursor API
void WM_init_tablet_api (void)
 
void WM_cursor_warp (wmWindow *win, int x, int y)
 
void WM_cursor_compatible_xy (wmWindow *win, int *x, int *y)
 
Window Size (public)
int WM_window_pixels_x (const wmWindow *win)
 
int WM_window_pixels_y (const wmWindow *win)
 
void WM_window_rect_calc (const wmWindow *win, rcti *r_rect)
 
void WM_window_screen_rect_calc (const wmWindow *win, rcti *r_rect)
 
bool WM_window_is_fullscreen (const wmWindow *win)
 
bool WM_window_is_maximized (const wmWindow *win)
 
Window Screen/Scene/WorkSpaceViewLayer API
void WM_windows_scene_data_sync (const ListBase *win_lb, Scene *scene)
 
SceneWM_windows_scene_get_from_screen (const wmWindowManager *wm, const bScreen *screen)
 
ViewLayerWM_windows_view_layer_get_from_screen (const wmWindowManager *wm, const bScreen *screen)
 
WorkSpaceWM_windows_workspace_get_from_screen (const wmWindowManager *wm, const bScreen *screen)
 
SceneWM_window_get_active_scene (const wmWindow *win)
 
void WM_window_set_active_scene (Main *bmain, bContext *C, wmWindow *win, Scene *scene)
 
ViewLayerWM_window_get_active_view_layer (const wmWindow *win)
 
void WM_window_set_active_view_layer (wmWindow *win, ViewLayer *view_layer)
 
void WM_window_ensure_active_view_layer (wmWindow *win)
 
WorkSpaceWM_window_get_active_workspace (const wmWindow *win)
 
void WM_window_set_active_workspace (bContext *C, wmWindow *win, WorkSpace *workspace)
 
WorkSpaceLayoutWM_window_get_active_layout (const wmWindow *win)
 
void WM_window_set_active_layout (wmWindow *win, WorkSpace *workspace, WorkSpaceLayout *layout)
 
bScreenWM_window_get_active_screen (const wmWindow *win)
 
void WM_window_set_active_screen (wmWindow *win, WorkSpace *workspace, bScreen *screen)
 
bool WM_window_is_temp_screen (const wmWindow *win)
 
Direct OpenGL Context Management
void * WM_opengl_context_create (void)
 
void WM_opengl_context_dispose (void *context)
 
void WM_opengl_context_activate (void *context)
 
void WM_opengl_context_release (void *context)
 
void WM_ghost_show_message_box (const char *title, const char *message, const char *help_label, const char *continue_label, const char *link, GHOST_DialogOptions dialog_options)
 

Variables

static GHOST_SystemHandle g_system = NULL
 
static struct WMInitStruct wm_init_state
 

Detailed Description

Window management, wrap GHOST.

Definition in file wm_window.c.

Macro Definition Documentation

◆ GHOST_WINDOW_STATE_DEFAULT

#define GHOST_WINDOW_STATE_DEFAULT   GHOST_kWindowStateMaximized

Definition at line 109 of file wm_window.c.

Typedef Documentation

◆ eWinOverrideFlag

Enumeration Type Documentation

◆ eWinOverrideFlag

Enumerator
WIN_OVERRIDE_GEOM 
WIN_OVERRIDE_WINSTATE 

Definition at line 104 of file wm_window.c.

◆ modifierKeyType

Enumerator
SHIFT 
CONTROL 
ALT 
OS 

Definition at line 997 of file wm_window.c.

Function Documentation

◆ find_free_winid()

static int find_free_winid ( wmWindowManager wm)
static

Definition at line 250 of file wm_window.c.

References id, LISTBASE_FOREACH, and wmWindowManager::windows.

Referenced by wm_window_new().

◆ ghost_event_proc()

static int ghost_event_proc ( GHOST_EventHandle  evt,
GHOST_TUserDataPtr  C_void_ptr 
)
static

Called by ghost, here we handle events for windows themselves or send to event system.

Mouse coordinate conversion happens here.

Definition at line 1096 of file wm_window.c.

References Freestyle::a, wmWindow::active, wmWindow::addmousemove, ALT, wmEvent::alt, GHOST_TEventKeyData::ascii, BKE_icon_changed(), BLF_cache_clear(), C, CONTROL, GHOST_TStringArray::count, wmEvent::ctrl, CTX_wm_manager(), CTX_wm_window_set(), GHOST_TEventDragnDropData::data, data, GHOST_TEventDragnDropData::dataType, wmWindowManager::drags, ED_file_extension_icon(), wmWindow::eventstate, EVT_DATA_DRAGDROP, EVT_DROP, G, G_DEBUG_EVENTS, g_system, GHOST_GetEventData(), GHOST_GetEventTime(), GHOST_GetEventType(), GHOST_GetEventWindow(), GHOST_GetWindowState(), GHOST_GetWindowUserData(), GHOST_kDragnDropTypeFilenames, GHOST_kEventButtonDown, GHOST_kEventButtonUp, GHOST_kEventCursorMove, GHOST_kEventDraggingDropDone, GHOST_kEventKeyUp, GHOST_kEventNativeResolutionChange, GHOST_kEventOpenMainFile, GHOST_kEventQuitRequest, GHOST_kEventTrackpad, GHOST_kEventWindowActivate, GHOST_kEventWindowClose, GHOST_kEventWindowDeactivate, GHOST_kEventWindowDPIHintChanged, GHOST_kEventWindowMove, GHOST_kEventWindowSize, GHOST_kEventWindowUpdate, GHOST_kKeyLeftAlt, GHOST_kKeyLeftControl, GHOST_kKeyLeftShift, GHOST_kKeyOS, GHOST_kWindowStateFullScreen, GHOST_kWindowStateMaximized, GHOST_kWindowStateMinimized, GHOST_kWindowStateNormal, GHOST_ValidWindow(), wmWindow::ghostwin, ID::icon_id, bScreen::id, wmWindowManager::initialized, GHOST_TEventKeyData::key, wmEvent::keymodifier, KM_ALT, KM_CTRL, KM_MOD_FIRST, KM_OSKEY, KM_RELEASE, KM_SHIFT, wmWindow::modalhandlers, MOUSEMOVE, NA_EDITED, NC_SCREEN, NC_WINDOW, NULL, OS, wmEvent::oskey, ot, wmWindow::posx, wmWindow::posy, query_qual(), RNA_boolean_set(), RNA_string_set(), SHIFT, wmEvent::shift, wmWindow::sizex, wmWindow::sizey, state, GHOST_TStringArray::strings, time, type, UI_popup_handlers_remove_all(), GHOST_TEventKeyData::utf8_buf, wmWindowManager::winactive, wmWindow::windowstate, wmWindow::winid, wm_cursor_position_from_ghost(), WM_DRAG_NOP, WM_DRAG_PATH, wm_draw_update(), wm_event_add(), wm_event_add_ghostevent(), WM_event_add_notifier(), wm_event_do_handlers(), wm_event_do_notifiers(), wm_event_init_from_window(), WM_event_start_drag(), wm_exit_schedule_delayed(), WM_main_add_notifier(), WM_OP_INVOKE_DEFAULT, WM_operator_name_call_ptr(), WM_operator_properties_create_ptr(), WM_operator_properties_free(), WM_operatortype_find(), wm_quit_with_optional_confirmation_prompt(), wm_window_close(), WM_window_get_active_screen(), WM_WINDOW_IS_INIT, wm_window_make_drawable(), WM_window_set_dpi(), wm_window_timer(), wm_window_update_eventstate(), wm_window_update_size_position(), GHOST_TEventCursorData::x, GHOST_TEventTrackpadData::x, GHOST_TEventCursorData::y, and GHOST_TEventTrackpadData::y.

Referenced by wm_ghost_init().

◆ query_qual()

static int query_qual ( modifierKeyType  qual)
static

◆ WM_clipboard_text_get()

char* WM_clipboard_text_get ( bool  selection,
int *  r_len 
)

Return text from the clipboard.

Note
Caller needs to check for valid utf8 if this is a requirement.

Definition at line 1765 of file wm_window.c.

References wm_clipboard_text_get_ex().

Referenced by console_paste_exec(), paste_text_exec(), pyrna_WindowManager_clipboard_get(), and text_paste_exec().

◆ wm_clipboard_text_get_ex()

static char* wm_clipboard_text_get_ex ( bool  selection,
int *  r_len,
bool  firstline 
)
static

Definition at line 1715 of file wm_window.c.

References ELEM, free(), G, GHOST_getClipboard(), MEM_mallocN, and NULL.

Referenced by WM_clipboard_text_get(), and WM_clipboard_text_get_firstline().

◆ WM_clipboard_text_get_firstline()

char* WM_clipboard_text_get_firstline ( bool  selection,
int *  r_len 
)

Convenience function for pasting to areas of Blender which don't support newlines.

Definition at line 1773 of file wm_window.c.

References wm_clipboard_text_get_ex().

Referenced by handleNumInput(), ui_but_get_pasted_text_from_clipboard(), and ui_textedit_copypaste().

◆ WM_clipboard_text_set()

void WM_clipboard_text_set ( const char *  buf,
bool  selection 
)

◆ wm_confirm_quit()

static void wm_confirm_quit ( bContext C)
static

Call the confirm dialog on quitting. It's displayed in the context window so caller should set it as desired.

Definition at line 348 of file wm_window.c.

References C, wmGenericCallback::exec, MEM_callocN, wm_close_file_dialog(), and wm_save_file_on_quit_dialog_callback().

Referenced by wm_quit_with_optional_confirmation_prompt().

◆ WM_cursor_compatible_xy()

void WM_cursor_compatible_xy ( wmWindow win,
int *  x,
int *  y 
)

Set x, y to values we can actually position the cursor to.

Definition at line 2110 of file wm_window.c.

References GHOST_GetNativePixelSize(), wmWindow::ghostwin, x, and y.

Referenced by initWalkInfo().

◆ wm_cursor_position_from_ghost()

void wm_cursor_position_from_ghost ( wmWindow win,
int *  x,
int *  y 
)

◆ wm_cursor_position_get()

void wm_cursor_position_get ( wmWindow win,
int *  r_x,
int *  r_y 
)

◆ wm_cursor_position_to_ghost()

void wm_cursor_position_to_ghost ( wmWindow win,
int *  x,
int *  y 
)

◆ WM_cursor_warp()

void WM_cursor_warp ( wmWindow win,
int  x,
int  y 
)

◆ WM_event_add_timer()

wmTimer* WM_event_add_timer ( wmWindowManager wm,
wmWindow win,
int  event_type,
double  timestep 
)

◆ WM_event_add_timer_notifier()

wmTimer* WM_event_add_timer_notifier ( wmWindowManager wm,
wmWindow win,
unsigned int  type,
double  timestep 
)

◆ WM_event_remove_timer()

void WM_event_remove_timer ( wmWindowManager wm,
wmWindow UNUSEDwin,
wmTimer timer 
)

◆ WM_event_remove_timer_notifier()

void WM_event_remove_timer_notifier ( wmWindowManager wm,
wmWindow win,
wmTimer timer 
)

Definition at line 1703 of file wm_window.c.

References wmTimer::customdata, NULL, and WM_event_remove_timer().

Referenced by file_draw_list(), file_exit(), and file_refresh().

◆ WM_event_timer_sleep()

void WM_event_timer_sleep ( wmWindowManager wm,
wmWindow UNUSEDwin,
wmTimer timer,
bool  do_sleep 
)

Definition at line 1619 of file wm_window.c.

References LISTBASE_FOREACH, and wmWindowManager::timers.

Referenced by ED_screen_refresh(), and screen_change_prepare().

◆ wm_get_desktopsize()

void wm_get_desktopsize ( int *  r_width,
int *  r_height 
)

◆ wm_get_screensize()

void wm_get_screensize ( int *  r_width,
int *  r_height 
)

Definition at line 140 of file wm_window.c.

References g_system, and GHOST_GetMainDisplayDimensions().

Referenced by wm_window_check_size(), and wm_window_ghostwindows_ensure().

◆ wm_ghost_exit()

void wm_ghost_exit ( void  )

Definition at line 1604 of file wm_window.c.

References g_system, GHOST_DisposeSystem(), and NULL.

Referenced by WM_exit_ex().

◆ wm_ghost_init()

void wm_ghost_init ( bContext C)

◆ WM_ghost_show_message_box()

void WM_ghost_show_message_box ( const char *  title,
const char *  message,
const char *  help_label,
const char *  continue_label,
const char *  link,
GHOST_DialogOptions  dialog_options 
)

Definition at line 2455 of file wm_window.c.

References BLI_assert, g_system, and GHOST_ShowMessageBox().

Referenced by WM_platform_support_perform_checks().

◆ wm_ghostwindow_destroy()

static void wm_ghostwindow_destroy ( wmWindowManager wm,
wmWindow win 
)
static

◆ WM_init_native_pixels()

void WM_init_native_pixels ( bool  do_it)

Definition at line 2061 of file wm_window.c.

References WMInitStruct::native_pixels, and wm_init_state.

Referenced by arg_handle_native_pixels_set().

◆ WM_init_state_fullscreen_set()

void WM_init_state_fullscreen_set ( void  )

◆ WM_init_state_maximized_set()

void WM_init_state_maximized_set ( void  )

◆ WM_init_state_normal_set()

void WM_init_state_normal_set ( void  )

◆ WM_init_state_size_set()

void WM_init_state_size_set ( int  stax,
int  stay,
int  sizx,
int  sizy 
)

◆ WM_init_tablet_api()

void WM_init_tablet_api ( void  )

◆ WM_init_window_focus_set()

void WM_init_window_focus_set ( bool  do_it)

Definition at line 2056 of file wm_window.c.

References WMInitStruct::window_focus, and wm_init_state.

Referenced by arg_handle_no_window_focus().

◆ WM_opengl_context_activate()

void WM_opengl_context_activate ( void *  context)

◆ WM_opengl_context_create()

void* WM_opengl_context_create ( void  )

◆ WM_opengl_context_dispose()

void WM_opengl_context_dispose ( void *  context)

◆ WM_opengl_context_release()

void WM_opengl_context_release ( void *  context)

◆ WM_progress_clear()

void WM_progress_clear ( wmWindow win)

Definition at line 1831 of file wm_window.c.

References GHOST_EndProgressBar(), and wmWindow::ghostwin.

Referenced by wm_jobs_update_progress_bars().

◆ WM_progress_set()

void WM_progress_set ( wmWindow win,
float  progress 
)

Definition at line 1823 of file wm_window.c.

References GHOST_SetProgressBar(), and wmWindow::ghostwin.

Referenced by wm_jobs_update_progress_bars().

◆ wm_quit_with_optional_confirmation_prompt()

void wm_quit_with_optional_confirmation_prompt ( bContext C,
wmWindow win 
)

Call the quit confirmation prompt or exit directly if needed. The use can still cancel via the confirmation popup. Also, this may not quit Blender immediately, but rather schedule the closing.

Parameters
winThe window to show the confirmation popup/window in.

Definition at line 362 of file wm_window.c.

References C, CTX_data_main(), CTX_wm_manager(), CTX_wm_window(), CTX_wm_window_set(), G, USER_SAVE_PROMPT, wm_confirm_quit(), wm_exit_schedule_delayed(), wm_file_or_image_is_modified(), and wm_window_raise().

Referenced by ghost_event_proc(), wm_exit_blender_invoke(), and wm_window_close().

◆ wm_save_file_on_quit_dialog_callback()

static void wm_save_file_on_quit_dialog_callback ( bContext C,
void *  UNUSEDuser_data 
)
static

Definition at line 339 of file wm_window.c.

References C, and wm_exit_schedule_delayed().

Referenced by wm_confirm_quit().

◆ wm_window_check_size()

static void wm_window_check_size ( rcti rect)
static

◆ wm_window_clear_drawable()

void wm_window_clear_drawable ( wmWindowManager wm)

◆ wm_window_close()

void wm_window_close ( bContext C,
wmWindowManager wm,
wmWindow win 
)

◆ wm_window_close_exec()

int wm_window_close_exec ( bContext C,
wmOperator UNUSEDop 
)

Definition at line 906 of file wm_window.c.

References C, CTX_wm_manager(), CTX_wm_window(), OPERATOR_FINISHED, and wm_window_close().

Referenced by WM_OT_window_close().

◆ wm_window_copy()

wmWindow* wm_window_copy ( Main bmain,
wmWindowManager wm,
wmWindow win_src,
const bool  duplicate_layout,
const bool  child 
)

◆ wm_window_copy_test()

wmWindow* wm_window_copy_test ( bContext C,
wmWindow win_src,
const bool  duplicate_layout,
const bool  child 
)

A higher level version of copy that tests the new window can be added. (called from the operator directly)

Definition at line 313 of file wm_window.c.

References C, CTX_data_main(), CTX_wm_manager(), CTX_wm_window(), wmWindow::ghostwin, NA_ADDED, NC_WINDOW, NULL, WM_check(), WM_event_add_notifier_ex(), wm_window_close(), and wm_window_copy().

Referenced by wm_stereo3d_set_exec(), and wm_window_new_main_exec().

◆ wm_window_desktop_pos_get()

static void wm_window_desktop_pos_get ( const wmWindow win,
const int  screen_pos[2],
int  r_desk_pos[2] 
)
static

Definition at line 1904 of file wm_window.c.

References wmWindow::posx, and wmWindow::posy.

Referenced by WM_window_find_under_cursor().

◆ WM_window_ensure_active_view_layer()

void WM_window_ensure_active_view_layer ( wmWindow win)

◆ wm_window_ensure_eventstate()

static void wm_window_ensure_eventstate ( wmWindow win)
static

◆ WM_window_find_under_cursor()

bool WM_window_find_under_cursor ( const wmWindowManager wm,
const wmWindow win_ignore,
const wmWindow win,
const int  mval[2],
wmWindow **  r_win,
int  r_mval[2] 
)

◆ wm_window_free()

void wm_window_free ( bContext C,
wmWindowManager wm,
wmWindow win 
)

◆ wm_window_fullscreen_toggle_exec()

int wm_window_fullscreen_toggle_exec ( bContext C,
wmOperator UNUSEDop 
)

◆ WM_window_get_active_layout()

WorkSpaceLayout* WM_window_get_active_layout ( const wmWindow win)

◆ WM_window_get_active_scene()

Scene* WM_window_get_active_scene ( const wmWindow win)

◆ WM_window_get_active_screen()

bScreen* WM_window_get_active_screen ( const wmWindow win)

Get the active screen of the active workspace in win.

Definition at line 2372 of file wm_window.c.

References BKE_workspace_active_screen_get(), LIKELY, NULL, WM_window_get_active_workspace(), and wmWindow::workspace_hook.

Referenced by actionzone_area_poll(), area_dupli_invoke(), areas_do_frame_follow(), button_activate_init(), button_tooltip_timer_reset(), compo_get_recalc_flags(), ED_area_type_hud_clear(), ED_area_update_region_sizes(), ED_clip_update_frame(), ED_fileselect_handler_area_find(), ED_object_texture_paint_mode_enter_ex(), ED_region_do_draw(), ED_render_scene_update(), ED_render_view3d_update(), ED_screen_animation_no_scrub(), ED_screen_animation_playing(), ED_screen_draw_edges(), ED_screen_refresh(), ED_screen_scene_change(), ED_screen_scene_find_with_window(), ED_screen_set_active_region(), ED_screen_state_toggle(), ED_screen_window_find(), ED_space_image_paint_update(), eyedropper_color_sample_fl(), find_area_showing_r_result(), ghost_event_proc(), gizmo_mesh_spin_redo_setup(), menu_items_from_ui_create(), redraw_timer_step(), region_cursor_set(), region_cursor_set_ex(), render_image_restore_layer(), render_image_update_pass_and_layer(), render_view_show_invoke(), screen_animation_step_invoke(), screen_cursor_set(), screen_geom_select_connected_edge(), screen_state_to_nonnormal(), SCULPT_flush_update_done(), toolsystem_refresh_screen_from_active_tool(), UI_but_tooltip_refresh(), UI_popup_block_close(), ui_popup_block_remove(), wm_draw_region_clear(), wm_draw_update(), wm_draw_update_clear_window(), wm_draw_update_test_window(), wm_draw_window(), wm_draw_window_offscreen(), wm_draw_window_onscreen(), wm_event_do_depsgraph(), wm_event_do_handlers(), wm_event_do_notifiers(), wm_event_do_refresh_wm_and_depsgraph(), wm_event_drag_and_drop_test(), WM_exit_ex(), wm_gesture_tag_redraw(), wm_handler_fileselect_do(), wm_handler_op_context(), wm_operator_winactive_normal(), WM_paint_cursor_tag_redraw(), wm_paintcursor_draw(), WM_stereo3d_enabled(), wm_stereo3d_set_exec(), WM_toolsystem_do_msg_notify_tag_refresh(), WM_toolsystem_refresh_active(), WM_toolsystem_refresh_screen_all(), WM_toolsystem_reinit_all(), WM_tooltip_clear(), WM_tooltip_immediate_init(), WM_tooltip_init(), WM_tooltip_refresh(), WM_tooltip_timer_clear(), WM_tooltip_timer_init_ex(), wm_window_close(), WM_window_cursor_keymap_status_refresh(), WM_window_is_temp_screen(), wm_window_match_init(), wm_window_match_keep_current_wm(), WM_window_open(), WM_window_set_active_workspace(), WM_window_status_area_tag_redraw(), WM_windows_scene_get_from_screen(), WM_windows_view_layer_get_from_screen(), and WM_windows_workspace_get_from_screen().

◆ WM_window_get_active_view_layer()

ViewLayer* WM_window_get_active_view_layer ( const wmWindow win)

Definition at line 2286 of file wm_window.c.

References BKE_view_layer_default_view(), BKE_view_layer_find(), NULL, scene, wmWindow::view_layer_name, WM_window_get_active_scene(), and WM_window_set_active_view_layer().

Referenced by buttons_context_path(), buttons_context_path_brush(), buttons_context_path_view_layer(), buttons_shading_context(), buttons_shading_new_context(), buttons_texture_users_from_context(), clean_viewport_memory(), ED_area_init(), ED_editors_init_for_undo(), ED_screen_scene_change(), image_listener(), pose_bone_layers_exec(), screen_animation_step_invoke(), screen_ctx_active_bone(), screen_ctx_active_gpencil_frame(), screen_ctx_active_gpencil_layer(), screen_ctx_active_object(), screen_ctx_active_pose_bone(), screen_ctx_edit_object(), screen_ctx_editable_gpencil_layers(), screen_ctx_editable_gpencil_strokes(), screen_ctx_editable_objects(), screen_ctx_gpencil_data(), screen_ctx_gpencil_data_owner(), screen_ctx_image_paint_object(), screen_ctx_object(), screen_ctx_objects_in_mode(), screen_ctx_objects_in_mode_unique_data(), screen_ctx_particle_edit_object(), screen_ctx_pose_object(), screen_ctx_sculpt_object(), screen_ctx_selectable_objects(), screen_ctx_selected_bones_(), screen_ctx_selected_editable_objects(), screen_ctx_selected_objects(), screen_ctx_selected_pose_bones(), screen_ctx_selected_pose_bones_from_active_object(), screen_ctx_vertex_paint_object(), screen_ctx_visible_gpencil_layers(), screen_ctx_visible_objects(), screen_ctx_visible_or_editable_bones_(), screen_ctx_visible_pose_bones(), screen_ctx_weight_paint_object(), sound_jack_sync_callback(), toolsystem_refresh_screen_from_active_tool(), view3d_main_region_cursor(), view3d_main_region_listener(), view_layer_add_exec(), wm_draw_update_test_window(), wm_event_do_depsgraph(), wm_event_do_handlers(), WM_toolsystem_do_msg_notify_tag_refresh(), WM_toolsystem_ref_sync_from_context(), WM_toolsystem_refresh_active(), WM_toolsystem_refresh_screen_all(), WM_toolsystem_reinit_all(), WM_window_cursor_keymap_status_refresh(), WM_window_set_active_scene(), WM_windows_view_layer_get_from_screen(), and wm_xr_session_scene_and_evaluated_depsgraph_get().

◆ WM_window_get_active_workspace()

WorkSpace* WM_window_get_active_workspace ( const wmWindow win)

◆ wm_window_get_position()

void wm_window_get_position ( wmWindow win,
int *  r_pos_x,
int *  r_pos_y 
)

Definition at line 1844 of file wm_window.c.

References wmWindow::posx, and wmWindow::posy.

◆ wm_window_get_swap_interval()

bool wm_window_get_swap_interval ( wmWindow win,
int *  intervalOut 
)

Definition at line 1894 of file wm_window.c.

References GHOST_GetSwapInterval(), and wmWindow::ghostwin.

◆ wm_window_ghostwindow_add()

static void wm_window_ghostwindow_add ( wmWindowManager wm,
const char *  title,
wmWindow win,
bool  is_dialog 
)
static

◆ wm_window_ghostwindow_ensure()

static void wm_window_ghostwindow_ensure ( wmWindowManager wm,
wmWindow win,
bool  is_dialog 
)
static

◆ wm_window_ghostwindows_ensure()

void wm_window_ghostwindows_ensure ( wmWindowManager wm)

Initialize wmWindow without ghostwin, open these and clear.

window size is read from window, if 0 it uses prefsize called in WM_check, also inits stuff after file read.

Warning
After running, 'win->ghostwin' can be NULL in rare cases (where OpenGL driver fails to create a context for eg). We could remove them with wm_window_ghostwindows_remove_invalid but better not since caller may continue to use. Instead, caller needs to handle the error case and cleanup.

Definition at line 693 of file wm_window.c.

References BLI_assert, G, LISTBASE_FOREACH, WMInitStruct::size_x, WMInitStruct::size_y, WMInitStruct::start_x, WMInitStruct::start_y, wmWindowManager::windows, wm_get_screensize(), wm_init_state, and wm_window_ghostwindow_ensure().

Referenced by WM_check().

◆ wm_window_ghostwindows_remove_invalid()

void wm_window_ghostwindows_remove_invalid ( bContext C,
wmWindowManager wm 
)

Call after wm_window_ghostwindows_ensure or WM_check (after loading a new file) in the unlikely event a window couldn't be created.

Definition at line 720 of file wm_window.c.

References BLI_assert, C, G, LISTBASE_FOREACH_MUTABLE, NULL, wmWindowManager::windows, and wm_window_close().

Referenced by wm_file_read_post().

◆ WM_window_is_fullscreen()

bool WM_window_is_fullscreen ( const wmWindow win)

Definition at line 2187 of file wm_window.c.

References GHOST_kWindowStateFullScreen, and wmWindow::windowstate.

Referenced by area_azone_init(), and wm_stereo3d_set_exec().

◆ WM_window_is_maximized()

bool WM_window_is_maximized ( const wmWindow win)

Definition at line 2192 of file wm_window.c.

References GHOST_kWindowStateMaximized, and wmWindow::windowstate.

Referenced by ED_fileselect_window_params_get().

◆ WM_window_is_temp_screen()

bool WM_window_is_temp_screen ( const wmWindow win)

◆ wm_window_lower()

void wm_window_lower ( wmWindow win)

◆ wm_window_make_drawable()

void wm_window_make_drawable ( wmWindowManager wm,
wmWindow win 
)

◆ wm_window_new()

wmWindow* wm_window_new ( const Main bmain,
wmWindowManager wm,
wmWindow parent,
bool  dialog 
)

◆ wm_window_new_exec()

int wm_window_new_exec ( bContext C,
wmOperator UNUSEDop 
)

◆ wm_window_new_main_exec()

int wm_window_new_main_exec ( bContext C,
wmOperator UNUSEDop 
)

◆ WM_window_open()

wmWindow* WM_window_open ( bContext C,
const char *  title,
int  x,
int  y,
int  sizex,
int  sizey,
int  space_type,
bool  dialog,
bool  temp,
WindowAlignment  alignment 
)
Parameters
space_typeSPACE_VIEW3D, SPACE_INFO, ... (eSpace_Type)
dialogwhether this should be made as a dialog-style window
tempwhether this is considered a short-lived window
alignmenthow this window is positioned relative to its parent
Returns
the window or NULL in case of failure.

Definition at line 764 of file wm_window.c.

References blender::compositor::area(), bScreen::areabase, BKE_workspace_active_set(), BKE_workspace_layout_screen_get(), BLI_rcti_size_x(), BLI_rcti_size_y(), C, CTX_data_main(), CTX_data_scene(), CTX_data_view_layer(), CTX_wm_area_set(), CTX_wm_manager(), CTX_wm_window(), CTX_wm_window_set(), ED_area_newspace(), ED_screen_change(), ED_screen_refresh(), ED_screen_scene_change(), ED_workspace_layout_add(), ListBase::first, free(), GHOST_GetNativePixelSize(), GHOST_GetTitle(), GHOST_SetTitle(), wmWindow::ghostwin, LISTBASE_FOREACH, ViewLayer::name, NULL, wmWindow::posx, wmWindow::posy, scene, wmWindow::sizex, wmWindow::sizey, SPACE_EMPTY, wmWindow::stereo3d_format, STREQ, STRNCPY, bScreen::temp, wmWindow::view_layer_name, WIN_ALIGN_LOCATION_CENTER, WIN_ALIGN_PARENT_CENTER, wmWindowManager::windows, WM_check(), wm_window_check_size(), wm_window_close(), WM_window_get_active_scene(), WM_window_get_active_screen(), WM_window_get_active_workspace(), wm_window_ghostwindow_ensure(), WM_window_is_temp_screen(), wm_window_new(), wm_window_raise(), WM_window_set_active_layout(), wm_window_set_size(), wm_window_update_size_position(), wmWindow::workspace_hook, x, rcti::xmax, rcti::xmin, y, rcti::ymax, and rcti::ymin.

Referenced by area_dupli_invoke(), drivers_editor_show_exec(), ED_screen_temp_space_open(), info_log_show_exec(), render_view_open(), userpref_show_exec(), and wm_window_new_exec().

◆ WM_window_pixel_sample_read()

void WM_window_pixel_sample_read ( const wmWindowManager wm,
const wmWindow win,
const int  pos[2],
float  r_col[3] 
)

◆ WM_window_pixels_read()

uint* WM_window_pixels_read ( wmWindowManager wm,
wmWindow win,
int  r_size[2] 
)

◆ WM_window_pixels_x()

int WM_window_pixels_x ( const wmWindow win)

◆ WM_window_pixels_y()

int WM_window_pixels_y ( const wmWindow win)

◆ wm_window_process_events()

void wm_window_process_events ( const bContext C)

◆ wm_window_raise()

void wm_window_raise ( wmWindow win)

◆ WM_window_rect_calc()

void WM_window_rect_calc ( const wmWindow win,
rcti r_rect 
)

◆ wm_window_reset_drawable()

void wm_window_reset_drawable ( void  )

◆ wm_window_screen_pos_get()

static void wm_window_screen_pos_get ( const wmWindow win,
const int  desktop_pos[2],
int  r_scr_pos[2] 
)
static

Definition at line 1913 of file wm_window.c.

References wmWindow::posx, and wmWindow::posy.

Referenced by WM_window_find_under_cursor().

◆ WM_window_screen_rect_calc()

void WM_window_screen_rect_calc ( const wmWindow win,
rcti r_rect 
)

◆ WM_window_set_active_layout()

void WM_window_set_active_layout ( wmWindow win,
WorkSpace workspace,
WorkSpaceLayout layout 
)

◆ WM_window_set_active_scene()

void WM_window_set_active_scene ( Main bmain,
bContext C,
wmWindow win,
Scene scene 
)

◆ WM_window_set_active_screen()

void WM_window_set_active_screen ( wmWindow win,
WorkSpace workspace,
bScreen screen 
)

◆ WM_window_set_active_view_layer()

void WM_window_set_active_view_layer ( wmWindow win,
ViewLayer view_layer 
)

◆ WM_window_set_active_workspace()

void WM_window_set_active_workspace ( bContext C,
wmWindow win,
WorkSpace workspace 
)

◆ WM_window_set_dpi()

void WM_window_set_dpi ( const wmWindow win)

◆ wm_window_set_drawable()

static void wm_window_set_drawable ( wmWindowManager wm,
wmWindow win,
bool  activate 
)
static

◆ wm_window_set_size()

void wm_window_set_size ( wmWindow win,
int  width,
int  height 
)

Definition at line 1850 of file wm_window.c.

References GHOST_SetClientSize(), wmWindow::ghostwin, height, and width.

Referenced by WM_window_open().

◆ wm_window_set_swap_interval()

void wm_window_set_swap_interval ( wmWindow win,
int  interval 
)

Definition at line 1889 of file wm_window.c.

References GHOST_SetSwapInterval(), and wmWindow::ghostwin.

◆ wm_window_swap_buffers()

void wm_window_swap_buffers ( wmWindow win)

Push rendered buffer to the screen.

Definition at line 1884 of file wm_window.c.

References GHOST_SwapWindowBuffers(), and wmWindow::ghostwin.

Referenced by wm_draw_update(), and wm_window_ghostwindow_add().

◆ wm_window_timer()

static int wm_window_timer ( const bContext C)
static

This timer system only gives maximum 1 timer event per redraw cycle, to prevent queues to get overloaded. Timer handlers should check for delta to decide if they just update, or follow real time. Timer handlers can also set duration to match frames passed

Definition at line 1501 of file wm_window.c.

References C, ceil(), CTX_data_main(), CTX_wm_manager(), EVT_DATA_TIMER, KM_NOTHING, LISTBASE_FOREACH_MUTABLE, NULL, PIL_check_seconds_timer(), POINTER_AS_UINT, time, TIMERAUTOSAVE, TIMERJOBS, TIMERNOTIFIER, wmWindowManager::timers, wm_autosave_timer(), wm_event_add(), wm_event_init_from_window(), wm_jobs_timer(), and WM_main_add_notifier().

Referenced by ghost_event_proc(), and wm_window_process_events().

◆ wm_window_title()

void wm_window_title ( wmWindowManager wm,
wmWindow win 
)

◆ wm_window_update_eventstate()

static void wm_window_update_eventstate ( wmWindow win)
static

◆ wm_window_update_size_position()

static bool wm_window_update_size_position ( wmWindow win)
static

◆ WM_windows_scene_data_sync()

void WM_windows_scene_data_sync ( const ListBase win_lb,
Scene scene 
)

Some editor data may need to be synced with scene data (3D View camera and layers). This function ensures data is synced for editors in visible workspaces and their visible layouts.

Definition at line 2208 of file wm_window.c.

References ED_workspace_scene_data_sync(), LISTBASE_FOREACH, scene, and WM_window_get_active_scene().

Referenced by tree_element_camera_activate().

◆ WM_windows_scene_get_from_screen()

Scene* WM_windows_scene_get_from_screen ( const wmWindowManager wm,
const bScreen screen 
)

◆ WM_windows_view_layer_get_from_screen()

ViewLayer* WM_windows_view_layer_get_from_screen ( const wmWindowManager wm,
const bScreen screen 
)

◆ WM_windows_workspace_get_from_screen()

WorkSpace* WM_windows_workspace_get_from_screen ( const wmWindowManager wm,
const bScreen screen 
)

Variable Documentation

◆ g_system

GHOST_SystemHandle g_system = NULL
static

◆ wm_init_state

struct WMInitStruct wm_init_state
static