full screen API
This commit is contained in:
parent
084d45b530
commit
2c20438e88
|
@ -89,6 +89,8 @@ Coming Soon</i><div>
|
|||
<li><a href='#directory_cd_doc'>directory_cd</a></li>
|
||||
<li><a href='#get_4ed_path_doc'>get_4ed_path</a></li>
|
||||
<li><a href='#show_mouse_cursor_doc'>show_mouse_cursor</a></li>
|
||||
<li><a href='#toggle_fullscreen_doc'>toggle_fullscreen</a></li>
|
||||
<li><a href='#is_fullscreen_doc'>is_fullscreen</a></li>
|
||||
</ul>
|
||||
<h3>§3.2 Type List</h3>
|
||||
<ul>
|
||||
|
@ -1059,6 +1061,18 @@ folders.</div></div><hr>
|
|||
<div style='margin-bottom: 6mm;'><div style='margin-left: 5mm; margin-right: 5mm;'>This parameter specifies the new state of the mouse cursor.</div></div>
|
||||
</div>
|
||||
<div style='margin-top: 3mm; margin-bottom: 3mm; color: #309030;'><b><i>See Also</i></b></div><div style='margin-left: 5mm; margin-right: 5mm;'><a href='#Mouse_Cursor_Show_Type_doc'>Mouse_Cursor_Show_Type</a></div></div><hr>
|
||||
<div id='toggle_fullscreen_doc' style='margin-bottom: 1cm;'>
|
||||
<h4>§3.3.58: toggle_fullscreen</h4>
|
||||
<div style='font-family: "Courier New", Courier, monospace; text-align: left; margin-top: 3mm; margin-bottom: 3mm; font-size: .95em; background: #DFDFDF; padding: 0.25em;'>void app->toggle_fullscreen(
|
||||
<div style='margin-left: 4mm;'>Application_Links *app<br></div>)
|
||||
</div>
|
||||
</div><hr>
|
||||
<div id='is_fullscreen_doc' style='margin-bottom: 1cm;'>
|
||||
<h4>§3.3.59: is_fullscreen</h4>
|
||||
<div style='font-family: "Courier New", Courier, monospace; text-align: left; margin-top: 3mm; margin-bottom: 3mm; font-size: .95em; background: #DFDFDF; padding: 0.25em;'>bool32 app->is_fullscreen(
|
||||
<div style='margin-left: 4mm;'>Application_Links *app<br></div>)
|
||||
</div>
|
||||
</div><hr>
|
||||
<h3>§3.4 Type Descriptions</h3>
|
||||
<h2 id='section_string_library'>§4 String Library</h2>
|
||||
<h3>§4.1 String Intro</h3>
|
||||
|
|
|
@ -55,6 +55,8 @@
|
|||
#define DIRECTORY_CD_SIG(n) bool32 n(Application_Links *app, char *dir, int32_t *len, int32_t capacity, char *rel_path, int32_t rel_len)
|
||||
#define GET_4ED_PATH_SIG(n) bool32 n(Application_Links *app, char *out, int32_t capacity)
|
||||
#define SHOW_MOUSE_CURSOR_SIG(n) void n(Application_Links *app, Mouse_Cursor_Show_Type show)
|
||||
#define TOGGLE_FULLSCREEN_SIG(n) void n(Application_Links *app)
|
||||
#define IS_FULLSCREEN_SIG(n) bool32 n(Application_Links *app)
|
||||
typedef EXEC_COMMAND_SIG(Exec_Command_Function);
|
||||
typedef EXEC_SYSTEM_COMMAND_SIG(Exec_System_Command_Function);
|
||||
typedef CLIPBOARD_POST_SIG(Clipboard_Post_Function);
|
||||
|
@ -112,6 +114,8 @@ typedef FILE_EXISTS_SIG(File_Exists_Function);
|
|||
typedef DIRECTORY_CD_SIG(Directory_CD_Function);
|
||||
typedef GET_4ED_PATH_SIG(Get_4ed_Path_Function);
|
||||
typedef SHOW_MOUSE_CURSOR_SIG(Show_Mouse_Cursor_Function);
|
||||
typedef TOGGLE_FULLSCREEN_SIG(Toggle_Fullscreen_Function);
|
||||
typedef IS_FULLSCREEN_SIG(Is_Fullscreen_Function);
|
||||
struct Application_Links{
|
||||
void *memory;
|
||||
int32_t memory_size;
|
||||
|
@ -172,6 +176,8 @@ struct Application_Links{
|
|||
Directory_CD_Function *directory_cd;
|
||||
Get_4ed_Path_Function *get_4ed_path;
|
||||
Show_Mouse_Cursor_Function *show_mouse_cursor;
|
||||
Toggle_Fullscreen_Function *toggle_fullscreen;
|
||||
Is_Fullscreen_Function *is_fullscreen;
|
||||
void *cmd_context;
|
||||
void *system_links;
|
||||
void *current_coroutine;
|
||||
|
@ -234,4 +240,6 @@ app_links->memory_free = Memory_Free;\
|
|||
app_links->file_exists = File_Exists;\
|
||||
app_links->directory_cd = Directory_CD;\
|
||||
app_links->get_4ed_path = Get_4ed_Path;\
|
||||
app_links->show_mouse_cursor = Show_Mouse_Cursor; } while(false)
|
||||
app_links->show_mouse_cursor = Show_Mouse_Cursor;\
|
||||
app_links->toggle_fullscreen = Toggle_Fullscreen;\
|
||||
app_links->is_fullscreen = Is_Fullscreen; } while(false)
|
||||
|
|
|
@ -277,6 +277,7 @@ default_keys(Bind_Helper *context){
|
|||
bind(context, 'w', MDFR_ALT, hide_scrollbar);
|
||||
|
||||
bind(context, key_f2, MDFR_NONE, toggle_mouse);
|
||||
bind(context, key_page_up, MDFR_CTRL, toggle_fullscreen);
|
||||
|
||||
end_map(context);
|
||||
|
||||
|
|
|
@ -2299,6 +2299,10 @@ CUSTOM_COMMAND_SIG(build_search_regular){
|
|||
// Common Settings Commands
|
||||
//
|
||||
|
||||
CUSTOM_COMMAND_SIG(toggle_fullscreen){
|
||||
app->toggle_fullscreen(app);
|
||||
}
|
||||
|
||||
CUSTOM_COMMAND_SIG(toggle_line_wrap){
|
||||
View_Summary view = app->get_active_view(app, AccessProtected);
|
||||
Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, AccessProtected);
|
||||
|
|
92
4ed.cpp
92
4ed.cpp
|
@ -11,30 +11,30 @@
|
|||
|
||||
// App Structs
|
||||
|
||||
enum App_State{
|
||||
typedef enum App_State{
|
||||
APP_STATE_EDIT,
|
||||
APP_STATE_RESIZING,
|
||||
// never below this
|
||||
APP_STATE_COUNT
|
||||
};
|
||||
} App_State;
|
||||
|
||||
struct App_State_Resizing{
|
||||
typedef struct App_State_Resizing{
|
||||
Panel_Divider *divider;
|
||||
f32 min, max;
|
||||
};
|
||||
} App_State_Resizing;
|
||||
|
||||
struct CLI_Process{
|
||||
typedef struct CLI_Process{
|
||||
CLI_Handles cli;
|
||||
Editing_File *out_file;
|
||||
b32 cursor_at_end;
|
||||
};
|
||||
} CLI_Process;
|
||||
|
||||
struct CLI_List{
|
||||
typedef struct CLI_List{
|
||||
CLI_Process *procs;
|
||||
i32 count, max;
|
||||
};
|
||||
} CLI_List;
|
||||
|
||||
struct Command_Data{
|
||||
typedef struct Command_Data{
|
||||
Models *models;
|
||||
struct App_Vars *vars;
|
||||
System_Functions *system;
|
||||
|
@ -45,9 +45,9 @@ struct Command_Data{
|
|||
|
||||
i32 screen_width, screen_height;
|
||||
Key_Event_Data key;
|
||||
};
|
||||
} Command_Data;
|
||||
|
||||
enum Input_Types{
|
||||
typedef enum Input_Types{
|
||||
Input_AnyKey,
|
||||
Input_Esc,
|
||||
Input_MouseMove,
|
||||
|
@ -55,20 +55,20 @@ enum Input_Types{
|
|||
Input_MouseRightButton,
|
||||
Input_MouseWheel,
|
||||
Input_Count
|
||||
};
|
||||
} Input_Types;
|
||||
|
||||
struct Consumption_Record{
|
||||
typedef struct Consumption_Record{
|
||||
b32 consumed;
|
||||
char consumer[32];
|
||||
};
|
||||
} Consumption_Record;
|
||||
|
||||
struct Available_Input{
|
||||
typedef struct Available_Input{
|
||||
Key_Summary *keys;
|
||||
Mouse_State *mouse;
|
||||
Consumption_Record records[Input_Count];
|
||||
};
|
||||
} Available_Input;
|
||||
|
||||
Available_Input
|
||||
internal Available_Input
|
||||
init_available_input(Key_Summary *keys, Mouse_State *mouse){
|
||||
Available_Input result = {0};
|
||||
result.keys = keys;
|
||||
|
@ -76,19 +76,19 @@ init_available_input(Key_Summary *keys, Mouse_State *mouse){
|
|||
return(result);
|
||||
}
|
||||
|
||||
Key_Summary
|
||||
internal Key_Summary
|
||||
direct_get_key_data(Available_Input *available){
|
||||
Key_Summary result = *available->keys;
|
||||
return(result);
|
||||
}
|
||||
|
||||
Mouse_State
|
||||
internal Mouse_State
|
||||
direct_get_mouse_state(Available_Input *available){
|
||||
Mouse_State result = *available->mouse;
|
||||
return(result);
|
||||
}
|
||||
|
||||
Key_Summary
|
||||
internal Key_Summary
|
||||
get_key_data(Available_Input *available){
|
||||
Key_Summary result = {0};
|
||||
|
||||
|
@ -113,7 +113,7 @@ get_key_data(Available_Input *available){
|
|||
return(result);
|
||||
}
|
||||
|
||||
Mouse_State
|
||||
internal Mouse_State
|
||||
get_mouse_state(Available_Input *available){
|
||||
Mouse_State mouse = *available->mouse;
|
||||
if (available->records[Input_MouseLeftButton].consumed){
|
||||
|
@ -135,7 +135,7 @@ get_mouse_state(Available_Input *available){
|
|||
return(mouse);
|
||||
}
|
||||
|
||||
void
|
||||
internal void
|
||||
consume_input(Available_Input *available, i32 input_type, char *consumer){
|
||||
Consumption_Record *record = &available->records[input_type];
|
||||
record->consumed = 1;
|
||||
|
@ -149,7 +149,7 @@ consume_input(Available_Input *available, i32 input_type, char *consumer){
|
|||
}
|
||||
}
|
||||
|
||||
struct App_Vars{
|
||||
typedef struct App_Vars{
|
||||
Models models;
|
||||
// TODO(allen): This wants to live in
|
||||
// models with everyone else but the order
|
||||
|
@ -164,16 +164,17 @@ struct App_Vars{
|
|||
Command_Data command_data;
|
||||
|
||||
Available_Input available_input;
|
||||
};
|
||||
} App_Vars;
|
||||
|
||||
enum Coroutine_Type{
|
||||
typedef enum Coroutine_Type{
|
||||
Co_View,
|
||||
Co_Command
|
||||
};
|
||||
struct App_Coroutine_State{
|
||||
} Coroutine_Type;
|
||||
typedef struct App_Coroutine_State{
|
||||
void *co;
|
||||
i32 type;
|
||||
};
|
||||
} App_Coroutine_State;
|
||||
|
||||
inline App_Coroutine_State
|
||||
get_state(Application_Links *app){
|
||||
App_Coroutine_State state = {0};
|
||||
|
@ -1086,6 +1087,7 @@ enum Command_Line_Action{
|
|||
CLAct_WindowSize,
|
||||
CLAct_WindowMaximize,
|
||||
CLAct_WindowPosition,
|
||||
CLAct_WindowFullscreen,
|
||||
CLAct_FontSize,
|
||||
CLAct_FontStopHinting,
|
||||
CLAct_Count
|
||||
|
@ -1109,20 +1111,21 @@ init_command_line_settings(App_Settings *settings, Plat_Settings *plat_settings,
|
|||
if (arg[0] == '-'){
|
||||
action = CLAct_Ignore;
|
||||
switch (arg[1]){
|
||||
case 'u': action = CLAct_UserFile; strict = false; break;
|
||||
case 'U': action = CLAct_UserFile; strict = true; break;
|
||||
case 'u': action = CLAct_UserFile; strict = false; break;
|
||||
case 'U': action = CLAct_UserFile; strict = true; break;
|
||||
|
||||
case 'd': action = CLAct_CustomDLL; strict = false;break;
|
||||
case 'D': action = CLAct_CustomDLL; strict = true; break;
|
||||
case 'd': action = CLAct_CustomDLL; strict = false; break;
|
||||
case 'D': action = CLAct_CustomDLL; strict = true; break;
|
||||
|
||||
case 'i': action = CLAct_InitialFilePosition; break;
|
||||
case 'i': action = CLAct_InitialFilePosition; break;
|
||||
|
||||
case 'w': action = CLAct_WindowSize; break;
|
||||
case 'W': action = CLAct_WindowMaximize; break;
|
||||
case 'p': action = CLAct_WindowPosition; break;
|
||||
case 'w': action = CLAct_WindowSize; break;
|
||||
case 'W': action = CLAct_WindowMaximize; break;
|
||||
case 'p': action = CLAct_WindowPosition; break;
|
||||
case 'F': action = CLAct_WindowFullscreen; break;
|
||||
|
||||
case 'f': action = CLAct_FontSize; break;
|
||||
case 'h': action = CLAct_FontStopHinting; --i; break;
|
||||
case 'f': action = CLAct_FontSize; break;
|
||||
case 'h': action = CLAct_FontStopHinting; --i; break;
|
||||
}
|
||||
}
|
||||
else if (arg[0] != 0){
|
||||
|
@ -1190,6 +1193,13 @@ init_command_line_settings(App_Settings *settings, Plat_Settings *plat_settings,
|
|||
action = CLAct_Nothing;
|
||||
}break;
|
||||
|
||||
case CLAct_WindowFullscreen:
|
||||
{
|
||||
--i;
|
||||
plat_settings->fullscreen_window = true;
|
||||
action = CLAct_Nothing;
|
||||
}break;
|
||||
|
||||
case CLAct_FontSize:
|
||||
{
|
||||
if (i < clparams.argc){
|
||||
|
@ -2466,6 +2476,12 @@ App_Step_Sig(app_step){
|
|||
"and if you load README.txt you'll find all the key combos there are.\n"
|
||||
"\n"
|
||||
"Newest features:\n"
|
||||
"-The commands for going to next error, previous error, etc now work\n"
|
||||
" on any buffer with jump locations including *search*\n"
|
||||
"-4coder now supports proper, borderless, fullscreen with the flag -F\n"
|
||||
" and fullscreen can be toggled with <control pageup>\n"
|
||||
"\n"
|
||||
"New in alpha 4.0.10:\n"
|
||||
"-<control F> list all locations of a string across all open buffers\n"
|
||||
"-Build now finds build.sh and Makefile on Linux\n"
|
||||
"-<alt n> goes to the next error if the *compilation* buffer is open\n"
|
||||
|
|
16
4ed.h
16
4ed.h
|
@ -52,27 +52,29 @@ get_single_key(Key_Summary *summary, i32 index){
|
|||
return key;
|
||||
}
|
||||
|
||||
struct Input_Summary{
|
||||
typedef struct Input_Summary{
|
||||
Mouse_State mouse;
|
||||
Key_Summary keys;
|
||||
f32 dt;
|
||||
};
|
||||
} Input_Summary;
|
||||
|
||||
struct Command_Line_Parameters{
|
||||
typedef struct Command_Line_Parameters{
|
||||
char **argv;
|
||||
int32_t argc;
|
||||
};
|
||||
} Command_Line_Parameters;
|
||||
|
||||
struct Plat_Settings{
|
||||
typedef struct Plat_Settings{
|
||||
char *custom_dll;
|
||||
b32 custom_dll_is_strict;
|
||||
b32 fullscreen_window;
|
||||
|
||||
i32 window_w, window_h;
|
||||
i32 window_x, window_y;
|
||||
b8 set_window_pos, set_window_size;
|
||||
b8 set_window_pos;
|
||||
b8 set_window_size;
|
||||
b8 maximize_window;
|
||||
b8 use_hinting;
|
||||
};
|
||||
} Plat_Settings;
|
||||
|
||||
#define App_Read_Command_Line_Sig(name) \
|
||||
i32 name(System_Functions *system, \
|
||||
|
|
|
@ -2039,6 +2039,7 @@ directories controlled on the custom side.
|
|||
return(hot->string.size);
|
||||
}
|
||||
|
||||
// TODO(allen): Replace this with an autogenerated file
|
||||
#define Memory_Allocate system->memory_allocate
|
||||
#define Memory_Set_Protection system->memory_set_protection
|
||||
#define Memory_Free system->memory_free
|
||||
|
@ -2048,6 +2049,9 @@ directories controlled on the custom side.
|
|||
#define Directory_CD system->directory_cd
|
||||
#define Show_Mouse_Cursor system->show_mouse_cursor
|
||||
|
||||
#define Toggle_Fullscreen system->toggle_fullscreen
|
||||
#define Is_Fullscreen system->is_fullscreen
|
||||
|
||||
API_EXPORT File_List
|
||||
Get_File_List(Application_Links *app, char *dir, int32_t len)/*
|
||||
DOC_PARAM(dir, This parameter specifies the directory whose files will be enumerated in the returned list; it need not be null terminated.)
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
#define DIRECTORY_CD_SIG(n) bool32 n(Application_Links *app, char *dir, int32_t *len, int32_t capacity, char *rel_path, int32_t rel_len)
|
||||
#define GET_4ED_PATH_SIG(n) bool32 n(Application_Links *app, char *out, int32_t capacity)
|
||||
#define SHOW_MOUSE_CURSOR_SIG(n) void n(Application_Links *app, Mouse_Cursor_Show_Type show)
|
||||
#define TOGGLE_FULLSCREEN_SIG(n) void n(Application_Links *app)
|
||||
#define IS_FULLSCREEN_SIG(n) bool32 n(Application_Links *app)
|
||||
typedef MEMORY_ALLOCATE_SIG(Memory_Allocate_Function);
|
||||
typedef MEMORY_SET_PROTECTION_SIG(Memory_Set_Protection_Function);
|
||||
typedef MEMORY_FREE_SIG(Memory_Free_Function);
|
||||
|
@ -12,3 +14,5 @@ typedef FILE_EXISTS_SIG(File_Exists_Function);
|
|||
typedef DIRECTORY_CD_SIG(Directory_CD_Function);
|
||||
typedef GET_4ED_PATH_SIG(Get_4ed_Path_Function);
|
||||
typedef SHOW_MOUSE_CURSOR_SIG(Show_Mouse_Cursor_Function);
|
||||
typedef TOGGLE_FULLSCREEN_SIG(Toggle_Fullscreen_Function);
|
||||
typedef IS_FULLSCREEN_SIG(Is_Fullscreen_Function);
|
||||
|
|
|
@ -235,6 +235,8 @@ struct System_Functions{
|
|||
Directory_CD_Function *directory_cd;
|
||||
Get_4ed_Path_Function *get_4ed_path;
|
||||
Show_Mouse_Cursor_Function *show_mouse_cursor;
|
||||
Toggle_Fullscreen_Function *toggle_fullscreen;
|
||||
Is_Fullscreen_Function *is_fullscreen;
|
||||
|
||||
// clipboard: 1
|
||||
System_Post_Clipboard *post_clipboard;
|
||||
|
|
2
TODO.txt
2
TODO.txt
|
@ -88,7 +88,7 @@
|
|||
; [] add to APIs
|
||||
;
|
||||
; [] tokens in the custom API
|
||||
; [] auto indent on the custom side
|
||||
; [] auto indent on the custom side
|
||||
; [] expose dirty flags
|
||||
; [] option to not open *messages* every startup
|
||||
; [] command for resizing panels
|
||||
|
|
6
build.c
6
build.c
|
@ -264,7 +264,7 @@ buildsuper(char *code_path, char *out_path, char *filename){
|
|||
|
||||
static void
|
||||
standard_build(char *cdir, uint32_t flags){
|
||||
#if 0
|
||||
#if 1
|
||||
{
|
||||
BEGIN_TIME_SECTION();
|
||||
build(OPTS, cdir, "fsm_table_generator.cpp",
|
||||
|
@ -279,7 +279,7 @@ standard_build(char *cdir, uint32_t flags){
|
|||
}
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
#if 1
|
||||
{
|
||||
BEGIN_TIME_SECTION();
|
||||
build(OPTS | DEBUG_INFO, cdir, "4ed_metagen.cpp",
|
||||
|
@ -305,7 +305,7 @@ standard_build(char *cdir, uint32_t flags){
|
|||
}
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
#if 1
|
||||
{
|
||||
BEGIN_TIME_SECTION();
|
||||
build(OPTS | INCLUDES | SHARED_CODE | flags, cdir, "4ed_app_target.cpp",
|
||||
|
|
153
win32_4ed.cpp
153
win32_4ed.cpp
|
@ -1106,6 +1106,80 @@ Sys_Get_Binary_Path_Sig(system_get_binary_path){
|
|||
return(result);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
NOTE(casey): This follows Raymond Chen's prescription
|
||||
for fullscreen toggling, see:
|
||||
http://blogs.msdn.com/b/oldnewthing/archive/2010/04/12/9994016.aspx
|
||||
*/
|
||||
|
||||
// TODO(allen): Move these into win32vars
|
||||
static b32 full_screen = 0;
|
||||
static b32 do_toggle = 0;
|
||||
static WINDOWPLACEMENT GlobalWindowPosition = {sizeof(GlobalWindowPosition)};
|
||||
|
||||
internal void
|
||||
Win32ToggleFullscreen(void){
|
||||
HWND Window = win32vars.window_handle;
|
||||
LONG_PTR Style = GetWindowLongPtr(Window, GWL_STYLE);
|
||||
if (Style & WS_OVERLAPPEDWINDOW){
|
||||
MONITORINFO MonitorInfo = {sizeof(MonitorInfo)};
|
||||
if(GetWindowPlacement(Window, &GlobalWindowPosition) &&
|
||||
GetMonitorInfo(MonitorFromWindow(Window, MONITOR_DEFAULTTOPRIMARY), &MonitorInfo))
|
||||
{
|
||||
SetWindowLongPtr(Window, GWL_STYLE, Style & ~WS_OVERLAPPEDWINDOW);
|
||||
SetWindowPos(Window, HWND_TOP,
|
||||
MonitorInfo.rcMonitor.left, MonitorInfo.rcMonitor.top,
|
||||
MonitorInfo.rcMonitor.right - MonitorInfo.rcMonitor.left,
|
||||
MonitorInfo.rcMonitor.bottom - MonitorInfo.rcMonitor.top,
|
||||
SWP_NOOWNERZORDER | SWP_FRAMECHANGED);
|
||||
full_screen = 1;
|
||||
}
|
||||
}
|
||||
else{
|
||||
SetWindowLongPtr(Window, GWL_STYLE, Style | WS_OVERLAPPEDWINDOW);
|
||||
SetWindowPlacement(Window, &GlobalWindowPosition);
|
||||
SetWindowPos(Window, 0, 0, 0, 0, 0,
|
||||
SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER |
|
||||
SWP_NOOWNERZORDER | SWP_FRAMECHANGED);
|
||||
full_screen = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
NOTE(allen):
|
||||
This is the crazy hacky nonsense I came up with to get alt-tab
|
||||
working in full screen mode. It puts the window back into
|
||||
bordered mode when the alt-tabbing begins. When the window regains
|
||||
focus it is automatically refullscreened.
|
||||
*/
|
||||
|
||||
internal void
|
||||
Win32FixFullscreenLoseFocus(b32 lose_focus){
|
||||
if (full_screen){
|
||||
|
||||
HWND Window = win32vars.window_handle;
|
||||
LONG_PTR Style = GetWindowLongPtr(Window, GWL_STYLE);
|
||||
|
||||
MONITORINFO MonitorInfo = {sizeof(MonitorInfo)};
|
||||
if(GetMonitorInfo(MonitorFromWindow(Window, MONITOR_DEFAULTTOPRIMARY), &MonitorInfo))
|
||||
{
|
||||
if (lose_focus){
|
||||
SetWindowLongPtr(Window, GWL_STYLE, Style | WS_OVERLAPPEDWINDOW);
|
||||
}
|
||||
else{
|
||||
SetWindowLongPtr(Window, GWL_STYLE, Style & ~WS_OVERLAPPEDWINDOW);
|
||||
}
|
||||
|
||||
SetWindowPos(Window, HWND_TOP,
|
||||
MonitorInfo.rcMonitor.left, MonitorInfo.rcMonitor.top,
|
||||
MonitorInfo.rcMonitor.right - MonitorInfo.rcMonitor.left,
|
||||
MonitorInfo.rcMonitor.bottom - MonitorInfo.rcMonitor.top,
|
||||
SWP_NOOWNERZORDER | SWP_FRAMECHANGED);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#include "win32_api_impl.cpp"
|
||||
|
||||
//
|
||||
|
@ -1407,11 +1481,17 @@ Win32LoadSystemCode(){
|
|||
win32vars.system.now_time = system_now_time;
|
||||
|
||||
win32vars.system.memory_allocate = Memory_Allocate;
|
||||
win32vars.system.memory_set_protection = Memory_Set_Protection;
|
||||
win32vars.system.memory_free = Memory_Free;
|
||||
|
||||
win32vars.system.file_exists = File_Exists;
|
||||
win32vars.system.directory_cd = Directory_CD;
|
||||
win32vars.system.get_4ed_path = Get_4ed_Path;
|
||||
win32vars.system.show_mouse_cursor = Show_Mouse_Cursor;
|
||||
|
||||
win32vars.system.toggle_fullscreen = Toggle_Fullscreen;
|
||||
win32vars.system.is_fullscreen = Is_Fullscreen;
|
||||
|
||||
win32vars.system.post_clipboard = system_post_clipboard;
|
||||
|
||||
win32vars.system.create_coroutine = system_create_coroutine;
|
||||
|
@ -1511,69 +1591,6 @@ Win32Resize(i32 width, i32 height){
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
NOTE(casey): This follows Raymond Chen's prescription
|
||||
for fullscreen toggling, see:
|
||||
http://blogs.msdn.com/b/oldnewthing/archive/2010/04/12/9994016.aspx
|
||||
*/
|
||||
|
||||
static b32 full_screen = 0;
|
||||
static WINDOWPLACEMENT GlobalWindowPosition = {sizeof(GlobalWindowPosition)};
|
||||
|
||||
internal void
|
||||
Win32ToggleFullscreen(void){
|
||||
HWND Window = win32vars.window_handle;
|
||||
LONG_PTR Style = GetWindowLongPtr(Window, GWL_STYLE);
|
||||
if (Style & WS_OVERLAPPEDWINDOW){
|
||||
MONITORINFO MonitorInfo = {sizeof(MonitorInfo)};
|
||||
if(GetWindowPlacement(Window, &GlobalWindowPosition) &&
|
||||
GetMonitorInfo(MonitorFromWindow(Window, MONITOR_DEFAULTTOPRIMARY), &MonitorInfo))
|
||||
{
|
||||
SetWindowLongPtr(Window, GWL_STYLE, Style & ~WS_OVERLAPPEDWINDOW);
|
||||
SetWindowPos(Window, HWND_TOP,
|
||||
MonitorInfo.rcMonitor.left, MonitorInfo.rcMonitor.top,
|
||||
MonitorInfo.rcMonitor.right - MonitorInfo.rcMonitor.left,
|
||||
MonitorInfo.rcMonitor.bottom - MonitorInfo.rcMonitor.top,
|
||||
SWP_NOOWNERZORDER | SWP_FRAMECHANGED);
|
||||
full_screen = 1;
|
||||
}
|
||||
}
|
||||
else{
|
||||
SetWindowLongPtr(Window, GWL_STYLE, Style | WS_OVERLAPPEDWINDOW);
|
||||
SetWindowPlacement(Window, &GlobalWindowPosition);
|
||||
SetWindowPos(Window, 0, 0, 0, 0, 0,
|
||||
SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER |
|
||||
SWP_NOOWNERZORDER | SWP_FRAMECHANGED);
|
||||
full_screen = 0;
|
||||
}
|
||||
}
|
||||
|
||||
internal void
|
||||
Win32FixFullscreenLoseFocus(b32 lose_focus){
|
||||
if (full_screen){
|
||||
|
||||
HWND Window = win32vars.window_handle;
|
||||
LONG_PTR Style = GetWindowLongPtr(Window, GWL_STYLE);
|
||||
|
||||
MONITORINFO MonitorInfo = {sizeof(MonitorInfo)};
|
||||
if(GetMonitorInfo(MonitorFromWindow(Window, MONITOR_DEFAULTTOPRIMARY), &MonitorInfo))
|
||||
{
|
||||
if (lose_focus){
|
||||
SetWindowLongPtr(Window, GWL_STYLE, Style | WS_OVERLAPPEDWINDOW);
|
||||
}
|
||||
else{
|
||||
SetWindowLongPtr(Window, GWL_STYLE, Style & ~WS_OVERLAPPEDWINDOW);
|
||||
}
|
||||
|
||||
SetWindowPos(Window, HWND_TOP,
|
||||
MonitorInfo.rcMonitor.left, MonitorInfo.rcMonitor.top,
|
||||
MonitorInfo.rcMonitor.right - MonitorInfo.rcMonitor.left,
|
||||
MonitorInfo.rcMonitor.bottom - MonitorInfo.rcMonitor.top,
|
||||
SWP_NOOWNERZORDER | SWP_FRAMECHANGED);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal void
|
||||
Win32SetCursorFromUpdate(Application_Mouse_Cursor cursor){
|
||||
switch (cursor){
|
||||
|
@ -2188,7 +2205,7 @@ WinMain(HINSTANCE hInstance,
|
|||
}
|
||||
|
||||
i32 window_style = WS_OVERLAPPEDWINDOW;
|
||||
if (win32vars.settings.maximize_window){
|
||||
if (!win32vars.settings.fullscreen_window && win32vars.settings.maximize_window){
|
||||
window_style |= WS_MAXIMIZE;
|
||||
}
|
||||
|
||||
|
@ -2324,6 +2341,9 @@ WinMain(HINSTANCE hInstance,
|
|||
win32vars.first = 1;
|
||||
timeBeginPeriod(1);
|
||||
|
||||
if (win32vars.settings.fullscreen_window){
|
||||
Win32ToggleFullscreen();
|
||||
}
|
||||
|
||||
SetForegroundWindow(win32vars.window_handle);
|
||||
SetActiveWindow(win32vars.window_handle);
|
||||
|
@ -2445,6 +2465,11 @@ WinMain(HINSTANCE hInstance,
|
|||
keep_playing = 0;
|
||||
}
|
||||
|
||||
if (do_toggle){
|
||||
Win32ToggleFullscreen();
|
||||
do_toggle = 0;
|
||||
}
|
||||
|
||||
Win32SetCursorFromUpdate(result.mouse_cursor_type);
|
||||
win32vars.lctrl_lalt_is_altgr = result.lctrl_lalt_is_altgr;
|
||||
|
||||
|
|
|
@ -176,5 +176,26 @@ DOC_SEE(Mouse_Cursor_Show_Type)
|
|||
}
|
||||
}
|
||||
|
||||
API_EXPORT void
|
||||
Toggle_Fullscreen(Application_Links *app)/*
|
||||
*/{
|
||||
/* NOTE(allen): Don't actually change window size now!
|
||||
Tell the platform layer to do the toggle (or to cancel the toggle)
|
||||
later when the app.step function isn't running. If the size changes
|
||||
mid step, it messes up the rendering rules and stuff. */
|
||||
do_toggle = !do_toggle;
|
||||
}
|
||||
|
||||
API_EXPORT bool32
|
||||
Is_Fullscreen(Application_Links *app)/*
|
||||
*/{
|
||||
/* NOTE(allen): This is a fancy way of say 'full_screen XOR do_toggle'
|
||||
This way this function can always report the state the fullscreen
|
||||
will have when the next frame runs, given the number of toggles
|
||||
that have occurred this frame and the original value. */
|
||||
bool32 result = (full_screen + do_toggle) & 1;
|
||||
return(result);
|
||||
}
|
||||
|
||||
// BOTTOM
|
||||
|
||||
|
|
Loading…
Reference in New Issue