Skip to content

Commit

Permalink
fixed centering and cloud login sizing
Browse files Browse the repository at this point in the history
  • Loading branch information
twocanoes committed Dec 9, 2023
1 parent 8a0994c commit f83d523
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 192 deletions.
41 changes: 12 additions & 29 deletions MainLoginWindowController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,11 @@ class MainLoginWindowController: NSWindowController {
return
}
self.window?.contentView?.addSubview(controlsViewController.view)
let rect = NSMakeRect(0, 0, controlsViewController.view.frame.size.width,120)
let rect = NSMakeRect(0, 0, controlsViewController.view.frame.size.width,controlsViewController.view.frame.size.height)
controlsViewController.view.frame=rect
// controlsViewController.delegate=self.delegate

TCSLogWithMark("Configure login window")
// loginAppearance()
setupLoginWindowAppearance()

TCSLogWithMark("create background windows")
Expand All @@ -63,13 +62,13 @@ class MainLoginWindowController: NSWindowController {
// Disabling due to it causing screen resizing during EULA
let notificationCenter = NotificationCenter.default
notificationCenter.addObserver(self,
selector: #selector(updateWindowAfterResize),
selector: #selector(updateWindow),
name: NSApplication.didChangeScreenParametersNotification,
object: nil)
}

}
@objc fileprivate func updateWindowAfterResize() {
@objc fileprivate func updateWindow() {

DispatchQueue.main.async{
if self.window?.isVisible ?? true {
Expand All @@ -79,9 +78,11 @@ class MainLoginWindowController: NSWindowController {

self.window?.setFrame(NSMakeRect(0,0 , screenWidth, screenHeight), display: true)

let rect = NSMakeRect(0, 0, screenWidth,120)
if let height = self.controlsViewController?.view.frame.size.height {
let rect = NSMakeRect(0, 0, screenWidth,height)

self.controlsViewController?.view.frame=rect
self.controlsViewController?.view.frame=rect
}
self.recenterCenterView()
}
}
Expand All @@ -104,31 +105,9 @@ class MainLoginWindowController: NSWindowController {
self.window?.canBecomeVisibleWithoutLogin = true

let screenRect = NSScreen.screens[0].frame
let screenWidth = screenRect.width
let screenHeight = screenRect.height

var loginWindowWidth = screenWidth //start with full size
var loginWindowHeight = screenHeight //start with full size

//if prefs define smaller, then resize window
TCSLogWithMark("checking for custom height and width")
if DefaultsOverride.standardOverride.object(forKey: PrefKeys.loginWindowWidth.rawValue) != nil {
let val = CGFloat(DefaultsOverride.standardOverride.float(forKey: PrefKeys.loginWindowWidth.rawValue))
if val > 100 {
TCSLogWithMark("setting loginWindowWidth to \(val)")
loginWindowWidth = val
}
}
if DefaultsOverride.standardOverride.object(forKey: PrefKeys.loginWindowHeight.rawValue) != nil {
let val = CGFloat(DefaultsOverride.standardOverride.float(forKey: PrefKeys.loginWindowHeight.rawValue))
if val > 100 {
TCSLogWithMark("setting loginWindowHeight to \(val)")
loginWindowHeight = val
}
}

self.window?.setFrame(screenRect, display: true, animate: false)
let rect = NSMakeRect(0, 0, self.window?.contentView?.frame.size.width ?? 100,120)
let rect = NSMakeRect(0, 0, self.window?.contentView?.frame.size.width ?? 100,117)

self.controlsViewController?.view.frame=rect

Expand Down Expand Up @@ -242,7 +221,11 @@ class MainLoginWindowController: NSWindowController {

centerView.setFrameOrigin(lowerLeftCorner)
}
if let controlsView = controlsViewController?.view {
controlsView.removeFromSuperview()
self.window?.contentView?.addSubview(controlsView)

}
}
func addCenterView(_ centerView:NSView){
TCSLogWithMark("re-centering")
Expand Down
18 changes: 6 additions & 12 deletions XCreds/LoginWebViewController.xib
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="LoginWebViewController" customModule="XCredsLoginPlugin">
<connections>
<outlet property="backgroundImageView" destination="LND-Te-8nB" id="Prm-fa-DgN"/>
<outlet property="view" destination="2LH-tE-efn" id="ZJD-dq-nuj"/>
<outlet property="webView" destination="IVa-Nc-Vs1" id="d8m-Bi-lYF"/>
<outlet property="window" destination="KxT-zM-Vnn" id="v4i-bY-4eE"/>
Expand All @@ -25,13 +24,8 @@
<rect key="frame" x="0.0" y="0.0" width="1002" height="883"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="LND-Te-8nB">
<wkWebView wantsLayer="YES" allowsLinkPreview="NO" translatesAutoresizingMaskIntoConstraints="NO" id="IVa-Nc-Vs1">
<rect key="frame" x="0.0" y="0.0" width="1002" height="883"/>
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" id="TLB-Dt-CAz"/>
</imageView>
<wkWebView wantsLayer="YES" fixedFrame="YES" allowsLinkPreview="NO" translatesAutoresizingMaskIntoConstraints="NO" id="IVa-Nc-Vs1">
<rect key="frame" x="187" y="210" width="628" height="613"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<wkWebViewConfiguration key="configuration" allowsAirPlayForMediaPlayback="NO" suppressesIncrementalRendering="YES">
<audiovisualMediaTypes key="mediaTypesRequiringUserActionForPlayback" none="YES"/>
<wkPreferences key="preferences" javaScriptCanOpenWindowsAutomatically="NO"/>
Expand All @@ -42,16 +36,16 @@
</wkWebView>
</subviews>
<constraints>
<constraint firstItem="LND-Te-8nB" firstAttribute="leading" secondItem="2LH-tE-efn" secondAttribute="leading" id="fow-VT-aOT"/>
<constraint firstItem="LND-Te-8nB" firstAttribute="top" secondItem="2LH-tE-efn" secondAttribute="top" id="gO1-aU-BKz"/>
<constraint firstAttribute="trailing" secondItem="LND-Te-8nB" secondAttribute="trailing" id="gwd-4q-kbH"/>
<constraint firstAttribute="bottom" secondItem="LND-Te-8nB" secondAttribute="bottom" id="nCQ-2r-Isx"/>
<constraint firstAttribute="trailing" secondItem="IVa-Nc-Vs1" secondAttribute="trailing" id="OcE-FD-9VC"/>
<constraint firstItem="IVa-Nc-Vs1" firstAttribute="top" secondItem="2LH-tE-efn" secondAttribute="top" id="YBv-2B-OZ5"/>
<constraint firstAttribute="bottom" secondItem="IVa-Nc-Vs1" secondAttribute="bottom" id="byG-kT-3XZ"/>
<constraint firstItem="IVa-Nc-Vs1" firstAttribute="leading" secondItem="2LH-tE-efn" secondAttribute="leading" id="pSj-sh-ecG"/>
</constraints>
</view>
<connections>
<outlet property="delegate" destination="-2" id="WYj-G7-iZU"/>
</connections>
<point key="canvasLocation" x="63" y="432.5"/>
<point key="canvasLocation" x="-5" y="427.5"/>
</window>
</objects>
</document>
4 changes: 2 additions & 2 deletions XCredsLoginPlugIn/LoginWindow/ControlsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Cocoa
class ControlsViewController: NSViewController {
var delegate: XCredsMechanismProtocol?

@IBOutlet weak var macLoginWindowGribColumn: NSGridColumn?
@IBOutlet weak var macLoginWindowGridColumn: NSGridColumn?
@IBOutlet weak var wifiGridColumn: NSGridColumn?
@IBOutlet weak var toolsView: NSView?

Expand Down Expand Up @@ -204,7 +204,7 @@ class ControlsViewController: NSViewController {
self.wifiGridColumn?.isHidden = !DefaultsOverride.standardOverride.bool(forKey: PrefKeys.shouldShowConfigureWifiButton.rawValue)
TCSLogWithMark()

self.macLoginWindowGribColumn?.isHidden = !DefaultsOverride.standardOverride.bool(forKey: PrefKeys.shouldShowMacLoginButton.rawValue)
self.macLoginWindowGridColumn?.isHidden = !DefaultsOverride.standardOverride.bool(forKey: PrefKeys.shouldShowMacLoginButton.rawValue)
TCSLogWithMark()

self.versionTextField?.isHidden = !DefaultsOverride.standardOverride.bool(forKey: PrefKeys.shouldShowVersionInfo.rawValue)
Expand Down
2 changes: 1 addition & 1 deletion XCredsLoginPlugIn/LoginWindow/ControlsViewController.xib
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="ControlsViewController" customModule="XCredsLoginPlugin">
<connections>
<outlet property="macLoginWindowGribColumn" destination="Qgw-6x-QRs" id="YHA-Qx-deF"/>
<outlet property="macLoginWindowGridColumn" destination="Qgw-6x-QRs" id="YHA-Qx-deF"/>
<outlet property="toolsView" destination="4X8-WT-UyO" id="TTk-aU-6Vw"/>
<outlet property="trialVersionStatusTextField" destination="D8S-gh-gv5" id="yc8-WQ-xH8"/>
<outlet property="versionTextField" destination="p61-id-z2n" id="qZT-E7-l0T"/>
Expand Down
30 changes: 30 additions & 0 deletions XCredsLoginPlugIn/Mechanisms/XCredsLoginMechanism.swift
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,36 @@ import Network
}

loginWebViewController.delegate=self
let screenRect = NSScreen.screens[0].frame

let screenWidth = screenRect.width
let screenHeight = screenRect.height

var loginWindowWidth = screenWidth //start with full size
var loginWindowHeight = screenHeight //start with full size


//if prefs define smaller, then resize window
TCSLogWithMark("checking for custom height and width")
if DefaultsOverride.standardOverride.object(forKey: PrefKeys.loginWindowWidth.rawValue) != nil {
let val = CGFloat(DefaultsOverride.standardOverride.float(forKey: PrefKeys.loginWindowWidth.rawValue))
if val > 100 {
TCSLogWithMark("setting loginWindowWidth to \(val)")
loginWindowWidth = val
}
}
if DefaultsOverride.standardOverride.object(forKey: PrefKeys.loginWindowHeight.rawValue) != nil {
let val = CGFloat(DefaultsOverride.standardOverride.float(forKey: PrefKeys.loginWindowHeight.rawValue))
if val > 100 {
TCSLogWithMark("setting loginWindowHeight to \(val)")
loginWindowHeight = val
}
}
TCSLogWithMark("setting loginWindowWidth to \(loginWindowWidth)")

TCSLogWithMark("setting loginWindowHeight to \(loginWindowHeight)")

loginWebViewController.view.setFrameSize(NSMakeSize(loginWindowWidth, loginWindowHeight))
mainLoginWindowController.addCenterView(loginWebViewController.view)


Expand Down
3 changes: 2 additions & 1 deletion app_to_test.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/sh -e


set -e
Expand Down Expand Up @@ -38,3 +38,4 @@ ssh root@"${REMOTE_MAC}" /Applications/XCreds.app/Contents/Resources/xcreds_log

#ssh root@"${REMOTE_MAC}" killall -9 SecurityAgent || echo "unable to kill"
ssh root@"${REMOTE_MAC}" reboot
exit 0
12 changes: 6 additions & 6 deletions xCreds.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1293,7 +1293,7 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 5459;
CURRENT_PROJECT_VERSION = 5481;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = UXP6YEHSPW;
FRAMEWORK_SEARCH_PATHS = (
Expand Down Expand Up @@ -1331,7 +1331,7 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 5459;
CURRENT_PROJECT_VERSION = 5481;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = UXP6YEHSPW;
FRAMEWORK_SEARCH_PATHS = (
Expand Down Expand Up @@ -1451,7 +1451,7 @@
CODE_SIGN_ENTITLEMENTS = "XCreds Login Overlay/XCreds_Login_Overlay.entitlements";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 5459;
CURRENT_PROJECT_VERSION = 5481;
DEVELOPMENT_TEAM = UXP6YEHSPW;
ENABLE_HARDENED_RUNTIME = YES;
FRAMEWORK_SEARCH_PATHS = (
Expand Down Expand Up @@ -1488,7 +1488,7 @@
CODE_SIGN_ENTITLEMENTS = "XCreds Login Overlay/XCreds_Login_Overlay.entitlements";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 5459;
CURRENT_PROJECT_VERSION = 5481;
DEVELOPMENT_TEAM = UXP6YEHSPW;
ENABLE_HARDENED_RUNTIME = YES;
FRAMEWORK_SEARCH_PATHS = (
Expand Down Expand Up @@ -1638,7 +1638,7 @@
CODE_SIGN_ENTITLEMENTS = XCreds/xCreds.entitlements;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 5459;
CURRENT_PROJECT_VERSION = 5481;
DEVELOPMENT_TEAM = UXP6YEHSPW;
ENABLE_HARDENED_RUNTIME = YES;
FRAMEWORK_SEARCH_PATHS = (
Expand Down Expand Up @@ -1679,7 +1679,7 @@
CODE_SIGN_ENTITLEMENTS = XCreds/xCreds.entitlements;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 5459;
CURRENT_PROJECT_VERSION = 5481;
DEVELOPMENT_TEAM = UXP6YEHSPW;
ENABLE_HARDENED_RUNTIME = YES;
FRAMEWORK_SEARCH_PATHS = (
Expand Down
Binary file not shown.

0 comments on commit f83d523

Please sign in to comment.