@@ -1836,188 +1836,6 @@ VALUE shoes_native_to_s(VALUE text) {
1836
1836
return text ;
1837
1837
}
1838
1838
1839
-
1840
-
1841
- #ifdef SHOES_GTK_WIN32
1842
- // hat tip: https://justcheckingonall.wordpress.com/2008/08/29/console-window-win32-app/
1843
- #include <stdio.h>
1844
- #include <io.h>
1845
- #include <fcntl.h>
1846
-
1847
-
1848
- // called from main.c(skel) on Windows - works fine
1849
- static FILE * shoes_console_out = NULL ;
1850
- static FILE * shoes_console_in = NULL ;
1851
-
1852
- int shoes_win32_console () {
1853
-
1854
- if (AllocConsole () == 0 ) {
1855
- // cshoes.exe can get here
1856
- printf ("Already have console\n" );
1857
- return 0 ;
1858
- }
1859
-
1860
- HANDLE handle_out = GetStdHandle (STD_OUTPUT_HANDLE );
1861
- int hCrt = _open_osfhandle ((long ) handle_out , _O_TEXT );
1862
- FILE * hf_out = _fdopen (hCrt , "w" );
1863
- setvbuf (hf_out , NULL , _IONBF , 1 );
1864
- * stdout = * hf_out ;
1865
- HANDLE handle_in = GetStdHandle (STD_INPUT_HANDLE );
1866
- hCrt = _open_osfhandle ((long ) handle_in , _O_TEXT );
1867
- FILE * hf_in = _fdopen (hCrt , "r" );
1868
- setvbuf (hf_in , NULL , _IONBF , 128 );
1869
- * stdin = * hf_in ;
1870
-
1871
- //* stash handles
1872
- shoes_console_out = hf_out ;
1873
- shoes_console_in = hf_in ;
1874
- return 1 ;
1875
- }
1876
-
1877
- // Called by Shoes after ruby/gtk/shoes is initialized and running
1878
- int shoes_native_terminal () {
1879
- // has a console been setup by --console flag?
1880
- if (shoes_console_out == NULL ) {
1881
- if (shoes_win32_console () == 0 ) { // cshoes.exe can do this
1882
- return 1 ;
1883
- }
1884
- }
1885
- // convert the (cached) FILE * for what ruby wants for fd[0], [1]...
1886
- if (dup2 (_fileno (shoes_console_out ), 1 ) == -1 ) {
1887
- printf ("failed dup2 of stdout\n" );
1888
- }
1889
- if (dup2 (_fileno (shoes_console_out ), 2 ) == -1 ) {
1890
- printf ("failed dup2 of stderr\n" );
1891
- }
1892
- if (dup2 (_fileno (shoes_console_in ), 0 ) == -1 ) {
1893
- printf ("failed dup2 of stdin\n" );
1894
- }
1895
- printf ("created win32 console\n" );
1896
- return 1 ;
1897
- }
1898
-
1899
- // For bug #428
1900
- int shoes_win10_gtk3_22_check () {
1901
- if (gtk_get_minor_version () < 22 )
1902
- return 0 ;
1903
- // borrowed from
1904
- // https://stackoverflow.com/questions/32115255/c-how-to-detect-windows-10
1905
- int ret = 0 ;
1906
- NTSTATUS (WINAPI * RtlGetVersion )(LPOSVERSIONINFOEXW );
1907
- OSVERSIONINFOEXW osInfo ;
1908
-
1909
- * (FARPROC * )& RtlGetVersion = GetProcAddress (GetModuleHandleA ("ntdll" ), "RtlGetVersion" );
1910
-
1911
- if (NULL != RtlGetVersion )
1912
- {
1913
- osInfo .dwOSVersionInfoSize = sizeof (osInfo );
1914
- RtlGetVersion (& osInfo );
1915
- ret = osInfo .dwMajorVersion ;
1916
- }
1917
- //printf("windows version %i\n", ret); // win 7 returns '6' go figure
1918
- return ret == 10 ;
1919
- }
1920
- #else
1921
- /*
1922
- int shoes_native_console(char *app_path)
1923
- {
1924
- //printf("init gtk console\n");
1925
- shoes_native_app_console(app_path);
1926
- printf("gtk\010k\t console \t\tcreated\n"); //test \b \t in string
1927
- return 1;
1928
- }
1929
- */
1930
- #endif
1931
-
1932
- /*
1933
- * ------- monitor handling --------
1934
- * As usual, gtk 3.22 'fixes' things with deprecations.
1935
- *
1936
- * Currrently using pre 3.22 API.
1937
- * Screen width is the sum of all monitors. Height is the max of all
1938
- * monitors. Do not address monitors just set x.
1939
- */
1940
- int shoes_native_monitor_default () {
1941
- GdkScreen * screen ;
1942
- GdkDisplay * display ;
1943
- display = gdk_display_get_default ();
1944
- screen = gdk_display_get_default_screen (display );
1945
- int mon ;
1946
- mon = gdk_screen_get_primary_monitor (screen );
1947
- return mon ;
1948
- }
1949
-
1950
- void shoes_native_monitor_geometry (int idx , shoes_monitor_t * geo ) {
1951
-
1952
- GdkScreen * screen ;
1953
- screen = gdk_screen_get_default ();
1954
- GdkRectangle r ;
1955
- // workarea approximates visibleFrame on OSX
1956
- //gdk_screen_get_monitor_geometry(screen, idx, &r);
1957
- gdk_screen_get_monitor_workarea (screen , idx , & r );
1958
- geo -> x = r .x ;
1959
- geo -> y = r .y ;
1960
- geo -> width = r .width ;
1961
- geo -> height = r .height ;
1962
- }
1963
-
1964
- int shoes_native_monitor_count () {
1965
- GdkScreen * screen ;
1966
- screen = gdk_screen_get_default ();
1967
- int cnt = 0 ;
1968
- cnt = gdk_screen_get_n_monitors (screen );
1969
- return cnt ;
1970
- }
1971
-
1972
- // Sets/moves the window onto monitor
1973
- void shoes_native_monitor_set (shoes_app * app ) {
1974
- GtkWindow * window = (GtkWindow * )app -> os .window ;
1975
- GdkDisplay * display ;
1976
- GdkScreen * screen ;
1977
- screen = gdk_screen_get_default ();
1978
- display = gdk_screen_get_display (screen );
1979
- // sanity checks
1980
- int cnt = 0 ;
1981
- cnt = gdk_screen_get_n_monitors (screen );
1982
- int realmon ;
1983
- if (app -> monitor < cnt && app -> monitor >= 0 )
1984
- realmon = app -> monitor ;
1985
- else {
1986
- realmon = 0 ;
1987
- }
1988
- /*
1989
- fprintf(stderr, "Screen w: %d x h: %d\n", gdk_screen_get_width(screen),
1990
- gdk_screen_get_height(screen));
1991
- fprintf(stderr, "Switch to monitor %d of %d\n", realmon, cnt);
1992
- */
1993
- GdkRectangle r ;
1994
- gdk_screen_get_monitor_geometry (screen , realmon , & r );
1995
- gtk_window_move (window , app -> x + r .x , app -> y );
1996
- // TODO: do a better job of positioning. Worth the effort?
1997
- }
1998
-
1999
- // returns the Shoes monitor number that the window is on
2000
- int shoes_native_monitor_get (shoes_app * app ) {
2001
- GtkWindow * window = (GtkWindow * )app -> os .window ;
2002
- GdkDisplay * display ;
2003
- GdkScreen * screen ;
2004
- screen = gtk_window_get_screen (window );
2005
- // determine which monitor that is. Remember: Gtk screen holds Gtk monitors
2006
- int x , y , cnt , i ;
2007
- gtk_window_get_position (window , & x , & y );
2008
- cnt = gdk_screen_get_n_monitors (screen );
2009
- for (i = 0 ; i < cnt ; i ++ ) {
2010
- GdkRectangle r ;
2011
- gdk_screen_get_monitor_geometry (screen , i , & r );
2012
- if ((x >= r .x ) && (x <= (r .x + r .width )) && (y >= r .y ) && (y <= (r .y + r .height ))) {
2013
- return i ;
2014
- }
2015
- }
2016
- // should never get here, but if it does:
2017
- return gdk_screen_get_primary_monitor (screen );
2018
- }
2019
-
2020
-
2021
1839
/* ------- have_menu == true and sizing ---------- */
2022
1840
2023
1841
// hack for windows (gtk < 3.12) - the 65 below is the taskbar height. Hack!!
@@ -2186,8 +2004,8 @@ gboolean shoes_app_gtk_configure_menu(GtkWidget *widget, GdkEvent *evt, gpointer
2186
2004
}
2187
2005
} else {
2188
2006
#ifdef SZBUG
2189
- printf (stderr , "shoes_app_gtk_configure_menu: dragged %d, %d, %d, %d\\n" ,
2190
- evt -> configure .x , evt -> configure .y , evt -> configure .width , evt -> configure .height );
2007
+ fprintf (stderr , "shoes_app_gtk_configure_menu: dragged %d, %d, %d, %d\\n" ,
2008
+ evt -> configure .x , evt -> configure .y , evt -> configure .width , evt -> configure .height );
2191
2009
GtkWidget * content = app -> os .shoes_window ;
2192
2010
#endif
2193
2011
}
0 commit comments