From 97570dea24733071cfacef0c68af38f06732fcd0 Mon Sep 17 00:00:00 2001 From: tslediter Date: Thu, 21 Dec 2023 16:12:54 +0800 Subject: [PATCH] gtk MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit y浼樺寲 --- designer/udesignerproject.tsf | 4 + designer/utslvcldesigner.tsf | 17 +- designer/utslvcldpropertytypes.tsf | 11 +- funcext/tvclib/tslvcl.tsf | 2 + funcext/tvclib/ugtkinterface.tsf | 635 +++++++++++++++++++++-------- 5 files changed, 488 insertions(+), 181 deletions(-) diff --git a/designer/udesignerproject.tsf b/designer/udesignerproject.tsf index 0182ec0..a1838ab 100644 --- a/designer/udesignerproject.tsf +++ b/designer/udesignerproject.tsf @@ -1080,11 +1080,15 @@ type TProjectView = class(TVCForm) // global g_orig_lib_path; sdir := array(p); idx := 1; + hdirs := array(p:true); if ifstring(g_orig_lib_path) then begin for i,v in str2array(g_orig_lib_path,";") do begin + tm := trim(v); + if hdirs[tm] then continue; + hdirs[tm] := true; if tm then begin sdir[idx++] := tm; diff --git a/designer/utslvcldesigner.tsf b/designer/utslvcldesigner.tsf index 06803f5..0862c46 100644 --- a/designer/utslvcldesigner.tsf +++ b/designer/utslvcldesigner.tsf @@ -2052,12 +2052,27 @@ function delexttypeclasscomp(n); begin class(TDComponent).unregestorclassitemsext(n); end +function Getfuncextdir(); +begin + tsl := SysExecName(); + ios := ioFileseparator(); + for i := length(tsl)-1 downto 2 do + begin + vi := tsl[i]; + if vi=ios then + begin + tsl[i+1:length(tsl)]:= "funcext"; + break; + end + end + return tsl; +end function staticInit(); begin global g_orig_lib_path; np := getdesignerpath()+"dcmps"+ioFileseparator(); CreateDirWithFileName(np+"1.txt"); - g_orig_lib_path := tsl_getlibpath_(); + g_orig_lib_path := tsl_getlibpath_()+";"+Getfuncextdir(); tsl_setlibpath_( np+";"+g_orig_lib_path); ini := static getdesginerini(); //class(TDSocketServer),class(TDSocketClient), diff --git a/designer/utslvcldpropertytypes.tsf b/designer/utslvcldpropertytypes.tsf index 2584ac2..a6ce80f 100644 --- a/designer/utslvcldpropertytypes.tsf +++ b/designer/utslvcldpropertytypes.tsf @@ -1543,7 +1543,7 @@ type TGridCellNaturalEdit = class(TGridPropertyRender,TPropertyNatural) FEdit.parent := FGrid; FEdit.OnChanged := thisfunction(Ched); end - FEdit.SetBoundsRect(FGrid.clienttoscreen(rec[0],rec[1]) union FGrid.clienttoscreen(rec[2],rec[3])); + FEdit.SetBoundsRect(rec);//FEdit.SetBoundsRect(FGrid.clienttoscreen(rec[0],rec[1]) union FGrid.clienttoscreen(rec[2],rec[3])); FEdit.text := numbertotext(d["value"]); FEdit.parent := grid; FEdit.SetFocus(); @@ -1683,12 +1683,15 @@ type TPopEditCtrl = class(TCustomControl) function create(AOwner);override; begin inherited; - WsPopUp := true; + //WsPopUp := true; WsDlgModalFrame := false; FEdit := new tedit(self); width := FEdit.Width+2; height := FEdit.Height +2; FEdit.align := alClient; + FEdit.onkillfocus := function(o,e)begin + self.visible := false; + end FEdit.parent := self; FEdit.OnKeyPress := function(o,e)begin CallDataFunction(FOnKeyPress,self,e); @@ -3257,6 +3260,7 @@ type TMultiSelectCell = class(TGridCellEditWithButton) FPanel.wspopup := true; FPanel.SetListData(SelPalRange()); FPanel.Onokclick := thisfunction(SelChanged); + FPanel.parent := Owner; end end function SelPalRange();virtual; @@ -3285,7 +3289,7 @@ type TMultiSelectCell = class(TGridCellEditWithButton) FCellv := array(); GetSelPanel(); rec := GetPopRectByHeight(160); - rec[3] := rec[1]+160; + rec[3] := rec[1]+160; FPanel.SetBoundsRect(rec); FPanel.SetSelectData(FListSel); FPanel.Show(); @@ -3314,6 +3318,7 @@ type TOneSelectCell = class(TGridCellEditWithButton) FPanel.wspopup := true; FPanel.SetList(SelPalRange()); FPanel.OnSelChanged := thisfunction(SelChanged); + FPanel.parent := Owner; end end function SelPalRange();virtual; diff --git a/funcext/tvclib/tslvcl.tsf b/funcext/tvclib/tslvcl.tsf index 67f4021..2c2a7a4 100644 --- a/funcext/tvclib/tslvcl.tsf +++ b/funcext/tvclib/tslvcl.tsf @@ -4500,7 +4500,9 @@ type tapplicationwindow=class(TWinControl) end function InitializeWnd();override; begin + global g_applicaton_wnd_handle; inherited; + g_applicaton_wnd_handle := handle;; {echo self.Handle; SysMeu := _wapi.GetSystemMenu(self.Handle,False); echo "\r\nsysmenu",sysmenu; diff --git a/funcext/tvclib/ugtkinterface.tsf b/funcext/tvclib/ugtkinterface.tsf index 6815363..785d6fe 100644 --- a/funcext/tvclib/ugtkinterface.tsf +++ b/funcext/tvclib/ugtkinterface.tsf @@ -57,7 +57,6 @@ type tsgtkapi = class(tgtkapis) SW_SHOWNOACTIVATE := 0x4;SW_SHOW := 0x5;SW_MINIMIZE := 0x6; SW_SHOWMINNOACTIVE := 0x7;SW_SHOWNA := 0x8;SW_RESTORE := 0x9; SW_SHOWDEFAULT := 0xA;SW_FORCEMINIMIZE := 0xB;SW_MAX := 0xB;} - global G_GTK_WINDOW_ACTIVATE; if not hwd then return ; if not GTK_WIDGET(hwd) then return ; if f =0 then //隐藏 @@ -124,22 +123,16 @@ type tsgtkapi = class(tgtkapis) if f=0x4 then begin //if not gtk_window_get_decorated(hwd) then - gtk_window_set_type_hint(hwd,3); + // gtk_window_set_type_hint(hwd,3); if cf and cf<>g_current_get_focus_widget then //设置一下focus begin - tplev := gtk_widget_get_toplevel(cf); - if tplev then gtk_window_set_focus(tplev,cf); - end + gtk_widget_grab_focus(cf); + //tplev := gtk_widget_get_toplevel(cf); + //if tplev then gtk_window_set_focus(tplev,cf); + end end end - gtk_widget_show(hwd); - {if f<>0x4 and G_GTK_WINDOW_ACTIVATE<>hwd then - begin - if G_GTK_WINDOW_ACTIVATE then - gtk_addMessageQueue(G_GTK_WINDOW_ACTIVATE,0x6,0,0,0); - G_GTK_WINDOW_ACTIVATE := hwd; - gtk_addMessageQueue(hwd,0x6,1,0,0); - end } + gtk_widget_show(hwd); end return true; end @@ -151,9 +144,7 @@ type tsgtkapi = class(tgtkapis) begin if h>0 or h<0 then begin - wt := static gtk_widget_get_type(); - r := g_type_check_instance_is_a(h,wt); - return r; + return IsGtkWidget(h); end end function IsZoomed(hd:pointer) @@ -341,7 +332,7 @@ type tsgtkapi = class(tgtkapis) end else begin gtk_widget_set_size_request(h,cx,max(0,cy-pcd)); - end + end gtk_window_resize(h,cx,max(0,cy-pcd)); g_object_set_data(h,"gtk_layout_width",cx); g_object_set_data(h,"gtk_layout_height",cy); @@ -444,8 +435,8 @@ type tsgtkapi = class(tgtkapis) if gtk_widget_is_toplevel(h) then begin r := g_object_get_data(h,"gtk_layout_parent"); - if r=phwnd then return ; - g_object_set_data(h,"gtk_layout_parent",IsGtkWidget(phwnd)?phwnd:0); + if r<>phwnd then ;//return ; //此处不返回了,继续往下 + g_object_set_data(h,"gtk_layout_parent",IsGtkWidget(phwnd)?phwnd:0); if gtk_widget_is_visible(h) then //显示的子窗口处理 begin @@ -454,7 +445,9 @@ type tsgtkapi = class(tgtkapis) if gtk_widget_is_toplevel(phwnd) then pp := phwnd; else pp := gtk_widget_get_toplevel(phwnd); + gtk_widget_hide(h); gtk_window_set_transient_for(h,pp); + gtk_widget_show(h); end end else begin @@ -1416,12 +1409,15 @@ type tsgtkapi = class(tgtkapis) end Function TrackPopupMenu( hMenu:pointer;uFlags:integer; x:integer; y:integer; nReserved:integer;hWnd:pointer; prcRect: array of integer):integer; begin + global g_c_btn_release_event; //echo "\r\n===trackmenu:",hmenu,"===",x,"===",y,"===",nReserved,"===hwnd:",hwnd,"===rect:",tostn(prcRect); if g_object_get_data(hMenu,"popmenubar") then begin g_object_set_data(hMenu,"popmenubarwindow",hWnd); - gtk_menu_popup(hmenu,0,0,0,0,3,0);//弹出 - //popup_at_rect(hmenu,0,array(x,y,-1,-1),0,0,0); + //gtk_menu_popup(hmenu,0,0,0,0,3,0);//弹出 gtk_get_current_event_time() + if g_c_btn_release_event then ev := g_c_btn_release_event._getptr_; + gtk_menu_popup_at_pointer(hMenu,ev); + //gtk_menu_popup_at_rect(hmenu,hWnd,array(x,y,-1,-1),0,0,0); return 1; end else begin @@ -1431,9 +1427,22 @@ type tsgtkapi = class(tgtkapis) end function ClientToScreen(hwnd :pointer;var p:array of integer):integer; // 继续努力 - begin + begin if not hwnd then return ; - if not GTK_WIDGET(hwnd) then return ; + if not GTK_WIDGET(hwnd) then return ; + if {gdk_backend_is_wayland()} true then + begin + p1 := g_object_get_data(hwnd,"motion_xy"); + if ifarray(p1) then + begin + dx := p1["x_r"]-p1["x"]; + dy := p1["y_r"]-p1["y"]; + p[0]+=dx; + p[1]+=dy; + + end + return true; + end x := g_object_get_data(hwnd,"gtk_layout_x"); y := g_object_get_data(hwnd,"gtk_layout_y"); p[0]+=x; @@ -1459,6 +1468,18 @@ type tsgtkapi = class(tgtkapis) end function ScreenToClient(hwnd :pointer;var p:array of integer):integer;// 继续努力 begin + if {gdk_backend_is_wayland()}true then + begin + p1 := g_object_get_data(hwnd,"motion_xy"); + if ifarray(p1) then + begin + dx := p1["x_r"]-p1["x"]; + dy := p1["y_r"]-p1["y"]; + p[0]-=dx; + p[1]-=dy; + end + return true; + end p1 := array(0,0); ClientToScreen(hwnd,p1); p[0]-=p1[0]; @@ -2145,20 +2166,24 @@ type tsgtkapi = class(tgtkapis) begin cfcs := GetFocus(); if cfcs = hwnd then return 0; + return gtk_widget_grab_focus(hwnd); if not(hwnd>0 or hwnd<0) then return 0; ph := hwnd; if not GTK_WIDGET(hwnd) then return 0; if not gtk_widget_is_toplevel(hwnd) then begin ph := gtk_widget_get_toplevel(hwnd); + echo "++set not top:",ph,">>>",hwnd; + gtk_window_set_focus(ph,hwnd); + end else + begin + echo "\r\n+++set top>>>",ph,">>>",hwnd; + gtk_window_set_focus(hwnd,0); end //if not lot then //lot := hwnd; - //gtk_widget_grab_focus(lot); - //echo "\r\n+++setfocus>>>",ph,">>>",hwnd; - gtk_window_set_focus(ph,hwnd); + //gtk_widget_grab_focus(lot); return 0; - end function GetFocus():pointer; begin @@ -2314,8 +2339,9 @@ type tsgtkapi = class(tgtkapis) g_gtk_drag_window.Border := false; g_gtk_drag_window.WsPopUp := true; g_gtk_drag_window.Enabled := false; - g_gtk_drag_window.Visible := false; - end + g_gtk_drag_window.Visible := false; + h := g_gtk_drag_window.handle; + end cx := g_image_list_caches[sptr,"width"] ; cy := g_image_list_caches[sptr,"height"] ; obj := g_image_list_caches[sptr,"imglist"] ; @@ -2335,6 +2361,7 @@ type tsgtkapi = class(tgtkapis) if not g_gtk_drag_window then return ; xy := g_gtk_drag_lock_window.ClientToScreen(x,y); SetWindowPos(g_gtk_drag_window.Handle,0,xy[0]-g_gtk_dragxy[0],xy[1]-g_gtk_dragxy[1],-1,-1,0); + //SetWindowPos(g_gtk_drag_window.Handle,0,integer(g_gtk_dragxy[0]-g_gtk_drag_window.width/2),integer(g_gtk_dragxy[1]-g_gtk_drag_window.height/2),-1,-1,0); end function ImageList_DragEnter(hwndLock:pointer;x:integer;y:integer):integer; begin @@ -2342,8 +2369,9 @@ type tsgtkapi = class(tgtkapis) if not g_gtk_drag_window then return ; g_gtk_drag_lock_window := class(tUIglobalData).uigetdata("TGlobalComponentcache").getwndbyhwnd(hwndLock); if not g_gtk_drag_lock_window then return ; - //g_gtk_drag_window.Parent := g_gtk_drag_lock_window; - g_gtk_drag_window.Enabled := false; + h := g_gtk_drag_window.handle; + g_object_set_data(h,"gtk_layout_parent",gtk_widget_get_toplevel(g_gtk_drag_lock_window.handle)); + //g_gtk_drag_window.Enabled := false; ImageList_DragMove(x,y); g_gtk_drag_window.show( 0x4); end @@ -3782,6 +3810,11 @@ type tgtkapis = class() //gtk _f_ := static procedure(window:pointer; focus:pointer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(window,focus); end + procedure gtk_window_set_accept_focus(window:pointer; setting:integer); + begin + _f_ := static procedure(window:pointer; setting:integer);cdecl;external getfuncptrbyname(0,functionname()); + return ##_f_(window,setting?true:false); + end procedure gtk_window_set_type_hint(window:pointer; tp:integer); begin _f_ := static procedure(window:pointer; tp:integer);cdecl;external getfuncptrbyname(0,functionname()); @@ -4273,7 +4306,8 @@ type tgtkapis = class() //gtk procedure gtk_widget_set_size_request(wd:pointer;w:integer;h:integer); begin _f_ := static procedure(wd:pointer;w:integer;h:integer);cdecl;external getfuncptrbyname(0,functionname()); - return ##_f_(wd,w,h); + window_get_true_size(wd,w,h,wdo,hto); + return ##_f_(wd,wdo,hto); end procedure gtk_widget_get_size_request(wd:pointer;var h:integer;var w:integer); begin @@ -4927,13 +4961,18 @@ type tgtkapis = class() //gtk return ##_f_(w); end procedure gtk_window_set_modal(w:pointer;f:integer); - begin + begin _f_ := static procedure(w:pointer;f:integer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(w,f); end procedure gtk_window_set_transient_for(w:pointer;p:pointer); begin + global g_applicaton_wnd_handle; _f_ := static procedure(w:pointer;p:pointer);cdecl;external getfuncptrbyname(0,functionname()); + if (p = g_applicaton_wnd_handle) and gdk_backend_is_wayland() then //处理底层窗口问题 + begin + return ##_f_(w,0); + end return ##_f_(w,p); end function gtk_window_get_transient_for(w:pointer); @@ -4991,21 +5030,54 @@ type tgtkapis = class() //gtk _f_ := static procedure(w:pointer;t:pointer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(w,t); end - function gtk_window_get_titlebar(w:pointer); + function gtk_window_get_titlebar(w:pointer):pointer; begin _f_ := static function(w:pointer):pointer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(w); end - procedure gtk_window_set_geometry_hints (window:pointer;eometry_widget:pointer;geometry:pointer;geom_mask:integer); + procedure gtk_window_set_geometry_hints(window:pointer;eometry_widget:pointer;geometry:pointer;geom_mask:integer); begin _f_ := static procedure(window:pointer;eometry_widget:pointer;geometry:pointer;geom_mask:integer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(window,eometry_widget,geometry,geom_mask); end + function gtk_widget_get_margin_end(w:pointer):integer; + begin + _f_ := static function(w:pointer):integer;cdecl;external getfuncptrbyname(0,functionname()); + return ##_f_(w); + end + function gtk_widget_get_margin_right(w:pointer):integer; + begin + _f_ := static function(w:pointer):integer;cdecl;external getfuncptrbyname(0,functionname()); + return ##_f_(w); + end + function gtk_widget_get_margin_bottom(w:pointer):integer; + begin + _f_ := static function(w:pointer):integer;cdecl;external getfuncptrbyname(0,functionname()); + return ##_f_(w); + end procedure gtk_window_resize(w:pointer;wd:integer;ht:integer); begin _f_ := static procedure(w:pointer;wd:integer;ht:integer);cdecl;external getfuncptrbyname(0,functionname()); - return ##_f_(w,wd,ht); + save_wnd_size(w,wd,ht); + window_get_true_size(wnd,wd,ht,wdo,hto); + return ##_f_(w,wdo,hto); end + function window_get_true_size(wnd,wd,ht,wdo,hto); + begin + global g_gtk_shadow_width,g_gtk_shadow_heigt; + wdo := wd;hto := ht; + if gdk_backend_is_wayland() and g_object_get_data(wnd,"size_has_shadow") then + begin + wdo+=g_gtk_shadow_width;hto+=g_gtk_shadow_heigt; + end + end + function save_wnd_size(w,wd,ht); + begin + if g_object_get_data(w,"size_last_set") then + begin + g_object_set_data(w,"size_last_set_value",array(wd,ht)); + end + end procedure gtk_window_resize_to_geometry(w:pointer;wd:integer;ht:integer); begin _f_ := static procedure(w:pointer;wd:integer;ht:integer);cdecl;external getfuncptrbyname(0,functionname()); @@ -5213,16 +5285,21 @@ type tgtkapis = class() //gtk _f_ := static procedure(mb:pointer;mi:pointer;id:integer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(mb,mi,id); end - procedure gtk_menu_popup (menu:pointer;parent_menu_shell:pointer;parent_menu_item:pointer;func:pointer;data:pointer;button:integer;activate_time:integer); + procedure gtk_menu_popup(menu:pointer;parent_menu_shell:pointer;parent_menu_item:pointer;func:pointer;data:pointer;button:integer;activate_time:integer); begin _f_ := static procedure(menu:pointer;parent_menu_shell:pointer;parent_menu_item:pointer;func:pointer;data:pointer;button:integer;activate_time:integer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(menu,parent_menu_shell,parent_menu_item,func,data,button,activate_time); end - procedure popup_at_rect(menu:pointer;rect_window:pointer;var rect : array of integer;rect_anchor:pointer;menu_anchor:pointer;trigger_event:pointer); + procedure gtk_menu_popup_at_rect(menu:pointer;rect_window:pointer;var rect : array of integer;rect_anchor:pointer;menu_anchor:pointer;trigger_event:pointer); begin _f_ := static procedure(menu:pointer;rect_window:pointer;var rect : array of integer;rect_anchor:pointer;menu_anchor:pointer;trigger_event:pointer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(menu,rect_window,rect,rect_anchor,menu_anchor,trigger_event); end + procedure gtk_menu_popup_at_pointer(mi:pointer;evt:pointer); + begin + _f_ := static procedure(mi:pointer;evt:pointer);cdecl;external getfuncptrbyname(0,functionname()); + return ##_f_(mi,evt); + end procedure gtk_menu_item_activate(mi:pointer); begin _f_ := static procedure(mi:pointer);cdecl;external getfuncptrbyname(0,functionname()); @@ -5471,7 +5548,12 @@ type tgtkapis = class() //gtk _f_ := static function(cs:string;c:pointer):integer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(cs,c); end - + /////////////////////////////////////////////////// + function gdk_event_new(t:integer):pointer; + begin + _f_ := static function(t:integer):pointer;cdecl;external getfuncptrbyname(0,functionname()); + return ##_f_(t); + end ////////////////// evntbox //////////////////////////// function gtk_event_box_new():pointer; begin @@ -5558,7 +5640,12 @@ type tgtkapis = class() //gtk _f_ := static function():integer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(); end - function gtk_get_binary_age ():integer; + function gtk_get_current_event_time():integer; + begin + _f_ := static function():integer;cdecl;external getfuncptrbyname(0,functionname()); + return ##_f_(); + end + function gtk_get_binary_age():integer; begin _f_ := static function():integer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(); @@ -5902,7 +5989,44 @@ type _dlgwidgets = class(tslcstructureobj) inherited create(getstruct(),ptr); end end - +type _GdkGeometry = class(tslcstructureobj) + private + static SSTRUCT; + class function getstruct() + begin + if not SSTRUCT then SSTRUCT := MemoryAlignmentCalculate( + array( + ("min_width","int",-1), + ("min_height","int",-1), + ("max_width","int",-1), + ("max_height","int",-1), + ("base_width","int",-1), + ("base_height","int",-1), + ("width_inc","int",-1), + ("height_inc","int",-1), + ("min_aspect","int",-1), + ("max_aspect","int",-1), + ("win_gravity","int",-1) + ),nil,nil,4); + return SSTRUCT; + end + public + function create(ptr) + begin + inherited create(getstruct(),ptr); + end + property min_width index "min_width" read _getvalue_ write _setvalue_; + property min_height index "min_height" read _getvalue_ write _setvalue_; + property max_width index "max_width" read _getvalue_ write _setvalue_; + property max_height index "max_height" read _getvalue_ write _setvalue_; + property base_width index "base_width" read _getvalue_ write _setvalue_; + property base_height index "base_height" read _getvalue_ write _setvalue_; + property width_inc index "width_inc" read _getvalue_ write _setvalue_; + property height_inc index "height_inc" read _getvalue_ write _setvalue_; + property min_aspect index "min_aspect" read _getvalue_ write _setvalue_; + property max_aspect index "max_aspect" read _getvalue_ write _setvalue_; + property GdkGravity index "GdkGravity" read _getvalue_ write _setvalue_; +end type _GdkEventButton=class(tslcstructureobj) private static SSTRUCT; @@ -6204,13 +6328,6 @@ type _GdkEventCrossing=class(tslcstructureobj) ("focus","int",0), ("state","int",0) ),nil,nil,4); - {GDK_WINDOW_STATE_WITHDRAWN = 1 << 0, - GDK_WINDOW_STATE_ICONIFIED = 1 << 1, - GDK_WINDOW_STATE_MAXIMIZED = 1 << 2, - GDK_WINDOW_STATE_STICKY = 1 << 3, - GDK_WINDOW_STATE_FULLSCREEN = 1 << 4, - GDK_WINDOW_STATE_ABOVE = 1 << 5, - GDK_WINDOW_STATE_BELOW = 1 << 6} return SSTRUCT; end public @@ -6233,13 +6350,6 @@ type _GdkEventWindowState=class(tslcstructureobj) ("changed_mask","int",0), ("new_window_state","int",0) ),nil,nil,4); - {GDK_WINDOW_STATE_WITHDRAWN = 1 << 0, - GDK_WINDOW_STATE_ICONIFIED = 1 << 1, - GDK_WINDOW_STATE_MAXIMIZED = 1 << 2, - GDK_WINDOW_STATE_STICKY = 1 << 3, - GDK_WINDOW_STATE_FULLSCREEN = 1 << 4, - GDK_WINDOW_STATE_ABOVE = 1 << 5, - GDK_WINDOW_STATE_BELOW = 1 << 6} return SSTRUCT; end public @@ -6521,7 +6631,8 @@ type _gslist =class(tslcstructureobj) end property data index "data" read _getvalue_ write _setvalue_ ; property next index "next" read _getvalue_ write _setvalue_ ; -end +end +{ type tenterouterlist = class function push(d); begin @@ -6607,7 +6718,7 @@ type tenterouterlist = class FList; FTimer; //20230314 修正此处问题 end - +} type tgtk_ctl_object = class(_gtkeventtype) private @@ -6632,9 +6743,9 @@ type tgtk_ctl_object = class(_gtkeventtype) begin _const := getwin32const(); _wapi := gettswin32api(); - FMousemoveernotify := new tenterouterlist(_wapi); - FMousemoveernotify.Mousemovecall := thisfunction(widgetmousemovecall); - FMousemoveernotify.Mousehittest := thisfunction(widgetmousehit); + //FMousemoveernotify := new tenterouterlist(_wapi); + //FMousemoveernotify.Mousemovecall := thisfunction(widgetmousemovecall); + //FMousemoveernotify.Mousehittest := thisfunction(widgetmousehit); FsysCursors := array(); FsysCursors[0] := _wapi.gdk_cursor_new(2); FsysCursors[1] := _wapi.gdk_cursor_new(70); @@ -6691,7 +6802,7 @@ type tgtk_ctl_object = class(_gtkeventtype) if (msg = _const.WM_SYSCOMMAND and w = 0xF012) or (msg = _const.WM_NCLBUTTONDOWN and w= _const.HTCAPTION) then //WM_NCLBUTTONDOWN begin Fsyscommand0x12 := true; - FMousemoveernotify.lock(); + //FMousemoveernotify.lock(); h := handle; x := _wapi.g_object_get_data(h,"gtk_layout_x"); y := _wapi.g_object_get_data(h,"gtk_layout_y"); @@ -6704,7 +6815,8 @@ type tgtk_ctl_object = class(_gtkeventtype) ); end return 0; - end + end + static fwindow_cursor; function CallTslVclProc(msg,w,l,P);virtual; //调用到win消息处理 begin CM_CURSORCHANGED := _const.CM_CURSORCHANGED; @@ -6736,17 +6848,29 @@ type tgtk_ctl_object = class(_gtkeventtype) 10,11:begin //_wapi.gdk_window_set_cursor(wd,FsysCursors[1]) ; g_show_cursor_window := 0; - AddMessageToGtkMessageQueue(FHandle,CM_CURSORCHANGED,wd,FsysCursors[1]); + if fwindow_cursor <> FsysCursors[1] then + begin + fwindow_cursor := FsysCursors[1]; + AddMessageToGtkMessageQueue(FHandle,CM_CURSORCHANGED,wd,FsysCursors[1]); + end end 12,15:begin //_wapi.gdk_window_set_cursor(wd,FsysCursors[2]) ; - g_show_cursor_window := 0; - AddMessageToGtkMessageQueue(FHandle,CM_CURSORCHANGED,wd,FsysCursors[2]); - + //g_show_cursor_window := 0; + if fwindow_cursor <> FsysCursors[2] then + begin + fwindow_cursor := FsysCursors[2]; + AddMessageToGtkMessageQueue(FHandle,CM_CURSORCHANGED,wd,FsysCursors[2]); + end end 1:begin //_wapi.gdk_window_set_cursor(wd,FsysCursors[0]) ; - AddMessageToGtkMessageQueue(FHandle,CM_CURSORCHANGED,0,0); + //AddMessageToGtkMessageQueue(FHandle,CM_CURSORCHANGED,0,0); + if fwindow_cursor <> FsysCursors[0] then + begin + fwindow_cursor := FsysCursors[0]; + AddMessageToGtkMessageQueue(FHandle,CM_CURSORCHANGED,wd,FsysCursors[0]); + end end else begin @@ -6761,18 +6885,30 @@ type tgtk_ctl_object = class(_gtkeventtype) begin //return _wapi.gdk_window_set_cursor(wd,FsysCursors[1]) ; g_show_cursor_window := 0; - AddMessageToGtkMessageQueue(FHandle,CM_CURSORCHANGED,wd,FsysCursors[1]); - + if fwindow_cursor <> FsysCursors[1] then + begin + fwindow_cursor := FsysCursors[1]; + return AddMessageToGtkMessageQueue(FHandle,CM_CURSORCHANGED,wd,FsysCursors[1]); + end return r; end else if ht=12 or ht=15 then begin g_show_cursor_window := 0; //return _wapi.gdk_window_set_cursor(wd,FsysCursors[2]) ; - AddMessageToGtkMessageQueue(FHandle,CM_CURSORCHANGED,wd,FsysCursors[2]); + if fwindow_cursor <> FsysCursors[2] then + begin + fwindow_cursor := FsysCursors[2]; + return AddMessageToGtkMessageQueue(FHandle,CM_CURSORCHANGED,wd,FsysCursors[2]); + end return r; end end //_wapi.gdk_window_set_cursor(wd,FsysCursors[0]) ; - return AddMessageToGtkMessageQueue(FHandle,CM_CURSORCHANGED,0,0); + //return AddMessageToGtkMessageQueue(FHandle,CM_CURSORCHANGED,0,0); + if fwindow_cursor<>FsysCursors[0] then + begin + fwindow_cursor := FsysCursors[0]; + return AddMessageToGtkMessageQueue(FHandle,CM_CURSORCHANGED,wd,FsysCursors[0]); + end return r; end end ; end else @@ -6838,7 +6974,6 @@ type tgtk_ctl_object = class(_gtkeventtype) begin CallTslVclProc(_const.WM_SIZE,0,makelong(w,h)); end - fimhandle; function gdk_window_get_state(w:pointer):integegr; begin _f_ := static function(w:pointer):integegr;cdecl;external getfuncptrbyname(0,functionname()); @@ -6851,29 +6986,44 @@ type tgtk_ctl_object = class(_gtkeventtype) function GSWINDOWSTATEEVENT(a,b,c,d);virtual; //状态改变 begin global G_GTK_WINDOW_ACTIVATE; - obj := new _GdkEventWindowState(c); - st := obj.new_window_state; - if st .& 4 then + + obj := new _GdkEventWindowState(c); + st := obj.new_window_state; + { + cm := obj.changed_mask; + if (cm .& 128)=128 then + begin + hwd := handle; + hwd := _wapi.gtk_widget_is_toplevel(hwd)?hwd:_wapi.gtk_widget_get_toplevel(hwd); + wp := (128=(st .& 128)); + echo "\r\nactivate:",hwd," ",wp; + if wp then + AddMessageToGtkMessageQueue(hwd,0x6,1,0,0); + else AddMessageToGtkMessageQueue(hwd,0x6,0,0,0); + //echo "\r\n focus:", handle," ",(128=(st .& 128)); + end + } + if st .& GDK_WINDOW_STATE_MAXIMIZED then begin return CallTslVclProc(_const.WM_SYSCOMMAND ,_const.SC_MAXIMIZE,0); end - if st .& 2 then + {if st .& 2 then begin return CallTslVclProc(_const.WM_SYSCOMMAND ,_const.SC_MINIMIZE,0); end - if st .& (2^4) then + if st .& (GDK_WINDOW_STATE_FULLSCREEN) then begin //echo "\r\n full screen"; end - if st .& (2^5) then + if st .& (GDK_WINDOW_STATE_ABOVE) then begin //echo "\r\n above"; end - if st .& (2^6) then + if st .& (GDK_WINDOW_STATE_BELOW) then begin //echo "\r\n below"; - end - if st .& (2^7) then + end } + if st .& (GDK_WINDOW_STATE_FOCUSED) then begin //CallTslVclProc(_const.WM_SETFOCUS ,0,0); hwd := handle; @@ -6938,7 +7088,7 @@ type tgtk_ctl_object = class(_gtkeventtype) if FHitwidgetposition in array(10,11,12,15) then begin FHitwidgetposition += 100; - FMousemoveernotify.lock(); + //FMousemoveernotify.lock(); h := handle; xy := array(0,0); _wapi.GetCursorPos(xy); @@ -6963,31 +7113,32 @@ type tgtk_ctl_object = class(_gtkeventtype) g_gtk_buttontable[1] := _const.MK_RButton; CallTslVclProc(_const.WM_RBUTTONDOWN ,wp,psi); end - end ; - - {hwd := handle; - hwd := _wapi.gtk_widget_is_toplevel(hwd)?hwd:_wapi.gtk_widget_get_toplevel(hwd); - if G_GTK_WINDOW_ACTIVATE<>hwd then - begin - if G_GTK_WINDOW_ACTIVATE then - AddMessageToGtkMessageQueue(G_GTK_WINDOW_ACTIVATE,0x6,0,0,0); - G_GTK_WINDOW_ACTIVATE := hwd; - AddMessageToGtkMessageQueue(hwd,0x6,1,0,0); - end } + end ; return CanignoreBtnpress(); end function GSMOTIONNOTIFYEVENT(a,b,c,d);virtual; begin + global g_gtk_dragxy; e := new _GdkEventMotion(c); //CallTslVclProc(_const.WM_MOUSEMOVE ,0,makelong(integer(e.x),integer(e.y)),true); id := a.handle; + mxy := array(); + mxy["x"] := e.x; + mxy["y"] := e.y; + mxy["x_r"] := e.x_root; + mxy["y_r"] := e.y_root; + _wapi.g_object_set_data(id,"motion_xy",mxy); + //g_gtk_dragxy := array(integer(e.x_root),integer(e.y_root)); mywidgetmousehit(id,array(integer(e.x_root),integer(e.y_root))); mywidgetmousemovecall(id,array(integer(e.x),integer(e.y))); end function GSBUTTONRELEASEEVENT(a,b,c,d);virtual; begin - global g_gtk_buttontable, g_gtk_keytable; - e := new _GdkEventButton(c); + global g_gtk_buttontable, g_gtk_keytable,g_c_btn_release_event; + e := new _GdkEventButton(c); + ev := new _GdkEventButton(nil); + ev.CopyFromString(e.CopyToString()); + g_c_btn_release_event := ev; psi := makelong(integer(e.x),integer(e.y)); wp := 0; if ifarray(g_gtk_keytable) then @@ -7014,13 +7165,13 @@ type tgtk_ctl_object = class(_gtkeventtype) end function GSFOCUSINEVENT(a,b,c,d);virtual; begin - global g_current_get_focus_widget,g_current_loss_focus_widget; + global g_current_get_focus_widget; h := a.handle; e := new _GdkEventAny(c); getfimobj().setclientwindow(e.window); getfimobj().setfocusctl(self); g_current_get_focus_widget := h; - //echo "\r\nsetfocus==>",h; + //echo "\r\nfocous in >",h; ch := _wapi.g_object_get_data(h,"gtk_client_parent"); if ch then begin @@ -7035,12 +7186,13 @@ type tgtk_ctl_object = class(_gtkeventtype) end function GSFOCUSOUTEVENT(a,b,c,d);virtual; begin - global g_current_get_focus_widget,g_current_loss_focus_widget; + global g_current_get_focus_widget;//,g_current_loss_focus_widget; h := a.handle; e := new _GdkEventAny(c); getfimobj().setclientwindow(e.window); getfimobj().setfocusctl(self); - g_current_loss_focus_widget := h; + //g_current_loss_focus_widget := h; + //echo "\r\n focus out>",h; g_current_get_focus_widget := 0; ch := _wapi.g_object_get_data(a.handle,"gtk_client_parent"); //将killfocus 修改为立即执行 @@ -7058,7 +7210,7 @@ type tgtk_ctl_object = class(_gtkeventtype) end function gs_key_vent(a,b,c,d); begin - global g_gtk_keytable; + global g_gtk_keytable,g_current_get_focus_widget; e := new _GdkEventKey(c); kud := e.ttype; ///////////////////////////////////控制键 @@ -7114,8 +7266,11 @@ type tgtk_ctl_object = class(_gtkeventtype) //echo "\r\n===handle:",a.handle; ah := a.handle; + fcsctl := g_current_get_focus_widget; + { if not _wapi.gtk_widget_is_toplevel(ah) then return true ; fcsctl := _wapi.gtk_window_get_focus(ah); + echo "\r\nfocus:",fcsctl;} if not fcsctl then begin obj := class(tUIglobalData).uigetdata("tuiapplication"); @@ -7140,7 +7295,7 @@ type tgtk_ctl_object = class(_gtkeventtype) end end //echo "\r\nkey fillter ed:",kud,"====",kv; - //return 1; + //return 1; case kv of //65513,65514,65506 65288: @@ -7443,7 +7598,7 @@ type tgtk_ctl_object = class(_gtkeventtype) begin FHitwidgetposition := 0; Fsyscommand0x12info := nil; - FMousemoveernotify.unlock(); + //FMousemoveernotify.unlock(); //return ; end end @@ -7472,16 +7627,20 @@ type tgtk_ctl_object = class(_gtkeventtype) begin Fsyscommand0x12 := false; Fsyscommand0x12info := nil; - FMousemoveernotify.unlock(); + //FMousemoveernotify.unlock(); //return ; end end end end case mn of + GS_VISIBILITY_NOTIFY_EVENT: + begin + echo "visb:"; + end GS_DESTROY: begin - FMousemoveernotify.unlock(); + //FMousemoveernotify.unlock(); Fsyscommand0x12 := 0; Fsyscommand0x12info := nil; FHitwidgetposition := 0; @@ -7630,14 +7789,6 @@ type tgtk_ctl_object = class(_gtkeventtype) GS_FOCUS_OUT_EVENT:"tsl_gtk_focus_out_event" ); end - function connect_test(n,f); //测试使用 - begin - if FHandle=0 then return 0; - if not ifstring(n) then return 0; - ln := FormularSignalName(lowercase(n)); - eid := GetGtkEventNameOrId(ln); - lnid := g_signal_connect_data(FHandle, ln, makeinstance(fn), eid,nil,0); - end function Connect(n,f); //连接消息 begin //删除connect @@ -7662,12 +7813,12 @@ type tgtk_ctl_object = class(_gtkeventtype) ptr := get_fptr_by_sigal_name(n); if ptr then begin - lnid := g_signal_connect_data(FHandle, ln, ptr, eid,nil,0); - FConnectNameIds[ln] := lnid; - FConnectHandlers[inttostr(eid)] := f; + lnid := g_signal_connect_data(FHandle, ln, ptr, eid,nil,0); + FConnectNameIds[ln] := lnid; + FConnectHandlers[inttostr(eid)] := f; end else begin - echo "\r\n not find:",n; + echo "\r\n not find signal callback:",n; end return lnid; end @@ -7885,7 +8036,7 @@ type tgtk_ctl_object = class(_gtkeventtype) begin return true; end - static FMousemoveernotify; + //static FMousemoveernotify; class function getfimobj(); begin if not FImobj then FImobj := new tgtk_im_object(nil); @@ -7894,7 +8045,7 @@ type tgtk_ctl_object = class(_gtkeventtype) static FImobj; end -type tscrollobject = class +type tscrollobject = class() fbar; fadj; fpgcount; @@ -8656,12 +8807,35 @@ type tgtk_ctl_window_PoPup = class(tgtk_ctl_scroll_window) if _wapi.gtk_object_get_data(Handle,"gtk_wnd_hs_caption") then return false; return true; end + function later_set_size(id:pointer):integer;cdecl; + begin + _wapi.g_object_set_data(id,"size_last_set",0); + if _wapi.IsGtkWidget(id) then + begin + _wapi.gtk_window_get_size(id,wd,ht); + sv := _wapi.g_object_get_data(id,"size_last_set_value") ; + if ifarray(sv) and (sv[0]<>wd or sv[1]<>ht) then + begin + _wapi.gtk_widget_set_size_request(id,integer(sv[0]),integer(sv[1])); + _wapi.gtk_window_resize(id,integer(sv[0]),integer(sv[1])); + end + end + return false; + end function GtkEventDispatch(a,mn,c,d);override; begin //消息分发 //echo "eventtype:",_wapi.gdk_event_get_event_type(c),"\r\n"; + global g_gtk_shadow_size_nset,g_gtk_shadow_width,g_gtk_shadow_heigt,g_w_c_width; case mn of - "configure-event" : + GS_SHOW: + begin + if _wapi.g_object_get_data(a.handle,"size_last_set") then //延时处理 + begin + _wapi.g_timeout_add(20,makeinstance(thisfunction(later_set_size)),a.handle); + end + end + GS_CONFIGURE_EVENT: begin //return false; h := a.handle; @@ -8671,11 +8845,22 @@ type tgtk_ctl_window_PoPup = class(tgtk_ctl_scroll_window) cy := _wapi.g_object_get_data(h,"gtk_layout_height"); cf := new _GdkEventConfigure(c); ALeft := integer(cf.x); - ATop := integer(cf.y); - //AWidth := integer(cf.width); - //AHeight := integer(cf.height); + ATop := integer(cf.y); //_wapi.gtk_window_get_position(h,aleft,atop); _wapi.gtk_window_get_size(h,AWidth,AHeight); + if g_gtk_shadow_size_nset then + begin + ewidth := cf.width; + eheight := cf.height; + dw := abs(AWidth-ewidth); + dh := abs(AHeight-eheight); + if dw>10 and dh>10 then + begin + g_gtk_shadow_width := dw; + g_gtk_shadow_heigt := dh; + g_gtk_shadow_size_nset := false; + end + end //echo "\r\nconfigure:",AWidth," ",AHeight; SizeChanged :=(cx <> AWidth)or(cy <> AHeight); PosChanged :=(x <> ALeft)or(y <> ATop); @@ -8684,11 +8869,9 @@ type tgtk_ctl_window_PoPup = class(tgtk_ctl_scroll_window) Exit; end if (cx <> AWidth) then _wapi.g_object_set_data(h,"gtk_layout_width",AWidth); - global g_w_c_width; pcd := _wapi.gtk_object_get_data(h,"gtk_wnd_hs_caption")?g_w_c_width:0; if cy <> AHeight then begin - _wapi.g_object_set_data(h,"gtk_layout_height",AHeight+pcd); end if x <> ALeft then @@ -8714,47 +8897,60 @@ type tgtk_ctl_window_PoPup = class(tgtk_ctl_scroll_window) function GtkBaseEventName();override; begin //return inherited union2 array("configure-event","delete-event","scroll-event","activate-default"); - return inherited union2 array(GS_CONFIGURE_EVENT,GS_DELETE_EVENT,GS_SCROLL_EVENT); - end + return inherited union2 array(GS_CONFIGURE_EVENT,GS_DELETE_EVENT,GS_SCROLL_EVENT,GS_SHOW); + end function CreateWnd(dwExStyle,lpClassName,lpWindowName,dwStyle,x,y,nwidth,nheight,hwndparent,hmenu,hinstance,lpParam);override; begin - //echo "\r\nctl===popup:",tostn(params),tostn(__stack_frame),datetimetostr(now()),">>>>"; - + global g_w_c_width; hascap := (_const.WS_CAPTION .& dwStyle)= _const.WS_CAPTION or (_const.WS_SYSMENU .& dwStyle)=_const.WS_SYSMENU; srszie :=((_const.WS_MAXIMIZEBOX .& dwStyle)=_const.WS_MAXIMIZEBOX) or ((_const.WS_SIZEBOX .& dwStyle)=_const.WS_SIZEBOX); - //h := _wapi.gtk_window_new(0); //控件层 - if hascap or srszie then + if hascap or srszie then //有标题 begin - h := _wapi.gtk_window_new(0); //控件层 + h := _wapi.gtk_window_new(0); //控件层 end else begin h := _wapi.gtk_window_new(1); //popup + //_wapi.gtk_window_set_type_hint(h,11); //此处忽略类型 end - - //_wapi.gtk_widget_set_events(h,0x3FFFFFE); - _wapi.gtk_window_set_default_size(h,10,10); - //_wapi.gtk_widget_set_size_request(h,300,300); _wapi.gtk_object_set_data(h,"gtk_wnd_hs_caption",1); if not(hascap or srszie) then begin _wapi.gtk_window_set_decorated(h,false); _wapi.gtk_object_set_data(h,"gtk_wnd_hs_caption",0); + pcd := 0; //无菜单顶层窗口 end else begin _wapi.gtk_window_set_decorated(h,true); - _wapi.gtk_window_set_title(h,_wapi.TslStringToGtk(lpWindowName)); + _wapi.gtk_window_set_title(h,_wapi.TslStringToGtk(lpWindowName)); + pcd := g_w_c_width; //有标题 有菜单的顶层窗口 end if (_const.WS_BORDER .& dwStyle)=_const.WS_BORDER then //Border begin _wapi.gtk_container_set_border_width(h,1); end + _wapi.gtk_window_set_default_size(h,max(1,nWidth),max(1,nheight-pcd)); //顶层窗口采用设default + if not srszie then + begin + if gdk_backend_is_wayland() and hascap then _wapi.g_object_set_data(h,"size_has_shadow",true); + _wapi.g_object_set_data(h,"size_last_set",true); + _wapi.g_object_set_data(h,"size_last_set_value",array(max(1,nWidth),max(1,nheight-pcd))); + end + _wapi.gtk_window_set_resizable(h,srszie); + {if false then ////////////最大最小处理/////////////////////// + begin + gd := new _GdkGeometry(); + gd.min_width := nWidth; + gd.min_height:= max(1,nheight-pcd); + gd.max_width := nWidth+1; + gd.max_height := max(1,nheight-pcd)+1; + _wapi.gtk_window_set_geometry_hints(h,0,gd._getptr_(),1+2+4+8+16+32+46+128); + end } vbox := _wapi.gtk_vbox_new(0,0); //菜单布局层 _wapi.gtk_container_add(h,vbox); _wapi.g_object_set_data(h,"gtk_vbox",vbox); //vbox - _wapi.gtk_window_set_resizable(h,srszie); _wapi.g_object_set_data(h,"gtk_popwp",2+srszie); { vbox @@ -8775,34 +8971,39 @@ type tgtk_ctl_window_PoPup = class(tgtk_ctl_scroll_window) _wapi.gtk_layout_put(ctllayout,evtdrawbox,0,0); clientLayout := _Wapi.gtk_layout_new(0,0); _wapi.gtk_container_add(evtdrawbox,clientLayout); - global g_w_c_width; - pcd := _wapi.gtk_object_get_data(h,"gtk_wnd_hs_caption")?g_w_c_width:0; - //_wapi.gtk_widget_set_size_request(evtdrawbox,nwidth,max(0,nheight-pcd)); + _wapi.gtk_widget_set_size_request(evtdrawbox,max(1,nwidth),max(1,nheight-pcd)); _wapi.g_object_set_data(evtdrawbox,"gtk_client_parent",h); FClientWideget := evtdrawbox; //_wapi.gtk_widget_set_can_focus(eb,true); _wapi.g_object_set_data(h,"gtk_layout",clientLayout); - _wapi.g_object_set_data(clientLayout,"gtk_layout_owner",h); - - InitWidgetSize(h,x,y,nwidth,nheight); - if nwidth>0 and nheight>0 then - begin - _wapi.gtk_window_resize(h,nwidth,max(1,nheight-pcd)); - end + _wapi.g_object_set_data(clientLayout,"gtk_layout_owner",h); + InitWidgetSize(h,x,y,nwidth,nheight); _wapi.gtk_window_move(h,x,max(0,y-pcd)); _wapi.gtk_widget_show_all(vbox); - InitContainerList(h); //容器list - handle := h; - _wapi.SetParent(h,hwndparent); + InitContainerList(h); //容器list + if hwndparent then //设置parent _wapi.SetParent(h,hwndparent); + begin + + _wapi.g_object_set_data(h,"gtk_layout_parent",hwndparent); + if _wapi.gtk_widget_is_toplevel(hwndparent) then trf := hWndParent; + else + trf := _wapi.gtk_widget_get_toplevel(hwndparent); + _wapi.gtk_window_set_transient_for(h,trf); + end + //设置default 后不使用 resize 函数 + ///////////需要绑定show信号,所以此处提前widget_show 前 + handle := h; + r := inherited; + //////////////////////////////////////////////////// if (_const.WS_VISIBLE .& dwStyle)=_const.WS_VISIBLE then begin //_wapi.ShowWindow(h); - _wapi.gtk_widget_show(h); + _wapi.gtk_widget_show(h); end else begin _wapi.gtk_widget_hide(h); - end - r := inherited; + end + /////////////处理边框消息/////////////////// if FClientObject then begin FClientObject.connect(GS_BUTTON_PRESS_EVENT,thisfunction(cleinteventpress)); @@ -8876,7 +9077,6 @@ type tgtk_ctl_window = class(tgtk_ctl_scroll_window) _wapi.gtk_container_add(evtdrawbox,clientlayout); _wapi.gtk_layout_put(ctllayout,evtdrawbox,0,0); _wapi.gtk_widget_set_size_request(evtdrawbox,nwidth,nheight); - //_wapi.gtk_widget_set_size_request(evtdrawbox,10000,10000); _wapi.g_object_set_data(h,"gtk_layout",clientlayout); _wapi.g_object_set_data(clientlayout,"gtk_layout_owner",h); _wapi.g_object_set_data(evtdrawbox,"gtk_client_parent",h); @@ -9062,40 +9262,30 @@ begin //定时处理 AddMessageToGtkMessageQueue(h,m,w,l,0x113); end +function get_m_m_q(); //获取消息队列 +begin + return static new tGtkMessageQueue(); +end function hasMessageFromGtkMessageQueue(h,m); //是否存在消息 begin - GLobal G_GTK_MESSAGE_QUEUE_A; - if G_GTK_MESSAGE_QUEUE_A then G_GTK_MESSAGE_QUEUE_A.haseasyLostMessage(h,m); + get_m_m_q().haseasyLostMessage(h,m); end function feacheasylostMessageFromGtkMessageQueue(h,m); //获取容丢失的消息 begin - GLobal G_GTK_MESSAGE_QUEUE_A; - if G_GTK_MESSAGE_QUEUE_A then return G_GTK_MESSAGE_QUEUE_A.feacheasylostmessage(h,m); + return get_m_m_q().feacheasylostmessage(h,m); end function clearMessageFromGtkMessageQueue(h,m); //清除消息 begin - GLobal G_GTK_MESSAGE_QUEUE_A; - if G_GTK_MESSAGE_QUEUE_A then G_GTK_MESSAGE_QUEUE_A.cleaneasyLostMessage(h,m); + return get_m_m_q().cleaneasyLostMessage(h,m); end function AddMessageToGtkMessageQueue(FHandle,msg,wparam,lparam,d); //推送消息 begin - GLobal G_GTK_MESSAGE_QUEUE_A; - if not G_GTK_MESSAGE_QUEUE_A then - begin - G_GTK_MESSAGE_QUEUE_A := new tGtkMessageQueue(); - end - G_GTK_MESSAGE_QUEUE_A.add(FHandle,msg,wparam,lparam,d); + return get_m_m_q().add(FHandle,msg,wparam,lparam,d); end function FeachMessageFromGtkMessageQueue(); //获取最后的事件 begin - GLobal G_GTK_MESSAGE_QUEUE_A; - if G_GTK_MESSAGE_QUEUE_A then - begin - d := G_GTK_MESSAGE_QUEUE_A.Feach(); - return d; - end - //return class(tgtk_ctl_object).Feach(params); + return get_m_m_q().Feach(); end function GetGtkEventNameOrId(n); //获得event begin @@ -9221,9 +9411,8 @@ begin //sleep(10);//休息一下 end unit(uvclthreadworker).RunThreadWorkerHost(); - GLobal G_GTK_MESSAGE_QUEUE_A; if r=0 then sleep(30); - //G_GTK_MESSAGE_QUEUE_A.idleworked := r; + //get_m_m_q().idleworked := r; return true; end procedure tslprocessmessages()begin end; @@ -9326,6 +9515,54 @@ begin return static systhreadid(); end type _gtkeventtype=class + + + static const GDK_WINDOW_STATE_WITHDRAWN=1; + static const GDK_WINDOW_STATE_ICONIFIED=2; + static const GDK_WINDOW_STATE_MAXIMIZED=4; + static const GDK_WINDOW_STATE_STICKY=8; + static const GDK_WINDOW_STATE_FULLSCREEN=16; + static const GDK_WINDOW_STATE_ABOVE=32; + static const GDK_WINDOW_STATE_BELOW=64; + static const GDK_WINDOW_STATE_FOCUSED=128; + static const GDK_WINDOW_STATE_TILED=256; + static const GDK_WINDOW_STATE_TOP_TILED=512; + static const GDK_WINDOW_STATE_TOP_RESIZABLE=1024; + static const GDK_WINDOW_STATE_RIGHT_TILED=2048; + static const GDK_WINDOW_STATE_RIGHT_RESIZABLE=4069; + static const GDK_WINDOW_STATE_BOTTOM_TILED=8192; + static const GDK_WINDOW_STATE_BOTTOM_RESIZABLE=16384; + static const GDK_WINDOW_STATE_LEFT_TILED=32768; + static const GDK_WINDOW_STATE_LEFT_RESIZABLE=65536; + + + static const GDK_GRAVITY_NORTH_WEST=1; + static const GDK_GRAVITY_NORTH=2; + static const GDK_GRAVITY_NORTH_EAST=3; + static const GDK_GRAVITY_WEST=4; + static const GDK_GRAVITY_CENTER=5; + static const GDK_GRAVITY_EAST=6; + static const GDK_GRAVITY_SOUTH_WEST=7; + static const GDK_GRAVITY_SOUTH=8; + static const GDK_GRAVITY_SOUTH_EAST=9; + static const GDK_GRAVITY_STATIC=10; + + + static const GDK_WINDOW_TYPE_HINT_NORMAL=0; + static const GDK_WINDOW_TYPE_HINT_DIALOG=1; + static const GDK_WINDOW_TYPE_HINT_MENU=2; + static const GDK_WINDOW_TYPE_HINT_TOOLBAR=3; + static const GDK_WINDOW_TYPE_HINT_SPLASHSCREEN=4; + static const GDK_WINDOW_TYPE_HINT_UTILITY=5; + static const GDK_WINDOW_TYPE_HINT_DOCK=6; + static const GDK_WINDOW_TYPE_HINT_DESKTOP=7; + static const GDK_WINDOW_TYPE_HINT_DROPDOWN_MENU=8; + static const GDK_WINDOW_TYPE_HINT_POPUP_MENU=9; + static const GDK_WINDOW_TYPE_HINT_TOOLTIP=10; + static const GDK_WINDOW_TYPE_HINT_NOTIFICATION=11; + static const GDK_WINDOW_TYPE_HINT_COMBO=12; + static const GDK_WINDOW_TYPE_HINT_DND=13; + static const GDK_DELETE=0; static const GDK_DESTROY=1; static const GDK_EXPOSE=2; @@ -9461,6 +9698,13 @@ type _gtkeventtype=class static const GS_UNREALIZE= "unrealize"; static const GS_VISIBILITY_NOTIFY_EVENT= "visibility-notify-event"; static const GS_WINDOW_STATE_EVENT= "window-state-event"; + + + static const GTK_WIN_POS_NONE= 0; + static const GTK_WIN_POS_CENTER= 1; + static const GTK_WIN_POS_MOUSE= 2; + static const GTK_WIN_POS_CENTER_ALWAYS= 3; + static const GTK_WIN_POS_CENTER_ON_PARENT= 4; end { //cairo 常量 CAIRO_OPERATOR_CLEAR:=0; @@ -9515,11 +9759,17 @@ begin end function igtk(); begin - global g_w_i_datas,g_w_c_width, g_gtk_buttontable,g_gtk_keytable,g_gtk_call_handler_manager,g_gtk_font_get_size; + global g_w_i_datas,g_w_c_width, g_gtk_buttontable,g_gtk_keytable, + g_gtk_call_handler_manager,g_gtk_font_get_size,g_gtk_dragxy, + g_gtk_shadow_width,g_gtk_shadow_heigt,g_gtk_shadow_size_nset; + g_gtk_dragxy := array(0,0); g_gtk_font_get_size := array(); gtk_init_check(nil,nil); g_w_i_datas := array(); g_w_c_width := 35; + g_gtk_shadow_size_nset := true; + g_gtk_shadow_width := 52; + g_gtk_shadow_heigt := 89; g_gtk_buttontable := array(0,0); g_gtk_keytable := array(0x10:0,0x11:0,0x12:0); g_gtk_call_handler_manager := new tinstancemanager(); @@ -9593,6 +9843,22 @@ begin end end ////////////////////////new function////////////////////////////////////////////// +function c_g_e_drag_begin(w:pointer;dt:pointer;u_d:pointer):integer; // +begin + return _gtkeventcall_(w,u_d,dt); + //return do_two_param_event(a, "value-changed"); +end +function c_g_e_show(w:pointer;u_d:pointer):integer; // +begin + return do_two_param_event(w, GetGtkEventNameOrId(u_d)); + //return do_two_param_event(a, "value-changed"); +end +function c_g_e_visibility_notify_event(w:pointer;e:pointer;u_d:pointer):integer; // +begin + echo ">>>visibility_notify_event:"; + return false; + //return do_two_param_event(a, "value-changed"); +end function c_g_e_value_changed(a:pointer;b:pointer):integer; //tsl_gtk_adj_value_changed_event begin return do_two_param_event(a, "value-changed"); @@ -9753,7 +10019,22 @@ end function dotparamseevents(a:pointer; b:string;p1:pointer;p2:pointer):pointer; begin return _gtkeventcall_(a,GetGtkEventNameOrId(b),p1,p2); -end +end +function gdk_backend_is_wayland(); //wayland 判断 +begin + return static is_wayland(); +end +function is_wayland(); +begin + st := static sysgetenv("XDG_SESSION_TYPE"); + if st="wayland" then + begin + bkend := static sysgetenv("GDK_BACKEND"); + if bkend="x11" then return false; + return true; + end + return false; +end function getfuncptrbyname(lib,n); begin case lib of