Blender  V3.3
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_system.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_report.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 toplevel, bool dialog, bool temp, eWindowAlignment alignment)
 
int wm_window_close_exec (bContext *C, wmOperator *UNUSED(op))
 
int wm_window_new_exec (bContext *C, wmOperator *op)
 
int wm_window_new_main_exec (bContext *C, wmOperator *op)
 
int wm_window_fullscreen_toggle_exec (bContext *C, wmOperator *UNUSED(op))
 
void wm_cursor_position_from_ghost_client_coords (wmWindow *win, int *x, int *y)
 
void wm_cursor_position_to_ghost_client_coords (wmWindow *win, int *x, int *y)
 
void wm_cursor_position_from_ghost_screen_coords (wmWindow *win, int *x, int *y)
 
void wm_cursor_position_to_ghost_screen_coords (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 bool 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 bool 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_window_delete_removed_timers (wmWindowManager *wm)
 
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
wmWindowWM_window_find_under_cursor (wmWindow *win, const int mval[2], 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_input_devices (void)
 
void WM_cursor_warp (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
voidWM_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 94 of file wm_window.c.

Typedef Documentation

◆ eWinOverrideFlag

Enumeration Type Documentation

◆ eWinOverrideFlag

Enumerator
WIN_OVERRIDE_GEOM 
WIN_OVERRIDE_WINSTATE 

Definition at line 89 of file wm_window.c.

◆ modifierKeyType

Enumerator
SHIFT 
CONTROL 
ALT 
OS 

Definition at line 971 of file wm_window.c.

Function Documentation

◆ find_free_winid()

static int find_free_winid ( wmWindowManager wm)
static

Definition at line 240 of file wm_window.c.

References id, LISTBASE_FOREACH, wmWindowManager::windows, and winid.

Referenced by wm_window_new().

◆ ghost_event_proc()

static bool 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 1071 of file wm_window.c.

References Freestyle::a, wmWindow::active, wmWindow::addmousemove, ALT, BKE_icon_changed(), BLF_cache_clear(), C, CONTROL, copy_v2_v2_int(), GHOST_TStringArray::count, 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_kKeyUnknown, 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_NOTHING, KM_OSKEY, KM_RELEASE, KM_SHIFT, wmWindow::modalhandlers, wmEvent::modifier, MOUSEMOVE, NA_EDITED, NC_SCREEN, NC_WINDOW, NULL, OS, ot, wmWindow::posx, wmWindow::posy, wmEvent::prev_xy, query_qual(), RNA_boolean_set(), RNA_string_set(), SHIFT, wmWindow::sizex, wmWindow::sizey, state, GHOST_TStringArray::strings, time, type, UI_popup_handlers_remove_all(), wmWindowManager::winactive, wmWindow::windowstate, wmWindow::winid, wm_cursor_position_from_ghost_screen_coords(), 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_TEventDragnDropData::x, wmEvent::xy, GHOST_TEventCursorData::y, GHOST_TEventTrackpadData::y, and GHOST_TEventDragnDropData::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 1770 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 1725 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 1775 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 332 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_position_from_ghost_client_coords()

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

◆ wm_cursor_position_from_ghost_screen_coords()

void wm_cursor_position_from_ghost_screen_coords ( 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_client_coords()

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

◆ wm_cursor_position_to_ghost_screen_coords()

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

◆ WM_cursor_warp()

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

This function requires access to the GHOST_SystemHandle (g_system).

Definition at line 2054 of file wm_window.c.

References wmWindow::eventstate, g_system, GHOST_SetCursorPosition(), wmWindow::ghostwin, wmEvent::prev_xy, wm_cursor_position_to_ghost_client_coords(), x, wmEvent::xy, and y.

Referenced by initFlyInfo(), wm_cursor_warp_relative(), and wm_gizmomap_modal_set().

◆ 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 
)

◆ WM_event_timer_sleep()

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

◆ wm_get_desktopsize()

void wm_get_desktopsize ( int *  r_width,
int *  r_height 
)

Size of all screens (desktop), useful since the mouse is bound by this.

Definition at line 133 of file wm_window.c.

References g_system, and GHOST_GetAllDisplayDimensions().

Referenced by wm_window_ghostwindow_add(), and wm_window_update_size_position().

◆ wm_get_screensize()

void wm_get_screensize ( int *  r_width,
int *  r_height 
)

This one should correctly check for apple top header... done for Cocoa: returns window contents (and not frame) max size.

Definition at line 123 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 1600 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 2392 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_input_devices()

void WM_init_input_devices ( void  )

◆ WM_init_native_pixels()

void WM_init_native_pixels ( bool  do_it)

Definition at line 2023 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  )

For border-less and border windows set from command-line.

Definition at line 2000 of file wm_window.c.

References GHOST_kWindowStateFullScreen, WMInitStruct::override_flag, WIN_OVERRIDE_WINSTATE, WMInitStruct::windowstate, and wm_init_state.

Referenced by arg_handle_without_borders().

◆ 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_window_focus_set()

void WM_init_window_focus_set ( bool  do_it)

Definition at line 2018 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 1833 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 1825 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 339 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_session_data_has_unsaved_changes(), 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 323 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 865 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 ( struct Main bmain,
wmWindowManager wm,
wmWindow win_src,
bool  duplicate_layout,
bool  child 
)

◆ wm_window_copy_test()

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

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

Definition at line 297 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_delete_removed_timers()

void wm_window_delete_removed_timers ( wmWindowManager wm)

Effectively remove timers from the list and delete them. Calling this should only be done by internal WM management code, from specific, safe places.

Definition at line 1669 of file wm_window.c.

References BLI_remlink(), LISTBASE_FOREACH_MUTABLE, MEM_freeN, wmWindowManager::timers, and WM_TIMER_TAGGED_FOR_REMOVAL.

Referenced by wm_window_free(), and wm_window_timer().

◆ 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()

wmWindow* WM_window_find_under_cursor ( wmWindow win,
const int  mval[2],
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)

Definition at line 2300 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(), bpy_rna_context_temp_override_enter(), button_activate_init(), button_tooltip_timer_reset(), blender::ed::space_node::compo_get_recalc_flags(), datadropper_win_area_find(), ED_area_find_under_cursor(), ED_area_type_hud_clear(), ED_area_update_region_sizes(), ED_clip_update_frame(), ED_editors_init(), ED_fileselect_handler_area_find(), ED_fileselect_handler_area_find_any_with_op(), ED_info_stats_clear(), ED_node_set_active(), 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(), 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_dropbox_invoke(), 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_get_if_valid(), wm_operator_winactive_normal(), WM_paint_cursor_tag_redraw(), wm_paintcursor_draw(), wm_region_tag_draw_on_gizmo_delay_refresh_for_tweak(), WM_stereo3d_enabled(), wm_stereo3d_set_exec(), WM_toolsystem_do_msg_notify_tag_refresh(), WM_toolsystem_refresh_active(), WM_toolsystem_refresh_screen_window(), 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 2217 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_info_stats_clear(), 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(), tree_element_object_activate(), 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_window(), 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_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 1846 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 1893 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 initialize 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 661 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 684 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 2126 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 2131 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 op 
)

◆ wm_window_new_main_exec()

int wm_window_new_main_exec ( bContext C,
wmOperator op 
)

◆ WM_window_open()

wmWindow* WM_window_open ( struct bContext C,
const char *  title,
int  x,
int  y,
int  sizex,
int  sizey,
int  space_type,
bool  toplevel,
bool  dialog,
bool  temp,
eWindowAlignment  alignment 
)
Parameters
space_typeSPACE_VIEW3D, SPACE_INFO, ... (eSpace_Type)
toplevelNot a child owned by other windows. A peer of main window.
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 721 of file wm_window.c.

References blender::compositor::area(), bScreen::areabase, BKE_workspace_active_set(), BKE_workspace_layout_screen_get(), BLI_listbase_is_single(), 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, GHOST_GetNativePixelSize(), GHOST_SetTitle(), wmWindow::ghostwin, LISTBASE_FOREACH, ViewLayer::name, NULL, wmWindow::posx, wmWindow::posy, scene, wmWindow::sizex, wmWindow::sizey, SPACE_EMPTY, wmWindow::stereo3d_format, 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_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_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 ( struct Main bmain,
struct bContext C,
struct wmWindow win,
struct Scene scene_new 
)

◆ 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 1852 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 1888 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 1883 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 bool 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 1477 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(), WM_main_add_notifier(), WM_TIMER_TAGGED_FOR_REMOVAL, and wm_window_delete_removed_timers().

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,
struct 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 work-spaces and their visible layouts.

Definition at line 2142 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