fixed issue with windows full screen (may want to revist in the future though)

This commit is contained in:
Allen Webster 2016-09-02 11:58:04 -04:00
parent f7afb72796
commit c134f04dde
10 changed files with 108 additions and 72 deletions

View File

@ -1195,6 +1195,7 @@ Coming Soon</i><div>
<li><a href='#set_last_folder_sc_str_doc'>set_last_folder_sc</a></li>
<li><a href='#set_last_folder_ss_str_doc'>set_last_folder_ss</a></li>
<li><a href='#file_extension_str_doc'>file_extension</a></li>
<li><a href='#remove_extension_str_doc'>remove_extension</a></li>
<li><a href='#remove_last_folder_str_doc'>remove_last_folder</a></li>
<li><a href='#string_set_match_str_doc'>string_set_match</a></li>
</ul>
@ -2097,14 +2098,21 @@ String file_extension(
<div style='margin-left: 4mm;'>String str<br></div>)
</div>
<div style='margin-top: 3mm; margin-bottom: 3mm; color: #309030;'><b><i>Description</i></b></div><div style='margin-left: 5mm; margin-right: 5mm;'>This call returns a substring containing only the file extension of the provided filename.</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='#substr_doc'>substr</a></div></div><hr>
<div id='remove_last_folder_str_doc'><h4>&sect;4.3.105: remove_last_folder</h4>
<div id='remove_extension_str_doc'><h4>&sect;4.3.105: remove_extension</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;'>
fstr_bool remove_extension(
<div style='margin-left: 4mm;'>String *str<br></div>)
</div>
<div style='margin-top: 3mm; margin-bottom: 3mm; color: #309030;'><b><i>Description</i></b></div><div style='margin-left: 5mm; margin-right: 5mm;'>This call attemps to delete a file extension off the end of a filename.
This call returns non-zero on success.</div></div><hr>
<div id='remove_last_folder_str_doc'><h4>&sect;4.3.106: remove_last_folder</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;'>
fstr_bool remove_last_folder(
<div style='margin-left: 4mm;'>String *str<br></div>)
</div>
<div style='margin-top: 3mm; margin-bottom: 3mm; color: #309030;'><b><i>Description</i></b></div><div style='margin-left: 5mm; margin-right: 5mm;'>This call attemps to delete a folder or filename off the end of a path string.
This call returns non-zero on success.</div></div><hr>
<div id='string_set_match_str_doc'><h4>&sect;4.3.106: string_set_match</h4>
<div id='string_set_match_str_doc'><h4>&sect;4.3.107: string_set_match</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;'>
fstr_bool string_set_match(
<div style='margin-left: 4mm;'>String *str_set,<br>int32_t count,<br>String str,<br>int32_t *match_index<br></div>)

View File

@ -440,10 +440,10 @@ CUSTOM_COMMAND_SIG(goto_first_jump){
end_temp_memory(temp);
}
#define goto_next_error goto_next_jump
#define goto_prev_error goto_prev_jump
#define goto_next_error_no_skips goto_next_jump_no_skips
#define goto_first_error goto_first_jump
#define goto_next_error goto_next_jump
#define goto_prev_error goto_prev_jump
#define goto_next_error_no_skips goto_next_jump_no_skips
#define goto_first_error goto_first_jump
#endif

View File

@ -157,6 +157,7 @@ FSTRING_INLINE String path_of_directory(String dir);
FSTRING_LINK fstr_bool set_last_folder_sc(String *dir, char *folder_name, char slash);
FSTRING_LINK fstr_bool set_last_folder_ss(String *dir, String folder_name, char slash);
FSTRING_LINK String file_extension(String str);
FSTRING_LINK fstr_bool remove_extension(String *str);
FSTRING_LINK fstr_bool remove_last_folder(String *str);
FSTRING_LINK fstr_bool string_set_match(String *str_set, int32_t count, String str, int32_t *match_index);
@ -1854,6 +1855,22 @@ file_extension(String str){
}
#endif
#if defined(FSTRING_IMPLEMENTATION)
FSTRING_LINK fstr_bool
remove_extension(String *str){
fstr_bool result = 0;
int32_t i;
for (i = str->size - 1; i >= 0; --i){
if (str->str[i] == '.') break;
}
if (i >= 0){
result = 1;
str->size = i + 1;
}
return(result);
}
#endif
#if defined(FSTRING_IMPLEMENTATION)
FSTRING_LINK fstr_bool
remove_last_folder(String *str){

11
4ed.cpp
View File

@ -1088,6 +1088,7 @@ enum Command_Line_Action{
CLAct_WindowMaximize,
CLAct_WindowPosition,
CLAct_WindowFullscreen,
CLAct_WindowStreamMode,
CLAct_FontSize,
CLAct_FontStopHinting,
CLAct_Count
@ -1123,6 +1124,7 @@ init_command_line_settings(App_Settings *settings, Plat_Settings *plat_settings,
case 'W': action = CLAct_WindowMaximize; break;
case 'p': action = CLAct_WindowPosition; break;
case 'F': action = CLAct_WindowFullscreen; break;
case 'S': action = CLAct_WindowStreamMode; break;
case 'f': action = CLAct_FontSize; break;
case 'h': action = CLAct_FontStopHinting; --i; break;
@ -1197,6 +1199,14 @@ init_command_line_settings(App_Settings *settings, Plat_Settings *plat_settings,
{
--i;
plat_settings->fullscreen_window = true;
plat_settings->stream_mode = true;
action = CLAct_Nothing;
}break;
case CLAct_WindowStreamMode:
{
--i;
plat_settings->stream_mode = true;
action = CLAct_Nothing;
}break;
@ -2481,6 +2491,7 @@ App_Step_Sig(app_step){
"-4coder now supports proper, borderless, fullscreen with the flag -F\n"
" and fullscreen can be toggled with <control pageup>.\n"
" (This sometimes causes artifacts on the Windows task bar)\n"
"-<alt f4> to exit\n"
"\n"
"New in alpha 4.0.10:\n"
"-<control F> list all locations of a string across all open buffers\n"

1
4ed.h
View File

@ -67,6 +67,7 @@ typedef struct Plat_Settings{
char *custom_dll;
b32 custom_dll_is_strict;
b32 fullscreen_window;
b32 stream_mode;
i32 window_w, window_h;
i32 window_x, window_y;

View File

@ -164,7 +164,7 @@ DOC_SEE(Command_ID)
result = true;
}
else{
app->print_message(app, literal("CUSTOM WARNING: An invalid Command_ID was passed to exec_command."));
app->print_message(app, literal("WARNING: An invalid Command_ID was passed to exec_command."));
}
return(result);

View File

@ -294,7 +294,7 @@ standard_build(char *cdir, uint32_t flags){
}
#endif
#if 1
#if 0
{
BEGIN_TIME_SECTION();
//buildsuper(cdir, BUILD_DIR, "../code/4coder_default_bindings.cpp");

View File

@ -1580,6 +1580,22 @@ DOC_SEE(substr) */{
return(make_string(str.str+i, str.size-i));
}
FSTRING_LINK fstr_bool
remove_extension(String *str)/*
DOC(This call attemps to delete a file extension off the end of a filename.
This call returns non-zero on success.) */{
fstr_bool result = 0;
int32_t i;
for (i = str->size - 1; i >= 0; --i){
if (str->str[i] == '.') break;
}
if (i >= 0){
result = 1;
str->size = i + 1;
}
return(result);
}
FSTRING_LINK fstr_bool
remove_last_folder(String *str)/*
DOC(This call attemps to delete a folder or filename off the end of a path string.

View File

@ -45,7 +45,7 @@ struct Custom_API{
typedef void Custom_Command_Function;
#include "4coder_types.h"
struct Application_Links;
# include "4ed_os_custom_api.h"
# include "4coder_custom_api.h"
//# include "4coder_custom.h"
#else
@ -1141,40 +1141,6 @@ Win32ToggleFullscreen(void){
}
}
/*
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 (win32vars.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"
//
@ -1871,10 +1837,6 @@ Win32Callback(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam){
win32vars.input_chunk.pers.mouse_r = 0;
win32vars.input_chunk.pers.controls = control_keys_zero();
if (uMsg == WM_SETFOCUS){
Win32FixFullscreenLoseFocus(false);
}
}break;
case WM_SIZE:
@ -1910,7 +1872,6 @@ Win32Callback(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam){
case WM_CANCELMODE:
{
Win32FixFullscreenLoseFocus(true);
result = DefWindowProc(hwnd, uMsg, wParam, lParam);
}break;
@ -2234,10 +2195,18 @@ WinMain(HINSTANCE hInstance,
GetClientRect(win32vars.window_handle, &window_rect);
DWORD pfd_flags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL;
// NOTE(allen): This is probably not an issue on linux and
// does not need to be ported.
if (!win32vars.settings.stream_mode){
pfd_flags |= PFD_DOUBLEBUFFER;
}
static PIXELFORMATDESCRIPTOR pfd = {
sizeof(PIXELFORMATDESCRIPTOR),
1,
PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER,
pfd_flags,
PFD_TYPE_RGBA,
32,
0, 0, 0, 0, 0, 0,
@ -2356,32 +2325,39 @@ WinMain(HINSTANCE hInstance,
// Looks like we can ReadFile with a size of zero
// in an IOCP for this effect.
system_release_lock(FRAME_LOCK);
// NOTE(allen): When we're in stream mode we don't have
// double buffering so we need to move ahead and call
// the first step right away so it will render into the
// window. With double buffering this is not an issue
// for reasons I cannot at all comprehend.
if (!(win32vars.first && win32vars.settings.stream_mode)){
system_release_lock(FRAME_LOCK);
if (win32vars.running_cli == 0){
win32vars.got_useful_event = 0;
for (;win32vars.got_useful_event == 0;){
if (GetMessage(&msg, 0, 0, 0)){
if (msg.message == WM_QUIT){
keep_playing = 0;
}else{
TranslateMessage(&msg);
DispatchMessage(&msg);
if (win32vars.running_cli == 0){
win32vars.got_useful_event = 0;
for (;win32vars.got_useful_event == 0;){
if (GetMessage(&msg, 0, 0, 0)){
if (msg.message == WM_QUIT){
keep_playing = 0;
}else{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
}
}
}
while (PeekMessage(&msg, 0, 0, 0, 1)){
if (msg.message == WM_QUIT){
keep_playing = 0;
}else{
TranslateMessage(&msg);
DispatchMessage(&msg);
while (PeekMessage(&msg, 0, 0, 0, 1)){
if (msg.message == WM_QUIT){
keep_playing = 0;
}else{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
}
system_acquire_lock(FRAME_LOCK);
system_acquire_lock(FRAME_LOCK);
}
POINT mouse_point;
if (GetCursorPos(&mouse_point) &&

View File

@ -182,12 +182,19 @@ Toggle_Fullscreen(Application_Links *app){
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. */
win32vars.do_toggle = !win32vars.do_toggle;
// NOTE(allen): On windows we must be in stream mode to go fullscreen.
if (win32vars.settings.stream_mode){
win32vars.do_toggle = !win32vars.do_toggle;
}
else{
app->print_message(app, literal("WARNING: Cannot go full screen unless 4coder is in stream mode\n Use the flag -S to put 4coder in stream mode.\n"));
}
}
API_EXPORT bool32
Is_Fullscreen(Application_Links *app){
/* NOTE(allen): This is a fancy way of say 'full_screen XOR do_toggle'
/* NOTE(allen): This is a fancy way to 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. */