Skip to content

Commit 9b6320c

Browse files
committed
adjust launcher scaling behavior
1 parent 724763f commit 9b6320c

File tree

3 files changed

+27
-14
lines changed

3 files changed

+27
-14
lines changed

embd_res/klite.embd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12252,7 +12252,7 @@ Current version indicated by LITEVER below.
1225212252
}
1225312253
else if(localflag && koboldcpp_has_txt2img && no_txt_model && safe_to_overwrite())
1225412254
{
12255-
msgboxYesNo("This KoboldCpp instance seems to be running an Image Generation model without any Text Generation model loaded.\n\nWould you like to launch StableUI (Dedicated Image Generation WebUI bundled with KoboldCpp)?\n\nIf unsure, select 'No'.","Launch StableUI?", ()=>{
12255+
msgboxYesNo("This KoboldCpp instance seems to be running an Image Generation model without any Text Generation model loaded.\n\nWould you like to launch StableUI (Dedicated Image Generation WebUI bundled with KoboldCpp)?\n\nIf unsure, select 'Yes'.","Launch StableUI?", ()=>{
1225612256
go_to_stableui();
1225712257
},()=>{
1225812258
});

environment-nocuda.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ channels:
33
- conda-forge
44
- defaults
55
dependencies:
6-
- python=3.10
6+
- python=3.8
77
- cxx-compiler
88
- gxx=10
99
- pip

koboldcpp.py

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4884,7 +4884,7 @@ def show_gui():
48844884
#check for wayland with fractional scale
48854885
def get_problematic_scaler():
48864886
if sys.platform != "linux" or os.environ.get("XDG_SESSION_TYPE") != "wayland":
4887-
return 1.0
4887+
return False
48884888
import xml.etree.ElementTree as ET
48894889
from pathlib import Path
48904890
fractional_enabled = False # Check if fractional scaling is enabled
@@ -4895,16 +4895,18 @@ def get_problematic_scaler():
48954895
).strip()
48964896
fractional_enabled = "scale-monitor-framebuffer" in features
48974897
except Exception:
4898-
return 1.0
4898+
return False
48994899
xml_path = Path.home() / ".config" / "monitors.xml"
4900-
if not xml_path.exists():
4901-
return 1.0
4900+
if not xml_path.exists(): #monitors.xml not found. if we have fractional scaling on gnome, just trigger the fallback
4901+
if fractional_enabled and "GNOME" in os.environ.get("XDG_CURRENT_DESKTOP"):
4902+
return True
4903+
return False
49024904
try:
49034905
tree = ET.parse(xml_path)
49044906
root = tree.getroot()
49054907
configs = root.findall(".//configuration")
49064908
if not configs:
4907-
return 1.0
4909+
return False
49084910
logical_confs = [c for c in configs if c.findtext(".//layoutmode") == "logical"]
49094911
physical_confs = [c for c in configs if c.findtext(".//layoutmode") == "physical"]
49104912
if fractional_enabled and logical_confs:
@@ -4915,20 +4917,20 @@ def get_problematic_scaler():
49154917
chosen_conf = configs[-1]
49164918
scales = [float(s.text) for s in chosen_conf.findall(".//scale") if s.text]
49174919
if scales:
4918-
return max(scales)
4920+
return max(scales)>1.0
49194921
except Exception:
49204922
pass
4921-
return 1.0
4923+
return False
49224924

49234925
import customtkinter as ctk
49244926
nextstate = 0 #0=exit, 1=launch
4925-
corrupt_scaler = (get_problematic_scaler() > 1.0)
4927+
corrupt_scaler = get_problematic_scaler()
49264928
original_windowwidth = int(860 if corrupt_scaler else 580)
49274929
original_windowheight = int(740 if corrupt_scaler else 580)
49284930
windowwidth = original_windowwidth
49294931
windowheight = original_windowheight
49304932
ctk.set_appearance_mode("dark")
4931-
root = ctk.CTk()
4933+
root = ctk.CTk(fg_color="#2b2b2b")
49324934
root.geometry(str(windowwidth) + "x" + str(windowheight))
49334935
root.title(f"KoboldCpp v{KcppVersion}")
49344936

@@ -4939,9 +4941,18 @@ def get_problematic_scaler():
49394941
window_reference_height = None
49404942
previous_event_width = None
49414943
previous_event_height = None
4944+
resizing = False
4945+
def clearesizing():
4946+
nonlocal resizing
4947+
resizing = False
49424948
def on_resize(event):
4943-
if not event.widget.master:
4949+
nonlocal resizing
4950+
if not event.widget.master and event.widget == root:
49444951
nonlocal window_reference_width, window_reference_height, previous_event_width,previous_event_height
4952+
if resizing:
4953+
previous_event_width = event.width
4954+
previous_event_height = event.height
4955+
return
49454956
if not window_reference_width and not window_reference_height:
49464957
window_reference_width = event.width
49474958
window_reference_height = event.height
@@ -4955,17 +4966,19 @@ def on_resize(event):
49554966
smallratio = min(incr_w,incr_h)
49564967
smallratio = round(smallratio,2)
49574968
if new_width != previous_event_width or new_height!=previous_event_height:
4969+
resizing = True
49584970
lastpos = root.geometry()
49594971
lparr = lastpos.split('+', 1)
49604972
lastpos = ("+"+str(lparr[1])) if (len(lparr)==2) else ""
49614973
previous_event_width = new_width
49624974
previous_event_height = new_height
4963-
windowwidth = math.floor(original_windowwidth*smallratio)
4975+
windowwidth = math.floor(original_windowwidth*max(smallratio,min(incr_w,smallratio*1.2))) #allow slight extension past legal width
49644976
windowwidth = max(256, min(1024, windowwidth))
49654977
windowheight = math.floor(original_windowheight*smallratio)
49664978
windowheight = max(256, min(1024, windowheight))
49674979
root.geometry(str(windowwidth) + "x" + str(windowheight) + str(lastpos))
49684980
ctk.set_widget_scaling(smallratio)
4981+
root.after(20, clearesizing)
49694982
changerunmode(1,1,1)
49704983
togglerope(1,1,1)
49714984
toggleflashattn(1,1,1)
@@ -5016,7 +5029,7 @@ def hide_tooltip(event):
50165029
navbuttonframe.grid(row=0, column=0, padx=2,pady=2)
50175030
navbuttonframe.grid_propagate(False)
50185031

5019-
tabcontentframe = ctk.CTkFrame(tabs, width=windowwidth - int(navbuttonframe.cget("width")), height=int(tabs.cget("height")))
5032+
tabcontentframe = ctk.CTkFrame(tabs, width=windowwidth - int(navbuttonframe.cget("width")), height=int(tabs.cget("height")),fg_color="transparent")
50205033
tabcontentframe.grid(row=0, column=1, sticky="nsew", padx=2, pady=2)
50215034
tabcontentframe.grid_propagate(False)
50225035

0 commit comments

Comments
 (0)